:root {
    --bg: #fff7ed;
    --surface: #ffffff;
    --surface-2: #fffaf3;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #eadfd3;
    --primary: #b45309;
    --primary-2: #92400e;
    --primary-soft: #ffedd5;
    --danger: #b91c1c;
    --success: #047857;
    --warning: #b45309;
    --shadow: 0 18px 50px rgba(120, 53, 15, .10);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }

a { color: inherit; }

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

.sidebar { background: #2b1a12; color: #fff; padding: 22px; position: sticky; top: 0; height: 100vh; }

.brand { display: flex; align-items: center; gap: 12px; padding-bottom: 28px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 20px; }
.brand strong { display: block; font-size: 1.2rem; }
.brand span { display: block; color: rgba(255,255,255,.72); font-size: .85rem; margin-top: 2px; }
.brand-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: #f59e0b; color: #2b1a12; font-weight: 900; }

.nav-menu { display: grid; gap: 8px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: rgba(255,255,255,.82); text-decoration: none; border-radius: 14px; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.12); color: #fff; }

.content { padding: 34px; max-width: 1280px; width: 100%; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.eyebrow { color: var(--primary); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .76rem; }
h1 { margin: 4px 0 8px; font-size: clamp(1.9rem, 3vw, 3rem); line-height: 1.05; }
p { color: var(--muted); line-height: 1.55; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); }
.card.compact { padding: 16px; }
.card-title { font-size: 1.05rem; font-weight: 800; margin: 0 0 12px; }
.metric { font-size: 2rem; font-weight: 900; margin: 8px 0 2px; }
.metric-label { color: var(--muted); font-size: .9rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 18px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-weight: 700; margin-bottom: 7px; font-size: .9rem; }
input, select, textarea { width: 100%; border: 1px solid var(--border); background: white; color: var(--text); border-radius: 14px; padding: 11px 12px; font: inherit; outline: none; }
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.btn { border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 14px; text-decoration: none; font-weight: 800; cursor: pointer; font: inherit; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-2); }
.btn-secondary { background: var(--primary-soft); color: var(--primary-2); }
.btn-light { background: #f3f4f6; color: #111827; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-sm { padding: 7px 10px; border-radius: 10px; font-size: .88rem; }

.badge { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; background: #f3f4f6; color: #374151; font-weight: 800; font-size: .78rem; }
.badge-success { background: #d1fae5; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-danger { background: #fee2e2; color: var(--danger); }

.alert { border-radius: 18px; padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--surface); }
.alert-success { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.alert-error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.alert-info { border-color: #fed7aa; background: #fff7ed; color: #7c2d12; }

.stack { display: grid; gap: 14px; }
.help { color: var(--muted); font-size: .9rem; margin-top: 6px; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.empty-state { padding: 52px; text-align: center; background: var(--surface); border-radius: 24px; border: 1px solid var(--border); box-shadow: var(--shadow); }

.code-box { border: 1px dashed #d6b797; background: #fffaf3; border-radius: 18px; padding: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #78350f; overflow-x: auto; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
    .content { padding: 20px; }
    .page-header { display: block; }
}


.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-bottom: 16px; }
.topbar form { margin: 0; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #fff7ed, #fff1f2); }
.auth-card { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 28px; box-shadow: var(--shadow); padding: 28px; }
.auth-brand { margin-bottom: 18px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-links { margin-top: 16px; text-align: center; }
.auth-links a { color: var(--primary-2); font-weight: 800; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

.toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e8e2d8;
    box-shadow: 0 14px 35px rgba(43, 32, 20, .18);
    color: #2b2014;
    animation: toast-in .22s ease-out;
}

.toast-success {
    border-left: 5px solid #22a06b;
}

.toast-error {
    border-left: 5px solid #d64545;
}

.toast-info {
    border-left: 5px solid #d8932a;
}

.toast-close {
    border: 0;
    background: transparent;
    color: #7c6a58;
    cursor: pointer;
    font-size: 20px;
    line-height: 18px;
    padding: 0;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px) translateX(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateX(0);
    }
}
