:root {
    --cafe-950: #140c08;
    --cafe-900: #1c120c;
    --cafe-800: #2b1a12;
    --cafe-700: #4a2c1a;
    --cafe-600: #6b3e26;
    --leaf-900: #0f2419;
    --leaf-800: #1b4332;
    --leaf-700: #2d6a4f;
    --leaf-600: #40916c;
    --leaf-500: #52b788;
    --gold: #c9a227;
    --gold-soft: #e6c86a;
    --cream: #f6f1e6;
    --cream-2: #efe6d4;
    --paper: #fffdf8;
    --ink: #2b2118;
    --muted: #7a6a58;
    --line: #e4d8c4;
    --sidebar: 268px;
    --radius: 18px;
    --shadow: 0 18px 40px rgba(44, 24, 16, .08);
}

* { box-sizing: border-box; }

body.app-body {
    margin: 0;
    font-family: Outfit, sans-serif;
    background:
        radial-gradient(1200px 500px at 110% -10%, rgba(201,162,39,.12), transparent 50%),
        linear-gradient(180deg, #f3ecdd 0%, var(--cream) 40%, #f8f4ea 100%);
    color: var(--ink);
}

h1, h2, h3, .display, .kpi-value {
    font-family: Fraunces, Georgia, serif;
}

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar);
    background:
        linear-gradient(180deg, rgba(201,162,39,.08), transparent 28%),
        linear-gradient(180deg, var(--leaf-900), var(--cafe-900) 80%);
    color: #f4ead8;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 22px 16px 28px;
    flex-shrink: 0;
}

.sidebar-brand {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 0 4px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 18px;
}

.sidebar-brand img {
    width: 100%;
    height: auto;
    object-fit: contain;
    background: #fff;
    border-radius: 16px;
    padding: 10px 12px;
}

.nav-label {
    font-size: .68rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #c4b08a;
    margin: 18px 10px 8px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #eadfca;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 12px;
    font-weight: 500;
    margin-bottom: 2px;
}

.sidebar-nav .nav-link i { width: 18px; }
.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(201,162,39,.16);
    color: #fff8e7;
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
}

.sidebar-toggle {
    display: none;
    border: 0;
    background: var(--paper);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 16px;
    color: var(--muted);
}

.topbar-right { margin-left: auto; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: var(--paper);
    border-radius: 999px;
    padding: 6px 12px 6px 6px;
    box-shadow: var(--shadow);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--leaf-700);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: .8rem;
    font-weight: 700;
}

.user-meta { text-align: left; line-height: 1.15; }
.user-meta strong { display: block; font-size: .9rem; }
.user-meta small { color: var(--muted); }

.app-content { padding: 8px 28px 36px; }

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

.page-heading h1 { font-size: 2rem; margin: 0; color: var(--cafe-800); }
.page-subtitle { margin: 4px 0 0; color: var(--muted); }

.app-footer {
    padding: 0 28px 24px;
    color: var(--muted);
    font-size: .85rem;
}

