:root {
    --bg: #f4f7f6;
    --surface: #ffffff;
    --ink: #17211f;
    --muted: #66736f;
    --line: #dfe7e3;
    --brand: #0f766e;
    --brand-dark: #0b5f59;
    --brand-light: #e6f4f2;
    --gold: #c58a30;
    --red: #b42318;
    --green: #1d7a4d;
    --shadow: 0 4px 24px rgba(23, 33, 31, 0.08);
    --radius: 10px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
textarea { resize: vertical; }
.hidden { display: none !important; }

/* ── LOGIN ── */
.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #f4f7f6 0%, #edf3ee 48%, #f8f0df 100%);
}
.login-panel {
    width: min(440px, 100%);
    display: grid;
    gap: 18px;
    padding: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--gold);
    color: #13221e;
    font-weight: 900;
    font-size: 16px;
}
.brand-row strong { display: block; font-size: 16px; }
.brand-row small, .hint, p { color: var(--muted); margin: 0; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
textarea { padding: 10px 12px; min-height: 80px; }
.error-msg { color: var(--red); font-size: 13px; font-weight: 700; margin: 0; }

/* ── BUTTONS ── */
.primary-button, .text-button, .danger-button {
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    font-weight: 700;
    font-size: 14px;
    transition: background .15s, opacity .15s;
}
.primary-button { background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-dark); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }
.text-button { min-height: auto; padding: 4px 8px; color: var(--brand); background: transparent; border-radius: 6px; }
.text-button:hover { background: var(--brand-light); }
.danger-button { color: var(--red); background: #fff0ef; border: 1px solid #ffd5d0; }
.danger-button:hover { background: #ffe4df; }
.link-button { display: inline-grid; place-items: center; text-decoration: none; }

/* ── HAMBURGER ── */
.hamburger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 400;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: #10241f;
    color: #fff;
    font-size: 18px;
    align-items: center;
    justify-content: center;
}

/* ── LAYOUT ── */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 14px;
    background: #10241f;
    color: #eef6f1;
    overflow-y: auto;
    z-index: 200;
    flex-shrink: 0;
}
.sidebar small, .user-card span { color: #8fa89d; font-size: 13px; }
.nav { display: grid; gap: 4px; }
.nav-icon { font-size: 10px; opacity: .6; margin-right: 4px; }
.nav-item {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    padding: 0 12px;
    text-align: left;
    color: #c8dbd4;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background .12s, color .12s;
}
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item:hover:not(.active) { background: rgba(255,255,255,0.1); color: #fff; }
.user-card {
    margin-top: auto;
    display: grid;
    gap: 6px;
    padding: 14px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
}
.password-modal {
    padding: 14px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
}
.password-modal input {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #eef6f1;
}
.password-modal input::placeholder { color: #8fa89d; }

/* ── MAIN ── */
.main {
    padding: 28px;
    display: grid;
    gap: 22px;
    align-content: start;
    min-width: 0;
    overflow-x: hidden;
}
.topbar, .module-head, .panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.eyebrow {
    margin: 0 0 6px;
    color: var(--brand);
    font-weight: 900;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
h1, h2 { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 3.5vw, 44px); line-height: 1.05; }
h2 { margin-bottom: 4px; font-size: 18px; }
p { margin-bottom: 0; }

/* ── METRICS ── */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 14px; }
.metrics article, .panel, .table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.metrics article { display: grid; gap: 6px; padding: 18px 20px; }
.metrics span { color: var(--muted); font-size: 13px; font-weight: 600; }
.metrics strong { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }

/* ── VIEWS ── */
.view { display: none; }
.view.active { display: grid; gap: 18px; }

/* ── GRID ── */
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ── PANEL ── */
.panel { padding: 20px; }
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    color: var(--brand-dark);
    background: #dff3ed;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.badge.danger { color: var(--red); background: #ffe4df; }
.progress { height: 10px; overflow: hidden; border-radius: 999px; background: #edf2ef; margin: 10px 0; }
.progress span { display: block; width: 0%; height: 100%; background: var(--brand); transition: width .4s ease; }
.list, .card-grid { display: grid; gap: 12px; }
.list-item, .data-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}
.row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }

/* ── FORMS ── */
.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.inline-form input, .inline-form select { width: 148px; }
.full-form { justify-content: flex-start; }
.full-form input, .full-form select { width: 170px; }
.stack-form { display: grid; gap: 8px; }
.stack-form .inline-form { justify-content: flex-start; }
.stack-form textarea { width: 100%; max-width: 700px; }
.import-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border: 1.5px dashed var(--line);
    border-radius: 8px;
    background: #f9fbf9;
}

