/* ------------------------------------------------------------------------
   Theme: light top navbar with dropdowns + card-first layout.
   Palette: purple/blue primary, teal/cyan supporting accents.
   ------------------------------------------------------------------------ */

:root {
    --bg: #f3f4f9;
    --surface: #ffffff;
    --surface-muted: #f6f5fb;
    --border: #e6e5f1;
    --ink: #1f2130;
    --ink-soft: #6b6f8a;
    --ink-faint: #9a9db3;

    --primary: #6f42c1;
    --primary-dark: #5a34a0;
    --primary-soft: #f1ebfa;
    --blue: #007bff;
    --blue-soft: #e6f2ff;
    --teal: #17a2b8;
    --teal-soft: #e3f7f9;
    --cyan: #0dcaf0;
    --cyan-soft: #e0f9fd;

    --good: #16a34a;
    --good-soft: #e5f6ea;
    --bad: #dc2626;
    --bad-soft: #fce8e6;
    --warn: #d97706;
    --warn-soft: #fdf1de;

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 2px rgba(31, 33, 48, 0.04), 0 10px 24px -14px rgba(111, 66, 193, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, .display {
    font-family: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
    font-weight: 500;
    color: var(--ink);
    margin: 0 0 0.4em;
}

h1 { font-size: 2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin-top: 0; }
em { color: var(--primary); font-style: italic; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.72rem;
    color: var(--ink-faint);
    font-weight: 600;
}

/* ---------------------------------------------------------------------
   Top navbar
   --------------------------------------------------------------------- */

.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 0 rgba(31, 33, 48, 0.03);
}

.topnav-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0.7rem 1.75rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--blue));
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: "Fraunces", serif;
    font-weight: 600;
    font-size: 1.05rem;
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--ink);
    text-decoration: none;
    flex: none;
}
.topnav-brand:hover { text-decoration: none; }
.topnav-brand .name { font-family: "Fraunces", serif; font-size: 1.05rem; line-height: 1.1; }
.topnav-brand .tag { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); }

.topnav-menu {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.topnav-link {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
}
.topnav-link:hover { color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.topnav-link.active { color: var(--primary); background: var(--primary-soft); }

.topnav-dropdown { position: relative; }
.topnav-dropdown summary {
    list-style: none;
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.topnav-dropdown summary::-webkit-details-marker { display: none; }
.topnav-dropdown summary::after { content: "\25BE"; font-size: 0.7em; color: var(--ink-faint); }
.topnav-dropdown[open] summary, .topnav-dropdown summary:hover { color: var(--primary); background: var(--primary-soft); }
.topnav-dropdown.has-active summary { color: var(--primary); }

.dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 0.4rem;
    min-width: 190px;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.dropdown-panel a {
    color: var(--ink);
    text-decoration: none;
    font-size: 0.86rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
}
.dropdown-panel a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.dropdown-panel a.active { color: var(--primary); font-weight: 600; background: var(--primary-soft); }

.topnav-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: none;
}

.badge-admin {
    background: var(--primary);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
}

.topnav-user {
    font-size: 0.82rem;
    color: var(--ink-soft);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 2rem 1.75rem 3.5rem;
}

/* Centered shell for login / admin password gate */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(650px 320px at 12% -10%, var(--primary-soft) 0%, transparent 60%),
        radial-gradient(500px 280px at 100% 0%, var(--blue-soft) 0%, transparent 55%),
        var(--bg);
    padding: 1.5rem;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.auth-card .brand-mark { margin: 0 auto 1rem; }
.auth-card h1 { font-size: 1.5rem; }
.auth-card .lede { color: var(--ink-soft); margin-bottom: 1.6rem; font-size: 0.92rem; }

/* ---------------------------------------------------------------------
   Cards, stats, pills
   --------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 1.5rem 1.6rem;
    margin-bottom: 1.5rem;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}
.card-head h2 { margin: 0; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.6rem;
}
.topbar .eyebrow { margin-bottom: 0.35rem; }
.topbar h1 { margin-bottom: 0; }
.topbar .lede { color: var(--ink-soft); margin-top: 0.35rem; max-width: 52ch; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 1.1rem 1.2rem;
    position: relative;
    overflow: hidden;
}
.stat-tile::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent, var(--primary));
}
.stat-tile .eyebrow { margin-bottom: 0.5rem; }
.stat-tile .num { font-family: "Fraunces", serif; font-size: 1.8rem; color: var(--ink); }
.stat-tile .num small { font-size: 1rem; color: var(--ink-faint); font-family: inherit; }

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tile-link {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 1.1rem 1.2rem;
    text-decoration: none;
    color: var(--ink);
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.tile-link:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }
.tile-link .tile-id { font-family: "Fraunces", serif; font-size: 1.1rem; margin-bottom: 0.5rem; }

/* Row-cards: the default way lists are shown (users, hubs, nodes, sharing...) */
.row-card-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.5rem; }

.row-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 0.9rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.row-card .row-main { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }

.row-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: "Fraunces", serif;
    font-weight: 600;
    font-size: 1rem;
}