.card-soft {
    background: var(--paper);
    border: 1px solid rgba(228,216,196,.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.kpi {
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.kpi::after {
    content: "";
    position: absolute;
    right: -20px;
    top: -20px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(45,106,79,.12), transparent 70%);
}

.kpi-label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; }
.kpi-value { font-size: 1.7rem; margin: 6px 0 0; }
.kpi-hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.kpi.positive .kpi-value { color: var(--leaf-700); }
.kpi.alert .kpi-value { color: #9b2226; }

.badge-status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-warning { background: #fff3cd; color: #8a6d1b; }
.badge-info { background: #d8f3dc; color: #1b4332; }
.badge-success { background: #d8f3dc; color: #1b4332; }
.badge-secondary { background: #eee; color: #555; }
.badge-dark { background: #2b2118; color: #fff; }
.badge-danger { background: #f8d7da; color: #842029; }

.table thead th {
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    background: #faf6ee;
}

.btn-cafe {
    background: var(--leaf-700);
    color: #fff;
    border: 0;
    border-radius: 12px;
    padding: 10px 16px;
    font-weight: 600;
}

.btn-cafe:hover { background: var(--leaf-800); color: #fff; }

.btn-gold {
    background: var(--gold);
    color: #1c120c;
    border: 0;
    border-radius: 12px;
    font-weight: 700;
}

.form-control, .form-select {
    border-color: var(--line);
    border-radius: 12px;
    padding: 10px 12px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--leaf-600);
    box-shadow: 0 0 0 .2rem rgba(45,106,79,.15);
}

.form-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.field-help {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #efe6d4;
    color: var(--leaf-700);
    line-height: 1;
    cursor: help;
}

.field-help:hover,
.field-help:focus {
    background: var(--leaf-700);
    color: #fff8e7;
}

.field-help i { font-size: .85rem; }

.item-block h6,
.item-block .h6,
.cost-panel h3 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.table thead th .field-help {
    vertical-align: middle;
}

.cost-panel .field-help {
    background: rgba(255, 255, 255, .16);
    color: #f8f1df;
}

.cost-panel .field-help:hover,
.cost-panel .field-help:focus {
    background: var(--gold);
    color: #1c120c;
}

.modal-cafe .modal-content {
    border: 0;
    border-radius: 22px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.modal-cafe .modal-header {
    border-bottom-color: var(--line);
    padding: 18px 22px 12px;
}

.modal-cafe .modal-title {
    font-family: Fraunces, Georgia, serif;
    color: var(--cafe-800);
}

.modal-cafe .modal-footer {
    border-top-color: var(--line);
}

.tooltip-cafe {
    --bs-tooltip-bg: #1b4332;
    --bs-tooltip-color: #f8f1df;
    --bs-tooltip-max-width: 280px;
    font-family: Outfit, sans-serif;
    font-size: .82rem;
    line-height: 1.4;
}

.alert-box {
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.alert-box.danger { background: #fdecee; color: #7a1f24; }
.alert-box.warning { background: #fff6dd; color: #6f5710; }
.alert-box.info { background: #e8f5ee; color: #1b4332; }
.alert-box.success { background: #e8f5ee; color: #1b4332; }

.cost-panel {
    background: linear-gradient(180deg, var(--leaf-800), var(--cafe-900));
    color: #f8f1df;
    border-radius: 22px;
    padding: 22px;
    position: sticky;
    top: 18px;
}

.cost-panel h3 { font-size: 1.1rem; margin-bottom: 16px; }
.cost-row { display: flex; justify-content: space-between; margin-bottom: 8px; color: #e6d7b8; }
.cost-total {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,.12);
    font-size: 1.25rem;
    font-family: Fraunces, serif;
}

.item-block {
    border: 1px dashed var(--line);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    background: #fffcf6;
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    background: var(--cream);
}

.auth-visual {
    position: relative;
    overflow: hidden;
    background: #140c08;
    color: #fff;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.auth-visual-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 40%;
    z-index: 0;
}

.auth-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        linear-gradient(180deg, rgba(15, 36, 25, .28) 0%, rgba(20, 12, 8, .55) 48%, rgba(20, 12, 8, .88) 100%),
        linear-gradient(90deg, rgba(20, 12, 8, .15), transparent 40%);
}

.auth-visual > *:not(.auth-visual-bg) {
    position: relative;
    z-index: 2;
}

.auth-visual-logo {
    width: 220px;
    max-width: 100%;
    height: auto;
    background: #fff;
    border-radius: 20px;
    padding: 10px;
    margin-bottom: auto;
}

.auth-card { display: grid; place-items: center; padding: 40px 24px; }
.auth-box { width: min(420px, 100%); background: var(--paper); border-radius: 24px; padding: 36px; box-shadow: var(--shadow); }
.auth-box img { width: 220px; max-width: 100%; height: auto; display: block; margin: 0 auto 12px; background: transparent; border-radius: 16px; padding: 0; }

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .app-sidebar { display: none; }
    .app-sidebar.open { display: block; position: fixed; z-index: 40; }
    .sidebar-toggle { display: inline-grid; place-items: center; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-visual { min-height: 260px; padding: 28px 24px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .app-content, .app-topbar, .app-footer { padding-left: 16px; padding-right: 16px; }
}
