:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-muted: #eef4f7;
    --line: #d9e3ea;
    --text: #1d2a32;
    --muted: #657783;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #dbeafe;
    --danger: #b91c1c;
    --shadow: 0 16px 40px rgba(26, 48, 58, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #f8fbfc 0%, var(--bg) 42%);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .85rem clamp(1rem, 3vw, 2rem);
    background: rgba(255,255,255,.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: .75rem; color: var(--text); margin-right: auto; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-weight: 800;
    letter-spacing: -.04em;
}
.brand small { display: block; color: var(--muted); font-size: .78rem; }
.topnav { display: flex; gap: .4rem; flex-wrap: wrap; }
.topnav a, .logout-form button {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: .55rem .8rem;
    background: transparent;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}
.topnav a:hover, .logout-form button:hover { background: var(--surface-muted); color: var(--text); text-decoration: none; }
.page-shell { width: min(1180px, calc(100% - 2rem)); margin: 1.4rem auto 3rem; }
.hero-panel, .page-header, .auth-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1.2rem, 3vw, 2rem);
    margin-bottom: 1rem;
}
.hero-panel h1, .page-header h1, .auth-card h1 { margin: .1rem 0; font-size: clamp(1.6rem, 4vw, 2.5rem); letter-spacing: -.04em; }
.hero-panel p { max-width: 680px; color: var(--muted); }
.eyebrow { margin: 0; color: var(--primary); text-transform: uppercase; font-size: .76rem; letter-spacing: .12em; font-weight: 800; }
.muted { color: var(--muted); }
.button-row, .hero-actions, .form-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.button, button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .68rem .9rem;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}
.button:hover { text-decoration: none; background: var(--surface-muted); }
.button.primary { background: var(--primary); border-color: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.metric-card, .panel, .table-card, .form-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.metric-card { padding: 1.1rem; }
.metric-card span { display: block; color: var(--muted); font-size: .88rem; }
.metric-card strong { display: block; margin-top: .25rem; font-size: 1.75rem; letter-spacing: -.04em; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.panel { padding: 1rem; }
.panel-header { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: .8rem; }
.panel-header h2 { margin: 0; font-size: 1.08rem; }
.list-stack { display: grid; gap: .6rem; }
.row-card { display: block; padding: .8rem; border: 1px solid var(--line); border-radius: 14px; background: #fbfdfe; }
.row-card strong, .row-card span { display: block; }
.row-card span { color: var(--muted); font-size: .92rem; margin-top: .15rem; }
.table-card { overflow: hidden; }
.table-card.flat { box-shadow: none; border-radius: 14px; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { text-align: left; padding: .8rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.form-card { padding: 1rem; max-width: 880px; }
.form-card p { display: grid; gap: .35rem; margin: 0 0 .9rem; }
.form-card label { font-weight: 700; color: #344955; }
.form-card input, .form-card select, .form-card textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .72rem .8rem;
    font: inherit;
    background: #fbfdfe;
}
.form-card input:focus, .form-card select:focus, .form-card textarea:focus { outline: 3px solid var(--accent); border-color: #93c5fd; }
.helptext { color: var(--muted); font-size: .84rem; }
.errorlist { color: var(--danger); margin: .2rem 0; }
.auth-card { max-width: 860px; margin: 4rem auto; align-items: stretch; }
.auth-card > * { flex: 1; }
.compact-form { box-shadow: none; }
.status-list { display: grid; gap: .7rem; }
.status-list div { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem; background: #fbfdfe; border-radius: 12px; border: 1px solid var(--line); }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; font-weight: 800; }
.messages { display: grid; gap: .5rem; margin-bottom: 1rem; }
.message { border: 1px solid var(--line); border-radius: 12px; padding: .75rem; background: #ecfeff; }
@media (max-width: 860px) {
    .topbar, .hero-panel, .page-header, .auth-card { align-items: flex-start; flex-direction: column; }
    .topnav { width: 100%; }
    .metric-grid, .two-column { grid-template-columns: 1fr; }
    table { min-width: 760px; }
    .table-card { overflow-x: auto; }
}
