:root {
    --orange: #e14b2a;
    --orange-dark: #be3a1c;
    --orange-soft: #fde8e1;
    --green: #1c7a43;
    --green-dark: #0e4e2a;
    --green-soft: #e5f5eb;
    --ink: #1a1714;
    --muted: #6e675f;
    --line: #e4ddd3;
    --paper: #f4f0e8;
    --card: #fffdf9;
    --danger: #b42318;
    --shadow: 0 16px 40px rgba(28, 23, 20, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
    font-size: 16.5px;
    line-height: 1.45;
}
a { color: var(--green-dark); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 700; line-height: 1.15; margin: 0; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.15rem; margin-bottom: 12px; }
p { margin: 0; }

.topbar {
    background: var(--card);
    border-bottom: 4px solid var(--green);
    box-shadow: 0 1px 0 var(--orange);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 12px 20px 10px;
    display: flex;
    align-items: center;
    gap: 22px;
}
.lockup { display: flex; flex-direction: column; text-decoration: none; }
.lockup-name {
    font-family: "Alfa Slab One", "Arial Black", Georgia, serif;
    font-weight: 400;
    color: var(--orange);
    text-shadow: 0.07em 0.07em 0 var(--green);
    letter-spacing: 0.02em;
    line-height: 0.9;
    font-size: 1.55rem;
}
.lockup-bar .lockup-name { font-size: 1.35rem; }
.lockup-line {
    margin-top: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--green);
}
.nav { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.nav a {
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 999px;
}
.nav a.is-active, .nav a:hover { background: var(--green-soft); color: var(--green-dark); }
.who { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.who span { font-weight: 700; }
.who small { color: var(--muted); }
.logout { font-weight: 700; text-decoration: none; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 48px; }
.site-foot {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.92rem;
    padding: 18px 0 28px;
}
.site-foot .wrap { padding-top: 0; padding-bottom: 0; }
.site-foot a { color: var(--green-dark); font-weight: 700; text-decoration: none; }

.page-head { margin-bottom: 18px; }
.page-head p, .lede, .muted, .note { color: var(--muted); }
.note { margin: 4px 0 16px; }
.lede { margin-bottom: 16px; }

.banner, .flash {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
}
.banner, .flash-ok { background: var(--green-soft); color: var(--green-dark); }
.flash-error { background: var(--orange-soft); color: var(--orange-dark); }
.banner a, .flash a { font-weight: 700; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-top: 4px solid var(--green);
    border-radius: 14px;
    padding: 14px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat span { color: var(--muted); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.stat strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat-transfer { border-top-color: var(--green-dark); }
.stat-pos { border-top-color: var(--orange); }
.stat-collected { border-top-color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.field span, .field label, label.field span { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.field input, .field select, .close-form input, .close-form select, .password-row input {
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 12px;
    background: white;
    width: 100%;
}
.field input:focus, .field select:focus, .close-form input:focus, .close-form select:focus {
    outline: 3px solid rgba(225, 75, 42, 0.25);
    border-color: var(--orange);
}
.quick-ranges { display: flex; gap: 8px; margin-bottom: 16px; }
.chip {
    text-decoration: none;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 700;
    font-size: 0.92rem;
}
.chip.is-active { background: var(--green); color: white; border-color: var(--green); }

.btn {
    height: 44px;
    border-radius: 10px;
    border: 0;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-primary { background: var(--orange); color: white; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: var(--green-dark); }
.btn-ghost { background: transparent; color: var(--green-dark); border: 1px solid var(--line); }
.btn-danger { background: white; color: var(--danger); border: 1px solid #f0c4be; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: wait; }

.form-card, .side-card, .login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.form-card.narrow { max-width: 440px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.field-wide { grid-column: 1 / -1; }
.form-card .field { margin-bottom: 12px; }
.form-grid .field { margin-bottom: 0; }

.table-wrap {
    overflow-x: auto;
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th {
    text-align: left;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 14px;
    background: #fbf8f3;
    border-bottom: 1px solid var(--line);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num, .invoice { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.invoice { color: var(--green-dark); }
.pill, .role {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.pill-open, .role-admin { background: var(--orange-soft); color: var(--orange-dark); }
.pill-closed, .role-cashier { background: var(--green-soft); color: var(--green-dark); }
.role-attendant { background: #eee7dc; color: #5c5146; }
.close-form { display: flex; flex-wrap: wrap; gap: 6px; min-width: 280px; }
.close-form input, .close-form select { width: 108px; height: 40px; }
.inline-form { display: inline; }

.empty {
    background: white;
    border: 1px dashed var(--line);
    border-radius: 14px;
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
}

.split { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 18px; align-items: start; }
.section-head, .side-card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head a { font-weight: 700; }
.plain { margin: 8px 0 16px; padding-left: 18px; }
.invoice-stamp {
    font-family: "Alfa Slab One", Georgia, serif;
    font-size: 2rem;
    letter-spacing: 0.04em;
    color: transparent;
    -webkit-text-stroke: 1.5px var(--green);
    margin: 4px 0 12px;
}
@supports not (-webkit-text-stroke: 1px #000) {
    .invoice-stamp { color: var(--green); }
}

.live-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--green-soft);
    color: var(--green-dark);
    font-weight: 700;
    border-radius: 999px;
    padding: 6px 12px;
}
.live-pill.is-down { background: var(--orange-soft); color: var(--orange-dark); }
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(28, 122, 67, 0.55);
    animation: pulse 1.8s infinite;
}
.live-pill.is-down .live-dot { background: var(--orange); animation: none; }
.live-open { margin-bottom: 10px; }
.sale-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}
.sale-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-top: 4px solid var(--green);
    border-radius: 16px;
    padding: 14px 14px 12px;
    box-shadow: var(--shadow);
}
.sale-card.is-new { animation: arrive 0.8s ease; }
.sale-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.sale-card .invoice-stamp { font-size: 1.7rem; margin: 0; }
.attendant { font-weight: 700; text-align: right; }
.customer { margin: 10px 0; font-weight: 700; }
.lines { border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); padding: 8px 0; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.line em { font-style: normal; color: var(--muted); }
.sale-card footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 12px; }
.sale-card footer span { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.sale-card footer strong { font-size: 1.25rem; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 40; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 16, 12, 0.48); }
.modal-card {
    position: relative;
    max-width: 460px;
    margin: 7vh auto;
    background: white;
    border-radius: 18px;
    padding: 18px;
    max-height: 86vh;
    overflow: auto;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.kicker { color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.icon-btn {
    border: 0;
    background: var(--paper);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    font-size: 1.4rem;
    cursor: pointer;
}
.modal-items { margin: 12px 0; }
.method-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.method {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 12px;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    cursor: pointer;
    background: white;
}
.method input { position: absolute; opacity: 0; }
.method:has(input:checked), .method input:checked + span { background: var(--green); color: white; }
.method:has(input:checked) { background: var(--green); color: white; border-color: var(--green); }
.pay-hint { min-height: 1.3em; margin-bottom: 10px; }
.pay-hint.is-bad { color: var(--orange-dark); font-weight: 700; }
.pay-hint.is-good { color: var(--green-dark); font-weight: 700; }
.form-error { color: var(--orange-dark); font-weight: 700; margin: 0 0 10px; }
body.modal-open { overflow: hidden; }

.login-body { background: var(--green-dark); }
.login-screen { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 0.85fr; }
.brand-panel {
    position: relative;
    overflow: hidden;
    color: #e7f6ec;
    padding: 64px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.08), transparent 28%),
        linear-gradient(160deg, #146b38 0%, #0e4e2a 55%, #0b3d21 100%);
}
.brand-panel .lockup-name { font-size: clamp(3.2rem, 7vw, 5.4rem); color: #f25c36; text-shadow: 0.06em 0.06em 0 #08381c; }
.brand-panel .lockup-line { color: #e7f6ec; font-size: 0.95rem; }
.brand-tag { max-width: 36rem; font-size: 1.12rem; }
.brand-meta { display: grid; gap: 14px; }
.brand-meta span { display: block; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.75rem; font-weight: 700; opacity: 0.8; }
.brand-meta a { color: white; font-weight: 700; text-decoration: none; }
.stamp { position: absolute; width: 180px; right: 6%; bottom: 8%; color: rgba(255, 255, 255, 0.16); }
.login-side { background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-card { width: min(420px, 100%); margin: 0; }
.login-card h1 { margin-bottom: 8px; }
.password-row { display: flex; gap: 8px; }
.password-row input { flex: 1; }
.password-row .btn { width: auto; }

.install-card { max-width: 640px; margin: 32px auto; }
.checks { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.check { border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 0.85rem; background: var(--green-soft); color: var(--green-dark); }
.check.is-bad { background: var(--orange-soft); color: var(--orange-dark); }
.accounts { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 12px 0 18px; }
.accounts dt { color: var(--muted); }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(28, 122, 67, 0.45); }
    70% { box-shadow: 0 0 0 8px rgba(28, 122, 67, 0); }
    100% { box-shadow: 0 0 0 0 rgba(28, 122, 67, 0); }
}
@keyframes arrive {
    from { transform: translateY(-6px); box-shadow: 0 0 0 3px rgba(225, 75, 42, 0.35); }
    to { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .live-dot, .sale-card.is-new { animation: none; }
}
@media (max-width: 900px) {
    .stats, .split, .form-grid, .login-screen { grid-template-columns: 1fr; }
    .topbar-inner { flex-wrap: wrap; }
    .who { width: 100%; }
    .brand-panel { padding: 36px 22px 48px; }
    .stamp { width: 110px; }
}
