:root {
    --navy: #17324d;
    --blue: #176b87;
    --blue-dark: #10566d;
    --cream: #f6f3ec;
    --white: #fff;
    --ink: #17212b;
    --muted: #65717c;
    --line: #dce2e6;
    --success: #176b4d;
    --success-bg: #e8f5ef;
    --error: #9d2f2f;
    --error-bg: #fbecec;
    --shadow: 0 12px 34px rgba(22, 42, 60, .09);
    --radius: 16px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--cream);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a { color: inherit; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 76px;
    padding: 14px clamp(18px, 4vw, 54px);
    background: var(--navy);
    color: var(--white);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--white);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--blue);
    font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand small { opacity: .72; font-size: .75rem; }

nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
nav a, .link-button {
    border: 0;
    border-radius: 9px;
    padding: 9px 11px;
    background: transparent;
    color: rgba(255,255,255,.86);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
nav a:hover, .link-button:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-form { display: inline; margin: 0; }

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 64px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 24px;
    margin-bottom: 26px;
}

h1 { margin: 0 0 7px; color: var(--navy); font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.12; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0 0 7px !important; color: var(--blue) !important; font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid var(--blue);
    border-radius: 10px;
    padding: 10px 18px;
    background: var(--blue);
    color: var(--white);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--blue-dark); }
.button-secondary { border-color: var(--line); background: var(--white); color: var(--ink); }
.button-secondary:hover { background: #f8fafb; }
.button-full { width: 100%; }

.table-card, .panel, .auth-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f8fafb; color: var(--muted); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 22px; }
.stat-card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; margin: 8px 0 2px; color: var(--navy); font-size: 1.5rem; }

.alert { margin: 0 0 20px; border-radius: 11px; padding: 13px 16px; }
.alert-success { border: 1px solid #b8dfce; background: var(--success-bg); color: var(--success); }
.alert-error { border: 1px solid #efc1c1; background: var(--error-bg); color: var(--error); }

.form-stack { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: var(--navy); font-size: .91rem; font-weight: 700; }
input {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cbd4da;
    border-radius: 9px;
    padding: 9px 11px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
input:focus { outline: 3px solid rgba(23, 107, 135, .16); border-color: var(--blue); }
.input-unit { display: flex; align-items: stretch; min-width: 175px; }
.input-unit input { border-radius: 9px 0 0 9px; }
.input-unit span { display: flex; align-items: center; padding: 0 11px; border: 1px solid #cbd4da; border-left: 0; border-radius: 0 9px 9px 0; background: #f5f7f8; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.input-small { width: 90px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.panel { padding: clamp(20px, 4vw, 32px); }
.narrow-panel { max-width: 580px; }
.settings-form { max-width: 720px; }

.auth-wrap { display: grid; place-items: center; min-height: calc(100vh - 220px); }
.auth-card { width: min(440px, 100%); padding: clamp(24px, 5vw, 38px); }
.auth-card h1 { margin-bottom: 8px; }
.auth-card .muted { margin: 0 0 24px; }

.footer { padding: 0 20px 28px; color: var(--muted); font-size: .82rem; text-align: center; }

@media (max-width: 800px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    nav { width: 100%; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .cards { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .container { width: min(100% - 22px, 1180px); padding-top: 28px; }
    nav a, .link-button { padding: 7px 8px; font-size: .9rem; }
    th, td { padding: 13px 14px; }
    .form-actions { align-items: stretch; flex-direction: column-reverse; }
}