.row-card .row-title { font-weight: 600; }
.row-card .row-title a { color: var(--ink); }
.row-card .row-title a:hover { color: var(--primary); }
.row-card .row-sub { font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.1rem; }
.row-card .row-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row-card .row-actions { display: flex; gap: 0.5rem; align-items: center; }

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
}
th {
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    color: var(--ink-faint);
    font-weight: 600;
    padding: 0 0.7rem 0.6rem;
    border-bottom: 1px solid var(--border);
}
td {
    padding: 0.65rem 0.7rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
tr:last-child td { border-bottom: none; }
td.muted, .muted { color: var(--ink-faint); }
td.mono, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.83rem; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.65rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-neutral { background: var(--surface-muted); color: var(--ink-soft); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-primary { background: var(--primary-soft); color: var(--primary-dark); }
.pill-teal { background: var(--teal-soft); color: var(--teal); }

/* ---------------------------------------------------------------------
   Admin: toolbars (search/filter), pagination
   --------------------------------------------------------------------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1.25rem; }
.toolbar input[type="text"], .toolbar input[type="date"], .toolbar select { width: auto; min-width: 160px; }
.toolbar select {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--ink);
}
.toolbar form { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

.pagination { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.5rem; font-size: 0.85rem; color: var(--ink-soft); }
.pagination .btn-sm { padding: 0.3rem 0.7rem; }

.count-badge {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    margin-left: 0.4rem;
}

.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.9rem 1.5rem; margin-bottom: 0.5rem; }
.kv-grid .kv-label { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.68rem; color: var(--ink-faint); margin-bottom: 0.2rem; }
.kv-grid .kv-value { font-size: 0.92rem; }

.danger-zone { border: 1px solid #f3d2ce; background: var(--bad-soft); border-radius: var(--radius-md); padding: 1.1rem 1.3rem; }
.danger-zone h2 { color: var(--bad); }

.payload-cell { max-width: 360px; white-space: pre-wrap; word-break: break-word; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.activity-list li:last-child { border-bottom: none; }
.activity-list .label { font-weight: 600; }
.activity-list .detail { color: var(--ink-soft); }
.activity-list .when { color: var(--ink-faint); font-size: 0.78rem; white-space: nowrap; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-soft); }

.flashes { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.flashes li { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #ded0f2; border-radius: var(--radius-sm); padding: 0.7rem 1rem; font-size: 0.88rem; }

.section-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.section-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.8rem; background: var(--surface-muted); border-radius: var(--radius-sm); font-size: 0.9rem; }

/* ---------------------------------------------------------------------
   Forms & buttons
   --------------------------------------------------------------------- */

.field { display: block; margin-bottom: 1.1rem; text-align: left; }
.field .field-label { display: block; font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 0.35rem; font-weight: 600; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--ink);
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.btn, button, input[type="submit"] {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.62rem 1.15rem;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover, button:hover, input[type="submit"]:hover { background: var(--primary-dark); text-decoration: none; }

.btn-outline { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--surface-muted); border-color: var(--ink-faint); color: var(--ink); }

.btn-block { width: 100%; justify-content: center; }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.78rem; }

.inline-form { display: inline-block; margin: 0; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 180px; }
.checkbox-field { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-field input { width: auto; }

@media (max-width: 900px) {
    .topnav-inner { flex-wrap: wrap; }
    .topnav-menu { order: 3; width: 100%; }
    .page { padding: 1.5rem 1rem; }
}
