:root {
    --forest: #173f2a;
    --forest-2: #215638;
    --leaf: #4f8a52;
    --mint: #e9f3e8;
    --lime: #d8e8b0;
    --gold: #e2aa45;
    --cream: #f7f5ee;
    --paper: #fffefa;
    --ink: #17211b;
    --muted: #69746d;
    --line: #dfe5de;
    --danger: #bd4c41;
    --shadow: 0 12px 36px rgba(25, 56, 37, .08);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--cream);
    font-family: "DM Sans", system-ui, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 244px;
    z-index: 20;
    padding: 25px 18px 20px;
    display: flex;
    flex-direction: column;
    color: #fff;
    background:
        radial-gradient(circle at 10% 85%, rgba(142, 181, 91, .18), transparent 32%),
        linear-gradient(180deg, #173f2a, #102e20);
}
.brand { display: block; padding: 0 10px 28px; }
.brand img { width: 100%; max-width: 190px; height: auto; display: block; }
.side-nav { display: grid; gap: 6px; }
.side-nav a, .sidebar-foot a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 10px 13px;
    border-radius: 12px;
    color: rgba(255,255,255,.72);
    font-weight: 600;
    transition: .18s ease;
}
.side-nav a:hover, .sidebar-foot a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav a.active { color: #173f2a; background: var(--lime); box-shadow: 0 8px 20px rgba(0,0,0,.16); }
.side-nav a i, .sidebar-foot a i { width: 20px; font-size: 1.1rem; }
.sidebar-foot { margin-top: auto; }
.open-status { padding: 16px 13px 0; color: rgba(255,255,255,.55); font-size: .75rem; }
.open-status span {
    display: inline-block; width: 7px; height: 7px; margin-right: 7px;
    border-radius: 50%; background: #8dd475; box-shadow: 0 0 0 4px rgba(141,212,117,.12);
}
.app-shell { margin-left: 244px; min-height: 100vh; }
.topbar {
    min-height: 104px;
    padding: 24px 34px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(27,63,42,.08);
    background: rgba(247,245,238,.92);
    backdrop-filter: blur(12px);
}
.eyebrow {
    margin: 0 0 4px; color: var(--leaf); font-size: .72rem;
    font-weight: 700; text-transform: uppercase; letter-spacing: .13em;
}
.topbar h1 {
    margin: 0; font-family: "Fraunces", Georgia, serif; font-size: 1.85rem;
    letter-spacing: -.025em; color: var(--forest);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.logout-form { margin: 0; }
.date-chip, .user-chip, .icon-button {
    min-height: 42px; border: 1px solid var(--line); background: var(--paper);
    border-radius: 12px; display: inline-flex; align-items: center; gap: 9px;
    padding: 0 14px; color: var(--muted); font-weight: 600; font-size: .84rem;
}
.icon-button { width: 42px; justify-content: center; padding: 0; }
.app-content { padding: 28px 34px 48px; max-width: 1680px; margin: 0 auto; }
.message-stack { padding: 14px 34px 0; display: grid; gap: 8px; }
.app-message {
    display: flex; align-items: center; gap: 10px; padding: 12px 15px;
    border-radius: 12px; background: #e8f4e4; color: #27572d; font-weight: 600;
}
.app-message.error { color: #762e28; background: #f6e3df; }
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 1.65fr) minmax(320px, .85fr); }
.card {
    border: 1px solid rgba(26,64,40,.09); border-radius: 18px;
    background: var(--paper); box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.kpi { position: relative; overflow: hidden; min-height: 146px; padding: 21px; }
.kpi::after {
    content: ""; position: absolute; width: 90px; height: 90px; right: -28px; top: -30px;
    border-radius: 50%; background: var(--kpi-tint, var(--mint));
}
.kpi-label { color: var(--muted); font-weight: 600; font-size: .8rem; }
.kpi-value { margin: 14px 0 5px; font: 700 1.85rem/1.1 "Fraunces", Georgia, serif; color: var(--forest); }
.kpi-note { color: var(--muted); font-size: .76rem; }
.kpi-icon {
    position: absolute; top: 18px; right: 18px; z-index: 1; width: 38px; height: 38px;
    border-radius: 11px; display: grid; place-items: center; color: var(--forest); background: var(--kpi-tint, var(--mint));
}
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 17px; }
.section-head h2 { margin: 0; font: 700 1.15rem "Fraunces", Georgia, serif; color: var(--forest); }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.button {
    min-height: 42px; padding: 0 17px; border: 0; border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-weight: 700; font-size: .84rem; transition: .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--forest); box-shadow: 0 7px 18px rgba(23,63,42,.2); }
