:root {
    --bg:      #f4f6f9;
    --bg2:     #ffffff;
    --accent:  #1a5c9e;
    --accent2: #2272c3;
    --navy:    #1a2332;
    --text:    #1a2332;
    --muted:   #5a6a7a;
    --border:  #d0d7e0;
    --danger:  #c0392b;
    --success: #1e8449;
    --warn:    #c8820a;
    --zero:    #b8c2ce;
    --shadow:  0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Barlow', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Nav ---- */
nav {
    background: var(--navy);
    border-bottom: 3px solid var(--accent);
    display: flex; align-items: stretch; padding: 0; min-height: 64px;
    position: sticky; top: 0; z-index: 50;
}
.nav-brand {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 24px; background: #ffffff;
    border-right: 3px solid var(--accent); text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand img { height: 42px; width: auto; display: block; }
.nav-brand-text {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.95rem; font-weight: 700; color: var(--navy);
    letter-spacing: 0.08em; text-transform: uppercase;
}
nav a.nav-link {
    color: #ffffff; text-decoration: none; padding: 0 20px;
    font-size: 0.85rem; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; transition: color 0.15s, background 0.15s;
    border-right: 1px solid #2e3d55; display: flex; align-items: center;
}
nav a.nav-link:hover, nav a.nav-link.active {
    color: #ffffff; background: var(--accent2); text-decoration: none;
}
nav .admin-on {
    color: #7fe0a4 !important; font-weight: 700; cursor: default;
    display: flex; align-items: center; letter-spacing: 0.08em;
}
nav .admin-on:hover { background: transparent; }

.container { max-width: 1800px; margin: 0 auto; padding: 28px 24px; }

/* ---- Page header ---- */
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid var(--border);
    flex-wrap: wrap; gap: 16px;
}
.page-title {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.8rem;
    font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text);
}
.page-title span { color: var(--accent); }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.page-sub strong { color: var(--text); }
.head-actions { display: flex; align-items: flex-end; gap: 12px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px;
    border: none; border-radius: 4px; font-family: 'Barlow', sans-serif;
    font-size: 0.85rem; font-weight: 500; letter-spacing: 0.04em;
    text-transform: uppercase; cursor: pointer; text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); color: #fff; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: #f0f5fc; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

