@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap');

:root {
    --bg: #f4efe8;
    --panel: rgba(255, 252, 246, 0.86);
    --panel-strong: #fffaf2;
    --surface: #0f2b3d;
    --surface-2: #16394f;
    --text: #182635;
    --muted: #6a7784;
    --line: rgba(17, 39, 56, 0.1);
    --accent: #de8f3f;
    --accent-soft: rgba(222, 143, 63, 0.14);
    --success: #198f62;
    --success-soft: rgba(25, 143, 98, 0.14);
    --danger: #c45050;
    --danger-soft: rgba(196, 80, 80, 0.14);
    --shadow: 0 24px 60px rgba(16, 38, 55, 0.14);
    --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(222, 143, 63, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(15, 43, 61, 0.14), transparent 24%),
        var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; grid-template-columns: 320px 1fr; min-height: 100vh; }
.sidebar {
    padding: 28px;
    background: linear-gradient(180deg, var(--surface), #10212f);
    color: #f7f2ea;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand-card, .auth-brand { display: flex; gap: 16px; align-items: center; }
.brand-chip {
    display: inline-flex;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #f0bf68);
    color: #1a2b38;
    font-weight: 800;
    letter-spacing: 0.08em;
}
.eyebrow {
    margin: 0 0 8px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 12px;
    font-weight: 800;
}
.sidebar .eyebrow, .auth-copy .eyebrow, .auth-brand .eyebrow { color: rgba(247, 242, 234, 0.7); }
.brand-card h1, .auth-copy h1, .page-topbar h2, .panel h3, .hero-panel h3 {
    margin: 0;
    font-family: "Fraunces", serif;
    font-weight: 700;
    letter-spacing: -0.03em;
}
.nav-list { display: grid; gap: 8px; }
.nav-item {
    padding: 16px 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: .2s ease;
    display: grid;
    gap: 4px;
}
.nav-item small { color: rgba(247, 242, 234, 0.66); }
.nav-item:hover, .nav-item.active {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
}
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
}
.badge-admin { background: rgba(222, 143, 63, 0.16); color: #ffd6a5; }
.badge-user { background: rgba(255, 255, 255, 0.1); color: #f7f2ea; }
.badge-plain { background: var(--accent-soft); color: #8a4d15; }

.main-shell { padding: 28px; display: grid; gap: 24px; }
.page-topbar, .panel-header, .section-head, .cta-row, .inline-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero-panel, .panel, .stat-card {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.hero-panel, .panel { border-radius: var(--radius); padding: 28px; }
.hero-panel { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card {
    border-radius: 22px;
    padding: 22px;
    display: grid;
    gap: 8px;
}
.stat-card span, .muted, .field small { color: var(--muted); }
.stat-card strong { font-size: 32px; font-weight: 800; }
.panel { display: grid; gap: 20px; }
.muted-panel { background: rgba(255, 250, 242, 0.7); }
.form-grid, .document-layout, .editor-layout, .two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.stack-form { display: grid; gap: 16px; }
.filters-grid {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr)) auto;
    gap: 12px;
}
.field { display: grid; gap: 8px; }
label { font-size: 14px; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.8);
    padding: 14px 16px;
    color: var(--text);
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: rgba(222, 143, 63, 0.6);
    box-shadow: 0 0 0 4px rgba(222, 143, 63, 0.14);
    transform: translateY(-1px);
}
textarea { resize: vertical; min-height: 120px; }

.primary-button, .ghost-button {
    border: 0;
    border-radius: 16px;
    padding: 14px 18px;
    font-weight: 800;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.primary-button { background: linear-gradient(135deg, var(--accent), #f0bf68); color: #132433; box-shadow: 0 18px 34px rgba(222, 143, 63, 0.24); }
.ghost-button { background: rgba(18, 38, 54, 0.06); color: var(--text); }
.primary-button:hover, .ghost-button:hover { transform: translateY(-2px); }
.full { width: 100%; }
.text-link, .button-reset {
    color: #915417;
    background: transparent;
    border: 0;
    padding: 0;
    font-weight: 700;
}
.button-reset { font: inherit; }

.alert {
    border-radius: 20px;
    padding: 16px 18px;
    font-weight: 700;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.error-text { color: var(--danger); font-size: 13px; }
.table-wrap { overflow: auto; border-radius: 18px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: rgba(255,255,255,0.76); }
th, td { padding: 16px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
td code { white-space: pre-wrap; word-break: break-word; }

.auth-shell { min-height: 100vh; position: relative; overflow: hidden; }
.auth-backdrop {
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, #102938, #21465c);
}
.auth-layout {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    padding: 40px;
    gap: 24px;
    align-items: center;
}
.auth-copy { color: #fff6ea; padding: 40px; }
.auth-copy h1 { font-size: clamp(42px, 6vw, 72px); line-height: 0.94; }
.lead { color: var(--muted); font-size: 15px; line-height: 1.7; }
.auth-copy .lead { color: rgba(255, 246, 234, 0.78); max-width: 540px; }
.auth-panel {
    max-width: 520px;
    justify-self: end;
    background: rgba(255, 250, 242, 0.88);
    border: 1px solid rgba(255,255,255,0.24);
    box-shadow: var(--shadow);
    border-radius: 32px;
    padding: 28px;
    display: grid;
    gap: 20px;
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-item {
    border-radius: 999px;
    padding: 10px 14px;
    background: rgba(15, 43, 61, 0.06);
    border: 1px solid rgba(15, 43, 61, 0.08);
    color: var(--surface);
    font-weight: 700;
}
.summary-list { display: grid; gap: 12px; padding: 0; margin: 0; list-style: none; }
.sticky-summary { align-self: start; position: sticky; top: 28px; }
.document-preview {
    margin: 0;
    white-space: pre-wrap;
    font-family: "Manrope", sans-serif;
    line-height: 1.75;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px;
}
.narrow-form { max-width: 720px; }

@media (max-width: 1200px) {
    .app-shell, .auth-layout, .document-layout, .form-grid, .editor-layout, .two-column { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters-grid { grid-template-columns: 1fr 1fr; }
    .sticky-summary { position: static; }
}

@media (max-width: 720px) {
    .main-shell, .sidebar, .auth-layout { padding: 20px; }
    .hero-panel, .page-topbar, .panel-header, .section-head, .cta-row, .inline-actions { flex-direction: column; align-items: stretch; }
    .stats-grid, .filters-grid { grid-template-columns: 1fr; }
    .auth-copy { padding: 0; }
}
