:root {
    --ink: #181923;
    --muted: #6f7280;
    --line: #e7e8ee;
    --paper: #ffffff;
    --wash: #f6f7fb;
    --pink: #ff3fa4;
    --cyan: #00b8d9;
    --yellow: #ffd447;
    --green: #19a974;
    --red: #d64545;
    --shadow: 0 14px 34px rgba(24, 25, 35, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--wash);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}
.sidebar {
    background: #161720;
    border-right: 1px solid #272936;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: block; padding: 4px 8px 24px; }
.brand img { max-height: 74px; object-fit: contain; }
.nav { display: grid; gap: 6px; }
.nav a {
    color: #f8f8fb;
    padding: 11px 12px;
    border-radius: 8px;
    font-weight: 700;
}
.nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.main { padding: 28px; min-width: 0; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}
.topbar h1, .guest-panel h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.eyebrow {
    margin: 0 0 3px;
    color: var(--pink);
    font-weight: 800;
    text-transform: uppercase;
    font-size: 12px;
}
.user-pill {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    margin-right: 8px;
    color: var(--muted);
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.topbar-actions form { margin: 0; }

.panel, .kpi, .guest-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.panel { padding: 20px; margin-bottom: 18px; overflow-x: auto; }
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.panel-head h2 { margin: 0; }
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.kpi { padding: 18px; border-top: 4px solid var(--pink); }
.kpi:nth-child(2) { border-top-color: var(--cyan); }
.kpi:nth-child(3) { border-top-color: var(--yellow); }
.kpi:nth-child(4) { border-top-color: var(--green); }
.kpi span { display: block; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.kpi strong { font-size: 27px; }
.two-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
tfoot th, tfoot td { font-size: 16px; color: var(--ink); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 800; }
input, select, textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #d6d8e2;
    border-radius: 8px;
    padding: 9px 11px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}
textarea { min-height: 92px; resize: vertical; }
.span-2 { grid-column: span 2; }
.checkbox { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.checkbox input { width: auto; min-height: auto; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    padding: 10px 15px;
    background: var(--pink);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}
.button:hover { text-decoration: none; filter: brightness(.96); }
.button.ghost { background: #eef0f6; color: var(--ink); }
.button.full { width: 100%; }
.link-button {
    border: 0;
    background: transparent;
    color: var(--cyan);
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-weight: 800;
}
.link-button.danger { color: var(--red); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions form { margin: 0; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 3px 9px;
    background: #eef0f6;
    color: var(--ink);
    font-size: 12px;
    font-weight: 900;
}
.badge.active { background: #dcf8ec; color: #116846; }
.badge.pending { background: #fff3bf; color: #826200; }
.badge.suspended { background: #ffe0e0; color: #991f1f; }
.badge.paid { background: #dcf8ec; color: #116846; }
.badge.issued { background: #dcf8ec; color: #116846; }
.badge.cancelled { background: #ffe0e0; color: #991f1f; }
.badge.ok { background: #dcf8ec; color: #116846; }
.badge.low_margin { background: #fff3bf; color: #826200; }
.badge.no_recipe { background: #eef0f6; color: #555b6b; }
.badge.manual_cost { background: #def7ff; color: #00657a; }
.badge.below_cost { background: #ffe0e0; color: #991f1f; }
.muted { color: var(--muted); }
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 800;
}
.alert.success { background: #dcf8ec; color: #116846; }
.alert.error { background: #ffe0e0; color: #991f1f; }
.empty-state { text-align: center; padding: 70px 20px; }

.guest-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #161720;
}
.guest-panel {
    width: min(480px, 100%);
    padding: 28px;
}
.guest-logo {
    display: block;
    max-height: 112px;
    margin: 0 auto 20px;
    object-fit: contain;
}

.sale-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 0 0 14px;
}
.sale-meta div { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.sale-meta dt { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.sale-meta dd { margin: 3px 0 0; font-weight: 800; }
.ticket-body { background: #fff; }
.ticket {
    width: min(380px, 100%);
    margin: 18px auto;
    padding: 18px;
    color: #111;
}
.ticket table { min-width: 0; font-size: 13px; }
.ticket th, .ticket td { padding: 8px 4px; }
.ticket h1 { text-align: center; margin: 4px 0; font-size: 20px; }
.ticket-logo { text-align: center; }
.ticket-logo img { width: 64px; height: 64px; object-fit: contain; }
.ticket-note { text-align: center; color: var(--muted); font-size: 12px; }
.sale-cart table { min-width: 760px; }
.sale-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.sale-summary div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fafbff;
}
.sale-summary span { display: block; color: var(--muted); font-weight: 800; margin-bottom: 5px; }
.sale-summary strong { font-size: 20px; }
.invoice-document { max-width: 980px; margin-left: auto; margin-right: auto; }
.invoice-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 22px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
    margin-bottom: 18px;
}
.invoice-header h2 { margin: 0 0 4px; font-size: 24px; }
.invoice-folio {
    min-width: 210px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    text-align: right;
}
.invoice-folio span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.invoice-folio strong { display: block; margin: 4px 0; font-size: 20px; }
.invoice-parties {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin: 18px 0;
}
.invoice-parties > div, .invoice-note {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}
.invoice-parties h3, .invoice-note h3 { margin: 0 0 8px; font-size: 15px; }
.invoice-parties p, .invoice-note p { margin: 5px 0; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-grid, .two-columns, .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .topbar-actions { width: 100%; }
    .sale-meta { grid-template-columns: 1fr; }
    .sale-summary { grid-template-columns: 1fr; }
    .invoice-header { flex-direction: column; }
    .invoice-folio { width: 100%; text-align: left; }
    .invoice-parties { grid-template-columns: 1fr; }
}

@media print {
    .print-hide { display: none !important; }
    body { background: #fff; }
    .app-shell { display: block; }
    .sidebar, .topbar { display: none !important; }
    .main { padding: 0; }
    .panel { box-shadow: none; border: 0; }
    .ticket { margin: 0; width: 100%; }
    .invoice-document { max-width: none; margin: 0; padding: 0; }
    table { min-width: 0; }
}