.icon-btn {
    border: none; background: none; cursor: pointer; font-size: 15px;
    padding: 4px 7px; border-radius: 4px; color: var(--muted); line-height: 1;
}
.icon-btn:hover { background: #f0f5fc; color: var(--accent); }
.del-btn:hover { background: #fdf0ee; color: var(--danger); }

/* ---- Alerts ---- */
.alert { padding: 12px 18px; border-radius: 4px; margin-bottom: 20px; font-size: 0.9rem; border-left: 4px solid; }
.alert-success { background: #eafaf1; border-color: var(--success); color: #1a6e3c; }
.alert-warning { background: #fef9ec; border-color: var(--warn); color: #7d5a00; }
.alert-error,
.alert-danger { background: #fdf0ee; border-color: var(--danger); color: #922b21; }
.alert-info { background: #eaf4fb; border-color: #2980b9; color: #1a5276; }

/* ---- Stat pills (reusable summary cards) ---- */
.stat-row { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-pill {
    flex: 1; min-width: 130px;
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    padding: 14px 20px; font-family: 'Barlow Condensed', sans-serif; box-shadow: var(--shadow);
}
.stat-pill.accent { background: var(--navy); border-color: var(--navy); }
.stat-pill.accent .stat-num { color: #fff; }
.stat-pill.accent .stat-lbl { color: #aeb9c7; }
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-num.small { font-size: 1.1rem; }
.stat-editable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.stat-editable:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.10); }
.stat-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 4px; }
.stat-sub { font-size: 0.82rem; font-weight: 600; color: var(--success); margin-top: 3px; }
.stat-pill.accent .stat-sub { color: #7fe0a4; }
.stat-row-compact .stat-pill { padding: 11px 16px; min-width: 100px; }
.stat-row-compact .stat-num { font-size: 1.45rem; }

.sort-label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sort-label select {
    display: block; margin-top: 6px; padding: 8px 12px; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 4px; font-family: 'Barlow', sans-serif; font-size: 0.9rem; cursor: pointer;
}

/* ---- Table (reusable data grid with sticky header) ---- */
/* No overflow wrapper on wide screens, so the sticky header resolves against
   the viewport (native sticky breaks inside an overflow-x container). Only
   enable horizontal scroll on narrow screens. The nav is sticky at top:0 and
   ~67px tall, so the header sticks at top:67px just beneath it. */
.table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
@media (max-width: 1200px) {
    .table-wrap { overflow-x: auto; }
}
table.grid { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.grid thead tr { background: #f8f9fb; }
table.grid th {
    padding: 12px 14px; text-align: left; font-family: 'Barlow Condensed', sans-serif;
    font-size: 1rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--navy); border-bottom: 2px solid var(--border);
    white-space: nowrap; position: sticky; top: 67px; background: #f8f9fb; z-index: 20;
}
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover td { background: #f0f5fc; }
table.grid td.company { font-weight: 500; }
.zero { color: var(--zero); }
.total-col { background: #eef4fb; }
table.grid thead .total-col { background: #e6eef8; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
table.grid thead .sticky-col { background: #f8f9fb; z-index: 21; }
table.grid tbody tr:hover .sticky-col { background: #f0f5fc; }
table.grid tfoot td {
    border-top: 2px solid var(--navy); background: #f8f9fb;
    font-variant-numeric: tabular-nums; font-weight: 700;
}
table.grid tfoot .sticky-col { background: #f8f9fb; }
.actions-col { text-align: center; width: 74px; }

/* ---- Cards ---- */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.card-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    font-family: 'Barlow Condensed', sans-serif; font-size: 0.9rem; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
    background: #f8f9fb; border-radius: 6px 6px 0 0;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-body { padding: 20px; }

/* ---- Modal ---- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(26,35,50,.55);
    align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 6px; width: 100%; max-width: 540px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3); border-top: 4px solid var(--accent); }
.modal-head {
    padding: 16px 22px; border-bottom: 1px solid var(--border);
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.15rem; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase; color: var(--text);
}
.modal-body { padding: 22px; }
.field { display: block; margin-bottom: 18px; }
.field-label {
    display: block; margin-bottom: 6px; font-size: 0.78rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.field input, .modal input.minput {
    width: 100%; padding: 9px 13px; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 4px;
    font-family: 'Barlow', sans-serif; font-size: 0.92rem; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .modal input.minput:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.12);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

/* ---- Login (standalone, full-page gate) ---- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px; background: var(--bg);
}
.login-card {
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    border-top: 4px solid var(--accent); box-shadow: 0 6px 24px rgba(0,0,0,.10);
    padding: 34px 32px; width: 100%; max-width: 380px; text-align: center;
}
.login-logo { height: 46px; width: auto; margin: 0 auto 14px; display: block; }
.login-title {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.15rem; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--navy);
    margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.login-hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }
.login-card input {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 5px;
    font-size: 1rem; margin-bottom: 16px; text-align: center; letter-spacing: 3px;
    font-family: 'Barlow', sans-serif;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.12); }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 0.95rem; }
.login-card .alert { text-align: left; }

/* ---- Settings ---- */
.settings-wrap { max-width: 560px; }

/* ---- Footer ---- */
.foot {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1800px; margin: 20px auto 0; padding: 20px 24px 30px;
    border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem;
}
.foot .mono { font-family: 'Barlow Condensed', sans-serif; letter-spacing: 0.05em; text-transform: uppercase; }
@media (max-width: 640px) { .foot { flex-direction: column; gap: 6px; text-align: center; } }


/* =========================================================================
   App Dashboard - app-specific additions (built on the shared tokens)
   ========================================================================= */

/* Signed-in user in the nav (pushed to the right) */
nav .nav-spacer { margin-left: auto; }
nav .nav-user { color: #7fe0a4; cursor: default; text-transform: none; letter-spacing: 0.02em; font-weight: 600; white-space: nowrap; }
nav .nav-user:hover { background: transparent; }

/* Tile grid */
.section { margin-bottom: 30px; }
.section-title {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1rem; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
    margin-bottom: 12px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
a.tile {
    display: flex; flex-direction: column; gap: 8px; min-height: 150px;
    background: #fff; border: 1px solid var(--border); border-top: 4px solid var(--accent);
    border-radius: 6px; box-shadow: var(--shadow); padding: 18px 20px;
    color: var(--text); text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
a.tile:hover, a.tile:focus-visible {
    text-decoration: none; border-color: var(--accent2); outline: none;
    box-shadow: 0 6px 18px rgba(26,92,158,0.16); transform: translateY(-2px);
}
.tile-head { display: flex; align-items: flex-start; gap: 10px; }
.tile-head .status-dot { margin-top: 6px; }
.tile-name {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.3rem; font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase; color: var(--navy); line-height: 1.1;
}
.tile-desc { color: var(--muted); font-size: 0.88rem; line-height: 1.4; flex: 1; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tile-host { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-open {
    flex-shrink: 0; padding: 5px 12px; border-radius: 4px; background: var(--accent); color: #fff;
    font-size: 0.78rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
}
a.tile:hover .tile-open { background: var(--accent2); }
.tile-badge {
    margin-left: auto; padding: 1px 7px; border-radius: 3px; background: #fef9ec; color: #7d5a00;
    font-family: 'Barlow Condensed', sans-serif; font-size: 0.72rem; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
}

/* Status light: grey until checked, then green / red / grey (can't tell) */
.status-dot {
    flex-shrink: 0; width: 11px; height: 11px; border-radius: 50%;
    background: var(--zero); box-shadow: 0 0 0 3px rgba(184,194,206,0.25);
}
.status-dot.up      { background: var(--success); box-shadow: 0 0 0 3px rgba(30,132,73,0.18); }
.status-dot.down    { background: var(--danger);  box-shadow: 0 0 0 3px rgba(192,57,43,0.18); }
.status-dot.unknown { background: var(--zero); }
.legend { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 0.8rem; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.empty-state { background: #fff; border: 1px dashed var(--border); border-radius: 6px; padding: 40px; text-align: center; color: var(--muted); }

/* Manage Links / Users tables and forms */
.muted { color: var(--muted); }
.mono-num { font-family: 'Barlow Condensed', sans-serif; font-size: 1rem; font-weight: 600; letter-spacing: 0.04em; }
.inactive-row td { color: var(--muted); background: #fafbfc; }
.inline-input {
    width: 100%; min-width: 120px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 4px;
    font-family: 'Barlow', sans-serif; font-size: 0.88rem; background: #fff;
}
.inline-input.narrow { min-width: 0; width: 70px; }
.inline-input:focus { outline: none; border-color: var(--accent); }
.inline-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.inline-form input[type=text], .inline-form input[type=password],
.inline-form input[type=url], .inline-form input[type=number] {
    display: block; margin-top: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
    font-family: 'Barlow', sans-serif; font-size: 0.9rem; background: #fff; width: 100%;
}
.inline-form input:focus { outline: none; border-color: var(--accent); }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; padding-bottom: 1px; }
.check-label input[type=checkbox] { display: block; margin-top: 12px; width: 18px; height: 18px; }
table.grid td.center, table.grid th.center { text-align: center; }
table.grid td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 1400px) { table.grid.links-grid td { padding: 8px 8px; } }