/* ── SEARCH ── */
.search-bar { max-width: 380px; }
.search-bar input { width: 100%; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; min-width: 660px; border-collapse: collapse; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; background: #f9fbf9; color: var(--muted); font-weight: 700; }
td { color: var(--muted); font-size: 14px; }
td strong { color: var(--ink); }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafcfb; }

/* ── STATUS CHIPS ── */
.status {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    color: var(--brand-dark);
    background: #dff3ed;
    white-space: nowrap;
}
.status.pending, .status.open, .status.high { color: #a16207; background: #fff3d7; }
.status.in_progress { color: #0369a1; background: #e0f2fe; }
.status.urgent { color: var(--red); background: #ffe4df; }
.status.paid, .status.approved, .status.resolved { color: var(--green); background: #dcf5e8; }
.status.exited { color: var(--muted); background: #f1f5f3; }
.status.vacant { color: var(--muted); background: #f1f5f3; }
.status.occupied { color: var(--brand-dark); background: var(--brand-light); }

/* ── KANBAN ── */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(200px, 1fr)); gap: 14px; }
.kanban-col {
    min-height: 240px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}
.kanban-col h3 { margin: 0 0 12px; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kanban-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ── CARD GRID ── */
.card-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.data-card h3 { margin: 6px 0 4px; font-size: 16px; }

/* ── TOAST ── */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: 380px;
    padding: 12px 18px;
    border-radius: var(--radius);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    background: #10241f;
    opacity: 0;
    transform: translateY(14px);
    transition: .22s ease;
    pointer-events: none;
    z-index: 999;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { background: var(--red); }
.toast.toast-ok { background: var(--green); }

/* ── OVERLAY ── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 150;
}
.overlay.show { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .grid.two { grid-template-columns: 1fr; }
    .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .hamburger { display: flex; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        width: 240px;
        transition: left .22s ease;
    }
    .sidebar.open { left: 0; }
    .main { padding: 16px; padding-top: 62px; }
    .kanban { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .topbar, .module-head { flex-direction: column; align-items: stretch; }
    .inline-form { flex-direction: column; }
    .inline-form input, .inline-form select, .inline-form button { width: 100%; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .stack-form .inline-form { flex-direction: column; }
}

/* ── LOADING BAR ── */
.loading-bar {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0%;
    background: var(--brand);
    z-index: 9999;
    transition: width .3s ease, opacity .3s ease;
    opacity: 0;
}
.loading-bar.active {
    opacity: 1;
    width: 70%;
    transition: width 20s cubic-bezier(0.1, 0.05, 0, 1);
}
.loading-bar.done {
    width: 100%;
    opacity: 0;
    transition: width .2s ease, opacity .4s ease .1s;
}

/* ── SETUP STATS ── */
.setup-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}
.setup-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.setup-stat strong { font-size: 20px; font-weight: 800; }
.setup-stat span { color: var(--muted); font-size: 13px; }

/* ── ACTION CELL ── */
.action-cell { white-space: nowrap; }
.receipt-body { min-height: 100vh; background: #e9efec; }
.receipt-page { width: min(920px, calc(100% - 28px)); margin: 28px auto; }
.receipt-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.receipt-sheet {
    padding: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}
.receipt-header, .receipt-grid, .receipt-footer {
    display: flex;
    justify-content: space-between;
    gap: 24px;
}
.receipt-header { padding-bottom: 24px; border-bottom: 2px solid var(--ink); }
.receipt-number {
    min-width: 220px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    align-self: flex-start;
}
.receipt-number span, .receipt-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.receipt-grid { margin: 28px 0; }
.receipt-grid > div { flex: 1; }
.receipt-table { min-width: 0; }
.receipt-table tfoot th { font-size: 16px; background: #f4f7f6; }
.receipt-footer {
    margin-top: 32px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    align-items: center;
}
@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
    .receipt-page { width: 100%; margin: 0; }
    .receipt-sheet { border: 0; box-shadow: none; padding: 0; }
}
