:root {
    --bg: #f4f1ea;
    --surface: rgba(255, 255, 255, 0.76);
    --line: rgba(145, 123, 91, 0.18);
    --text: #2d261f;
    --muted: #786a5d;
    --accent: #b18857;
    --accent-deep: #8d6941;
    --danger: #b34d45;
    --shadow: 0 18px 60px rgba(122, 92, 54, 0.12);
    --radius: 24px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(194, 161, 120, 0.28), transparent 28%),
        radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.9), transparent 24%),
        linear-gradient(135deg, #f6f1e8 0%, #efe7dc 45%, #f9f5ee 100%);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.shell {
    display: grid;
    grid-template-columns: 290px 1fr;
    min-height: 100vh;
    transition: grid-template-columns .25s ease;
}
.shell.collapsed { grid-template-columns: 83px 1fr; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 18px;
    background: rgba(255, 253, 249, 0.72);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--line);
    transition: width .25s ease, padding .25s ease;
}

.sidebar.collapsed { width: 83px; padding-inline: 10px; }
.sidebar.collapsed .label,
.sidebar.collapsed .brand-copy,
.sidebar.collapsed .user-card { display: none; }

.brand { display: flex; align-items: center; gap: 14px; }
.brand strong { font-size: 22px; }
.brand small, .topbar p, .user-card small, .flash, label span, .text-list, .prose p { color: var(--muted); }

.ghost-btn {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: grid;
    place-content: center;
    gap: 4px;
}

.ghost-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
}

.nav { display: grid; gap: 10px; margin-top: 28px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    color: var(--muted);
    transition: .2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--text);
    background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(243,233,220,.92));
    box-shadow: var(--shadow);
}

.icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #e9dcc9, #fff);
    color: var(--accent-deep);
    font-weight: 800;
    flex: 0 0 36px;
}
.icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer { display: grid; gap: 14px; }

.user-card, .card, .login-card, .login-hero {
    background: var(--surface);
    border: 1px solid var(--line);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

.user-card { padding: 16px; }
.logout-link { color: var(--accent-deep); font-weight: 700; padding-left: 6px; }

.main { padding: 28px; overflow: hidden; }
.topbar {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.topbar h1 { margin: 0 0 6px; font-size: 34px; }
.refresh-badge {
    min-width: 210px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255,255,255,.76);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    text-align: right;
}
.refresh-badge strong {
    display: block;
    font-size: 14px;
}
.refresh-badge small {
    color: var(--muted);
}
.card { padding: 22px; margin-bottom: 18px; }
.accent-card { background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(244,233,213,.88)); }
.grid.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.inline-form, .toolbar, .filter-card form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

label { display: grid; gap: 8px; font-size: 14px; }

input, select, textarea, button { font: inherit; }

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 13px 14px;
    background: rgba(255,255,255,.92);
    color: var(--text);
}

textarea { min-height: 52px; resize: vertical; }

.primary-btn, .secondary-btn, .danger-btn {
    border: 0;
    border-radius: 16px;
    padding: 13px 18px;
    font-weight: 700;
    cursor: pointer;
}

.primary-btn { background: linear-gradient(135deg, #c79d66, #a87a44); color: #fff; }
.secondary-btn { background: #f2eadf; color: var(--accent-deep); }
.danger-btn { background: #f8e2de; color: var(--danger); }

.flash-stack { display: grid; gap: 10px; margin-bottom: 16px; }
.flash { padding: 14px 16px; border-radius: 16px; background: rgba(255,255,255,.82); border: 1px solid var(--line); }
.flash.success { border-color: rgba(70, 144, 93, 0.25); }
.flash.error { border-color: rgba(179, 77, 69, 0.25); }

.table-shell { overflow: auto; border-radius: 22px; border: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; min-width: 1200px; background: rgba(255,255,255,.78); }
.data-table.compact { min-width: 1700px; }

.data-table th, .data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(145,123,91,.1);
    vertical-align: top;
    text-align: left;
}

.data-table th {
    position: sticky;
    top: 0;
    background: rgba(252, 249, 245, 0.96);
    z-index: 2;
    font-size: 13px;
    color: var(--muted);
}

.tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.stats-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat-card {
    display: grid;
    gap: 8px;
    padding: 18px 20px;
    border-radius: 20px;
    background: rgba(255,255,255,.78);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.stat-card strong {
    font-size: 14px;
    color: var(--muted);
}
.stat-card span {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}
.stat-card.active {
    background: linear-gradient(135deg, rgba(199,157,102,.16), rgba(255,255,255,.94));
    border-color: rgba(177, 136, 87, 0.34);
}
.tab {
    padding: 11px 16px;
    border-radius: 999px;
    background: #f5ede2;
    color: var(--muted);
    font-weight: 700;
}

.tab.active { background: linear-gradient(135deg, #c79d66, #a87a44); color: #fff; }

.text-list { margin: 0; padding-left: 18px; line-height: 1.8; }
.prose h3 { margin-top: 0; }
.inner-table { width: 100%; border-collapse: collapse; }
.inner-table th, .inner-table td { padding: 10px 0; border-bottom: 1px solid var(--line); text-align: left; }

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 24px;
    padding: 32px;
}

.login-hero, .login-card { padding: 42px; align-self: center; }

.login-hero {
    min-height: 420px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background:
        linear-gradient(160deg, rgba(255,255,255,.55), rgba(255,255,255,.14)),
        url("/static/main_jpg.jpg") center/cover;
}

.hero-chip {
    display: inline-flex;
    width: fit-content;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,.66);
    color: var(--accent-deep);
    font-weight: 700;
    margin-bottom: 18px;
}

.login-hero h1 { font-size: 48px; margin: 0 0 14px; max-width: 520px; }
.login-card { max-width: 520px; width: 100%; justify-self: end; display: grid; gap: 14px; }

.autosave-field[data-saving="true"] { outline: 2px solid rgba(177, 136, 87, 0.32); }
.autosave-field[data-saved="true"] { outline: 2px solid rgba(70, 144, 93, 0.22); }

@media (max-width: 1080px) {
    .shell { grid-template-columns: 83px 1fr; }
    .sidebar .label, .sidebar .brand-copy, .sidebar .user-card { display: none; }
    .grid.two-col, .login-page { grid-template-columns: 1fr; }
    .login-card { justify-self: stretch; max-width: none; }
    .topbar { flex-direction: column; }
    .refresh-badge { text-align: left; min-width: 0; }
    .stats-strip { grid-template-columns: 1fr; }
}
