:root {
    --ink: #12263a;
    --ink-soft: #1c3a52;
    --ink-muted: #5c7184;
    --paper: #f6f1e8;
    --paper-strong: #fffdf8;
    --sand: #e7dcc8;
    --line: #d8ccb6;
    --clay: #b55239;
    --clay-dark: #933f2b;
    --moss: #2f6b5a;
    --gold: #c4922a;
    --sidebar: #0f2030;
    --sidebar-2: #173047;
    --danger: #9b2c2c;
    --shadow: 0 18px 50px rgba(18, 38, 58, 0.12);
    --radius: 18px;
    --font: "Figtree", sans-serif;
    --display: "Fraunces", serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input { font: inherit; }

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
}

.wrap {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
    background: rgba(246, 241, 232, 0.86);
    border-bottom: 1px solid rgba(18, 38, 58, 0.08);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--ink);
    color: var(--sand);
    display: grid;
    place-items: center;
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.15rem;
}

.brand small {
    display: block;
    font-weight: 500;
    color: var(--ink-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.68rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 22px;
    color: var(--ink-soft);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    padding: 12px 20px;
    cursor: pointer;
    transition: 0.18s ease;
    font-weight: 600;
}

.btn-clay {
    background: var(--clay);
    color: #fff8f4;
}

.btn-clay:hover { background: var(--clay-dark); }

.btn-ink {
    background: var(--ink);
    color: var(--paper);
}

.btn-ink:hover { background: var(--ink-soft); }

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

.btn-full { width: 100%; }

.hero {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 48px;
    align-items: center;
    padding: 72px 0 48px;
}

.kicker {
    color: var(--moss);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

h1, h2, h3, .display {
    font-family: var(--display);
    letter-spacing: -0.04em;
    line-height: 1.08;
    margin: 0 0 14px;
}

h1 { font-size: clamp(2.5rem, 5vw, 4.4rem); font-weight: 560; }
h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
p.lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 38rem; }

.hero-panel {
    background: var(--ink);
    color: var(--paper);
    border-radius: 28px;
    padding: 28px;
    min-height: 360px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.hero-panel::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -50px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(181,82,57,0.55), transparent 70%);
}

.flow-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(231, 220, 200, 0.16);
    position: relative;
    z-index: 1;
}

.flow-item:last-child { border-bottom: 0; }

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    background: rgba(231, 220, 200, 0.14);
    color: var(--sand);
    font-size: 0.78rem;
}

.section { padding: 36px 0 72px; }

.grid-3, .grid-4 {
    display: grid;
    gap: 18px;
}

.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
    background: var(--paper-strong);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
}

.card h3 { font-size: 1.35rem; }

.muted { color: var(--ink-muted); }

.site-footer {
    border-top: 1px solid var(--line);
    padding: 28px 0 40px;
    color: var(--ink-muted);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.auth-brand {
    background:
        linear-gradient(160deg, rgba(18,38,58,0.88), rgba(18,38,58,0.72)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 40 40'%3E%3Cg fill='none' stroke='%23e7dcc8' stroke-opacity='0.12'%3E%3Cpath d='M0 20h40M20 0v40'/%3E%3C/g%3E%3C/svg%3E");
    color: var(--paper);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-panel {
    display: grid;
    place-items: center;
    padding: 40px 24px;
    background: var(--paper);
}

.auth-card {
    width: min(440px, 100%);
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.92rem;
}

.field input,
.field select {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--paper-strong);
    border-radius: 14px;
    padding: 13px 14px;
    outline: none;
}

.field input:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 4px rgba(18, 38, 58, 0.08);
}

.alert {
    background: #fde8e8;
    color: var(--danger);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.hint {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #efe7d6;
    color: var(--ink-soft);
    font-size: 0.92rem;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
    background: #eef2f4;
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
    color: #e8dfd0;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 28px;
}

.sidebar-nav a,
.sidebar-nav button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #d7cbb6;
    padding: 11px 12px;
    border-radius: 12px;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.sidebar-nav a:hover,
.sidebar-nav button:hover,
.sidebar-nav a.active {
    background: rgba(231, 220, 200, 0.12);
    color: #fff;
}

.badge-soon {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(196, 146, 42, 0.2);
    color: #efd08a;
    border-radius: 999px;
    padding: 3px 8px;
}

.app-main { min-width: 0; }

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 28px;
    background: rgba(255,253,248,0.9);
    border-bottom: 1px solid #e2e8ee;
    position: sticky;
    top: 0;
    z-index: 10;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 8px 10px;
}

.app-content { padding: 28px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    background: #fffdf8;
    border-radius: 18px;
    padding: 18px;
    border: 1px solid #e6edf2;
}

.stat strong {
    display: block;
    font-family: var(--display);
    font-size: 2rem;
    letter-spacing: -0.04em;
}

.welcome {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 16px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--sand);
    display: grid;
    place-items: center;
    font-weight: 700;
}

.sidebar-scrim {
    display: none;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.table-wrap {
    overflow: auto;
    background: #fffdf8;
    border: 1px solid #e6edf2;
    border-radius: 18px;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

table.data th,
table.data td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid #edf1f4;
    vertical-align: top;
}

table.data th {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

table.data tr:last-child td { border-bottom: 0; }

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.row-actions a,
.row-actions button {
    background: #eef3f6;
    border: 0;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
}

.row-actions a.danger,
.row-actions button.danger {
    background: #fde8e8;
    color: var(--danger);
}

.page-head .btn { min-width: 140px; }

.matrix-wrap { overflow: auto; }

.matrix {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.matrix th,
.matrix td {
    padding: 10px 12px;
    border-bottom: 1px solid #edf1f4;
    text-align: center;
}

.matrix th:first-child,
.matrix td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: #fffdf8;
}

.status {
    display: inline-flex;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-on { background: #e5f4ee; color: var(--moss); }
.status-off { background: #fde8e8; color: var(--danger); }

.flash-ok {
    background: #e5f4ee;
    color: var(--moss);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-grid .span-2 { grid-column: 1 / -1; }

textarea {
    width: 100%;
    min-height: 110px;
    border: 1px solid var(--line);
    background: var(--paper-strong);
    border-radius: 14px;
    padding: 13px 14px;
    outline: none;
    resize: vertical;
}

textarea:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 4px rgba(18, 38, 58, 0.08);
}

.check-groups {
    display: grid;
    gap: 14px;
}

.check-groups fieldset {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
}

.check-groups legend {
    padding: 0 6px;
    font-weight: 700;
}

.check-groups label {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 8px 0;
    font-weight: 500;
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.search-bar input {
    flex: 1;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 14px;
    padding: 12px 14px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    background: #eef3f6;
    color: var(--ink-soft);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 0.8rem;
}

.text-danger { color: var(--danger); font-size: 0.88rem; }

@media (max-width: 980px) {
    .hero, .auth-shell, .welcome, .grid-3, .grid-4, .stat-grid, .form-grid {
        grid-template-columns: 1fr;
    }

    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        z-index: 30;
        width: min(300px, 86vw);
    }

    .sidebar.open { transform: none; }

    .sidebar-scrim.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10, 18, 28, 0.45);
        z-index: 25;
    }

    .menu-toggle { display: inline-flex; }
}