.button-accent { color: var(--forest); background: var(--lime); }
.button-soft { color: var(--forest); background: var(--mint); }
.button-outline { color: var(--forest); background: transparent; border: 1px solid var(--line); }
.button-danger { color: #fff; background: var(--danger); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 11px 12px; text-align: left; color: var(--muted); font-size: .69rem;
    letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line);
}
.data-table td { padding: 13px 12px; border-bottom: 1px solid #edf0ec; font-size: .86rem; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.text-right { text-align: right !important; }
.muted { color: var(--muted); }
.money { font-weight: 700; color: var(--forest); }
.badge {
    display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px;
    border-radius: 999px; background: var(--mint); color: var(--forest); font-size: .72rem; font-weight: 700;
}
.badge-danger { color: #842f28; background: #f5dfdc; }
.badge-gold { color: #66450a; background: #f7e9c8; }
.form-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.form-control {
    width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line);
    border-radius: 11px; color: var(--ink); background: #fff; outline: none;
}
.form-control:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(79,138,82,.12); }
textarea.form-control { min-height: 72px; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
.empty-state { padding: 32px; text-align: center; color: var(--muted); }
.empty-state i { display: block; margin-bottom: 8px; font-size: 1.6rem; color: var(--leaf); }
.mobile-nav { display: none; }

/* Authentication */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(380px, .9fr) minmax(500px, 1.1fr);
    background: var(--cream);
}
.login-panel {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: var(--paper);
}
.login-card { width: min(100%, 430px); }
.login-brand {
    display: inline-block;
    width: 185px;
    margin-bottom: 54px;
    padding: 16px 18px;
    border-radius: 18px;
    background: var(--forest);
    box-shadow: 0 12px 28px rgba(23, 63, 42, .18);
}
.login-brand img { display: block; width: 100%; height: auto; }
.login-eyebrow {
    margin: 0 0 10px;
    color: var(--leaf);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.login-card h1 {
    margin: 0;
    color: var(--forest);
    font: 700 clamp(2rem, 4vw, 2.7rem)/1.05 "Fraunces", Georgia, serif;
    letter-spacing: -.035em;
}
.login-intro {
    max-width: 380px;
    margin: 14px 0 30px;
    color: var(--muted);
    line-height: 1.65;
}
.login-form { display: grid; gap: 18px; }
.login-field label {
    display: block;
    margin-bottom: 8px;
    color: var(--ink);
    font-size: .78rem;
    font-weight: 700;
}
.login-input-wrap { position: relative; }
.login-input-wrap > i {
    position: absolute;
    top: 50%;
    left: 15px;
    color: var(--leaf);
    transform: translateY(-50%);
}
.login-input {
    width: 100%;
    min-height: 52px;
    padding: 12px 45px;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: var(--ink);
    background: #fff;
    outline: none;
    transition: .15s ease;
}
.login-input:focus {
    border-color: var(--leaf);
    box-shadow: 0 0 0 4px rgba(79, 138, 82, .12);
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: 9px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 9px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: transparent;
    transform: translateY(-50%);
}
.password-toggle:hover { color: var(--forest); background: var(--mint); }
.login-submit { width: 100%; min-height: 52px; margin-top: 4px; font-size: .9rem; }
.login-error {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #762e28;
    background: #f6e3df;
    font-size: .82rem;
    line-height: 1.45;
}
.login-help {
    margin: 24px 0 0;
    color: var(--muted);
    font-size: .76rem;
    text-align: center;
}
.login-visual {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    min-height: 100vh;
    padding: 70px;
    color: #fff;
    background:
        radial-gradient(circle at 75% 17%, rgba(216, 232, 176, .2), transparent 24%),
        radial-gradient(circle at 12% 85%, rgba(226, 170, 69, .18), transparent 30%),
        linear-gradient(145deg, #102e20 0%, #173f2a 52%, #245f3d 100%);
}
.login-visual::before,
.login-visual::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 50%;
}
.login-visual::before { width: 520px; height: 520px; top: -180px; right: -130px; }
.login-visual::after { width: 330px; height: 330px; top: -80px; right: -35px; }
.login-visual-content { position: relative; z-index: 1; max-width: 560px; }
.login-visual-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 24px;
    border-radius: 17px;
    display: grid;
    place-items: center;
    color: var(--forest);
    background: var(--lime);
    font-size: 1.4rem;
}
.login-visual h2 {
    margin: 0;
    font: 700 clamp(2.25rem, 4vw, 4rem)/1.03 "Fraunces", Georgia, serif;
    letter-spacing: -.04em;
}
.login-visual p {
    max-width: 490px;
    margin: 20px 0 0;
    color: rgba(255, 255, 255, .72);
    font-size: 1rem;
    line-height: 1.7;
}
.login-security {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 30px;
    padding: 10px 13px;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 999px;
    color: rgba(255, 255, 255, .78);
    background: rgba(255, 255, 255, .06);
    font-size: .76rem;
}
@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .login-page { grid-template-columns: 1fr; }
    .login-panel { min-height: 100vh; padding: 34px 22px; }
    .login-visual { display: none; }
    .login-brand { margin-bottom: 38px; }
}
@media (max-width: 760px) {
    .app-sidebar { display: none; }
    .app-shell { margin-left: 0; padding-bottom: 76px; }
    .topbar { min-height: 82px; padding: 17px 18px; }
    .topbar h1 { font-size: 1.45rem; }
    .date-chip, .user-chip { display: none; }
    .app-content { padding: 19px 15px 30px; }
    .message-stack { padding: 10px 15px 0; }
    .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi { min-height: 132px; padding: 16px; }
    .kpi-value { font-size: 1.45rem; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid > * { grid-column: span 1 !important; }
    .mobile-nav {
        display: grid; grid-template-columns: repeat(5, 1fr); position: fixed;
        z-index: 50; left: 0; right: 0; bottom: 0; height: 68px; padding: 6px 7px;
        background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0,0,0,.08);
    }
    .mobile-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .65rem; }
    .mobile-nav i { font-size: 1.1rem; }
    .mobile-nav .mobile-sale {
        width: 54px; height: 54px; margin: -16px auto 0; border-radius: 17px;
        color: #fff; background: var(--forest); box-shadow: 0 8px 20px rgba(23,63,42,.25);
    }
    .data-table { min-width: 680px; }
    .table-wrap { overflow-x: auto; }
}
@media print {
    .app-sidebar, .topbar, .mobile-nav, .no-print { display: none !important; }
    .app-shell { margin: 0; }
    .app-content { padding: 0; }
    body { background: #fff; }
}
