/* DINEZAP operations PWA */
:root {
  --bg: #F6F4F0;
  --surface: #FFFFFF;
  --text: #1A1D20;
  --muted: #6C757D;
  --line: #E6E1D9;
  --accent: #FF6B35;
  --accent-2: #F7B05B;
  --dark: #14171A;
  --ok: #1E9E6A;
  --warn: #E0A200;
  --danger: #D64545;
  --radius: 14px;
  --sidebar: 248px;
  --shadow: 0 10px 30px rgba(20, 23, 26, .07);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Open Sans", system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: "Poppins", system-ui, sans-serif; margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { margin: 0; padding: 0; list-style: none; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.boot, .app-boot { min-height: 100vh; display: grid; place-items: center; text-align: center; color: var(--muted); }
.brand-mark {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; letter-spacing: .05em;
}

/* ---------- Auth screen ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 30px 26px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.3rem; }
.auth-foot { margin-top: 16px; font-size: .88rem; text-align: center; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.shell.collapsed { --sidebar: 68px; }
.sidebar { background: var(--dark); color: #E8E5E0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden; }
.sidebar-top { display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-top .brand-mark { margin: 0; width: 36px; height: 36px; border-radius: 12px; font-size: .8rem; }
.sidebar-title { font-family: "Poppins", sans-serif; font-weight: 800; letter-spacing: .05em; font-size: .98rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; display: grid; gap: 2px; align-content: start; }
.sidebar-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 10px;
  color: #C9C4BC; font-weight: 600; font-size: .92rem; white-space: nowrap; }
.sidebar-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.sidebar-nav .ico { width: 20px; text-align: center; flex: none; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.09); padding: 12px; display: grid; gap: 8px; }
.sidebar-user { font-size: .85rem; color: #B7B2AA; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell.collapsed .label, .shell.collapsed .sidebar-title, .shell.collapsed .sidebar-user { display: none; }
.shell.collapsed .sidebar-nav a { justify-content: center; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; background: rgba(246,244,240,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 1.1rem; }
.topbar .spacer { margin-left: auto; }
.icon-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px;
  display: grid; place-items: center; cursor: pointer; font-size: 1rem; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.view { padding: 18px; display: grid; gap: 16px; align-content: start; }

/* ---------- Cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-family: "Poppins", sans-serif; font-size: 1.5rem; font-weight: 700; }
.stat .s { font-size: .84rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; background: #FBFAF8; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FCFAF7; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > label { font-size: .85rem; font-weight: 600; color: #43484D; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255,107,53,.35); border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
.field .err { color: var(--danger); font-size: .8rem; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.check input { width: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  border-radius: 11px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: .85rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters .field { margin: 0; min-width: 150px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: #EEE9E1; color: #4B5157; white-space: nowrap; }
.badge.ok { background: rgba(30,158,106,.14); color: var(--ok); }
.badge.warn { background: rgba(224,162,0,.16); color: #96700A; }
.badge.danger { background: rgba(214,69,69,.14); color: var(--danger); }
.badge.info { background: rgba(255,107,53,.14); color: #C24A1D; }

/* ---------- Toasts & modal ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--dark); color: #fff; padding: 11px 15px; border-radius: 11px; box-shadow: var(--shadow);
  max-width: 330px; font-size: .9rem; }
.toast.ok { background: #12694A; }
.toast.err { background: #A62F2F; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,23,26,.5); display: grid; place-items: center;
  padding: 18px; z-index: 150; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px; max-height: 88vh;
  overflow: auto; padding: 20px; box-shadow: var(--shadow); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.modal-head .spacer { margin-left: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ---------- Kitchen / waiter boards ---------- */
.board { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.ticket { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--accent);
  border-radius: var(--radius); padding: 13px; display: grid; gap: 8px; }
.ticket.new { border-left-color: var(--accent); }
.ticket.preparing { border-left-color: var(--warn); }
.ticket.ready { border-left-color: var(--ok); }
.ticket.delayed { border-left-color: var(--danger); }
.ticket-head { display: flex; align-items: baseline; gap: 8px; }
.ticket-head .no { font-family: "Poppins", sans-serif; font-weight: 700; }
.ticket-items { display: grid; gap: 4px; font-size: .92rem; }
.ticket-items .qty { font-weight: 700; color: var(--accent); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  display: grid; gap: 5px; cursor: pointer; }
.tile.busy { border-color: var(--accent); background: #FFF6F1; }
.tile.bill { border-color: var(--warn); background: #FFFAEC; }

/* ---------- Offline banner ---------- */
.offline-bar { background: var(--danger); color: #fff; text-align: center; padding: 7px; font-size: .86rem; }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg,#EEEAE4,#F7F4F0,#EEEAE4);
  background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 120; transform: translateX(-100%);
    transition: transform .22s ease; height: 100vh; }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(20,23,26,.45); z-index: 110; }
  .shell.collapsed { --sidebar: 250px; }
  .shell.collapsed .label, .shell.collapsed .sidebar-title, .shell.collapsed .sidebar-user { display: block; }
  .view { padding: 14px 14px 84px; }
  .bottom-nav { display: flex; }
}
@media print {
  .sidebar, .topbar, .toasts, .no-print { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; }
}

/* ---------------------------------------------------------- layout helpers */
.spacer { flex: 1 1 auto; }
.sm { font-size: 12px; }
.center { text-align: center; }
.break { word-break: break-all; }
.section { margin: 22px 0 10px; font-size: 15px; font-weight: 650; }

.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.input { padding: 9px 11px; border: 1px solid var(--line, #d9dde5); border-radius: 9px;
  background: var(--surface, #fff); color: inherit; font: inherit; min-width: 140px; }
.input:focus { outline: 2px solid var(--brand, #e2451f); outline-offset: 1px; }
.grow { flex: 1 1 220px; }

/* ------------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line, #e6e9ef); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted, #6b7280); }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table td.right, .table th.right { text-align: right; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: rgba(0,0,0,.03); }
.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 2px; }

/* ------------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .field { display: flex; flex-direction: column; gap: 5px; }
.form-grid label { font-size: 13px; font-weight: 600; }
.field-error { color: #c62828; font-size: 12px; min-height: 1em; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line, #d9dde5);
  background: transparent; cursor: pointer; font: inherit; }
.tab.active { background: var(--brand, #e2451f); color: #fff; border-color: transparent; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- kitchen */
.kot-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.kot { border: 1px solid var(--line, #e2e6ee); border-radius: 14px; padding: 14px; background: var(--surface, #fff); }
.kot.late { border-color: #d64545; box-shadow: 0 0 0 2px rgba(214,69,69,.12); }
.kot header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kot-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.kot-items li { display: flex; gap: 8px; font-size: 14px; }
.kot-items .qty { font-weight: 700; }
.kot footer { margin-top: 12px; }

/* -------------------------------------------------------------------- floor */
.alert-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.alert-chip { border: 1px solid var(--line, #e2e6ee); background: #fff8e1; border-radius: 999px;
  padding: 8px 14px; cursor: pointer; font: inherit; display: inline-flex; gap: 8px; align-items: center; }
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.table-card { border: 1px solid var(--line, #e2e6ee); border-radius: 14px; padding: 12px; background: var(--surface, #fff); }
.table-card.busy { border-color: var(--brand, #e2451f); }
.table-card header { display: flex; align-items: center; gap: 8px; }
.table-card footer { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* --------------------------------------------------------------- composer */
.composer { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.menu-picker { display: grid; gap: 8px; max-height: 46vh; overflow: auto; margin-top: 10px; }
.menu-chip { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--line, #e2e6ee); border-radius: 10px; background: transparent; cursor: pointer; font: inherit; }
.menu-chip:hover { border-color: var(--brand, #e2451f); }
.cart-lines { display: grid; gap: 8px; margin: 10px 0; max-height: 32vh; overflow: auto; }
.cart-line { display: flex; align-items: center; gap: 8px; }
.cart-line .qty { min-width: 22px; text-align: center; font-weight: 700; }
.cart-total { display: flex; justify-content: space-between; border-top: 1px solid var(--line, #e6e9ef); padding-top: 8px; }

/* ------------------------------------------------------------------ billing */
.totals { display: grid; gap: 6px; max-width: 340px; margin-left: auto; font-size: 14px; }
.totals > div { display: flex; justify-content: space-between; gap: 20px; }
.totals .grand { border-top: 1px solid var(--line, #e6e9ef); padding-top: 8px; font-size: 16px; }
.invoice-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.qr-box img { border-radius: 12px; }

/* ------------------------------------------------------------ super admin */
.module-list, .perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.brand-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.brand-preview { border: 1px dashed var(--line, #d9dde5); border-radius: 12px; min-height: 90px;
  display: grid; place-items: center; margin: 6px 0; overflow: hidden; }
.brand-preview img { max-width: 100%; max-height: 140px; }

@media (max-width: 860px) {
  .form-grid, .composer { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
}

@media print {
  .sidebar, .topbar, .toolbar, .page-actions, .tabs, .pager, .row-actions, .offline-bar { display: none !important; }
  .view { padding: 0; }
}


/* ---------- Official brand marks ---------- */
.boot-logo { height: 30px; width: auto; margin: 0 auto 14px; }
.auth-logo { height: 32px; width: auto; margin: 0 auto 14px; }
.sidebar-logo { height: 24px; width: auto; }
.sidebar-logo-icon { width: 30px; height: 30px; flex: none; display: none; }
.shell.collapsed .sidebar-logo { display: none; }
.shell.collapsed .sidebar-logo-icon { display: block; }

/* ---------- Mobile bottom navigation + sheets ---------- */
.bottom-nav { display: none; position: fixed; inset: auto 0 0 0; z-index: 100;
  background: var(--surface, #fff); border-top: 1px solid var(--line, #e3e6ec);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
.bottom-nav a, .bottom-nav button { flex: 1 1 0; min-height: 52px; border: 0; background: none;
  display: grid; place-items: center; gap: 2px; font-size: .68rem; font-weight: 700;
  color: var(--muted, #6C757D); cursor: pointer; border-radius: 12px; }
.bottom-nav a.active { color: var(--accent, #FF6B35); background: rgba(255,107,53,.1); }
.bottom-nav .ico { font-size: 1.05rem; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 160; background: rgba(20,23,26,.45);
  display: flex; align-items: flex-end; }
.sheet { width: 100%; background: var(--surface, #fff); border-radius: 20px 20px 0 0; padding: 10px 16px
  calc(18px + env(safe-area-inset-bottom)); max-height: 78vh; overflow: auto; }
.sheet-grip { width: 42px; height: 4px; border-radius: 4px; background: #d8dbe2; margin: 4px auto 12px; }
.sheet-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 14px; }
.sheet-links a { min-height: 76px; display: grid; place-items: center; gap: 6px; border-radius: 14px;
  border: 1px solid var(--line, #e3e6ec); font-size: .78rem; font-weight: 700; text-align: center; padding: 8px; }

/* Touch targets on small screens */
@media (max-width: 860px) {
  .btn, .icon-btn, input, select, textarea { min-height: 44px; }
}


/* ---------- Form sections, password controls, key/value lists ---------- */
.form-section { margin: 6px 0 2px; }
.form-section h3 { margin: 0; font-size: .95rem; font-family: "Poppins", sans-serif; }
.form-section + .field { margin-top: 0; }
.pw-field { position: relative; }
.pw-field .input { padding-right: 74px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none;
  color: var(--accent, #FF6B35); font-weight: 700; cursor: pointer; min-height: 36px; padding: 0 10px; }
.pw-tools { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.pw-meter { margin-top: 6px; font-size: .76rem; font-weight: 700; color: var(--muted, #6C757D); }
.pw-meter.s4, .pw-meter.s5 { color: #1a7f4b; }
.pw-meter.s3 { color: #b8860b; }
.pw-meter.s0, .pw-meter.s1, .pw-meter.s2 { color: #b5341f; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; margin: 12px 0; }
.kv dt { color: var(--muted, #6C757D); font-size: .85rem; }
.kv dd { margin: 0; font-weight: 600; }
.stack { display: grid; gap: 6px; }

/* Single-column forms on mobile */
@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr !important; }
  .form-grid .span-2 { grid-column: auto !important; }
}


/* ---------- Tables become cards on mobile ---------- */
@media (max-width: 860px) {
  .table-wrap { border: 0; background: none; box-shadow: none; padding: 0; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { background: var(--surface, #fff); border: 1px solid var(--line, #e3e6ec); border-radius: 16px;
    padding: 12px 14px; margin-bottom: 10px; }
  .table td { border: 0; padding: 4px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted, #6C757D); font-size: .74rem;
    text-transform: uppercase; letter-spacing: .04em; font-weight: 700; text-align: left; }
  .table td:empty, .table td[data-label=""]::before { display: none; }
  .table td .row-actions { justify-content: flex-end; flex-wrap: wrap; }
}


/* ---------- Tablet & touch layouts for service screens ---------- */
@media (min-width: 700px) and (max-width: 1200px) {
  .kot-board { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
  .table-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
@media (pointer: coarse) {
  .kot footer .btn, .table-card .btn, .invoice-actions .btn { min-height: 46px; font-size: 15px; }
  .kot-items li { font-size: 15px; }
  .btn.sm { min-height: 40px; }
}
.kot footer .btn { width: 100%; }
.table-card { display: grid; gap: 6px; align-content: start; }

/* Invoices stay tabular even on small screens */
@media (max-width: 860px) {
  .invoice .table, .invoice .table tbody, .invoice .table tr { display: table; width: 100%; }
  .invoice .table tbody { display: table-row-group; }
  .invoice .table tr { display: table-row; border: 0; padding: 0; margin: 0; background: none; }
  .invoice .table thead { display: table-header-group; }
  .invoice .table td, .invoice .table th { display: table-cell; text-align: left; padding: 6px 4px; }
  .invoice .table td::before { content: none; }
  .invoice .table td.num, .invoice .table th.num { text-align: right; }
  .invoice-head { display: grid; gap: 8px; }
  .invoice-head .right { text-align: left; }
}


/* ---------- Native-app feel: safe areas, scroll and taps ---------- */
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
.boot, .app-boot, .shell, .auth { min-height: 100dvh; }
button, a, .btn, input, select, textarea { touch-action: manipulation; }
.topbar { padding-top: calc(env(safe-area-inset-top) * .5); }
.sidebar { padding-bottom: env(safe-area-inset-bottom); }
.view { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.bottom-nav { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.bottom-sheet { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
@media (max-width: 860px) {
  .view { -webkit-overflow-scrolling: touch; }
  .modal-card { max-height: 92dvh; }
}
html.standalone .install-hint { display: none; }

/* ---------- Install / update banner ---------- */
.pwa-banner {
  position: fixed; left: 12px; right: 12px; z-index: 90;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  display: flex; align-items: center; gap: 12px;
  background: var(--surface, #fff); color: var(--text, #1A1D20);
  border: 1px solid var(--line, #E6E1D9); border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 18px 40px -18px rgba(20, 23, 26, .45);
  transform: translateY(18px); opacity: 0; transition: transform .22s ease, opacity .22s ease;
}
.pwa-banner.in { transform: none; opacity: 1; }
.pwa-banner img { border-radius: 10px; }
.pwa-copy { display: grid; flex: 1; min-width: 0; }
.pwa-copy strong { font-size: .93rem; }
.pwa-copy span { font-size: .8rem; color: var(--muted, #6C757D); }
.pwa-banner .btn { flex-shrink: 0; }
@media (max-width: 860px) {
  .pwa-banner { bottom: calc(env(safe-area-inset-bottom) + 76px); }
}
@media (prefers-reduced-motion: reduce) {
  .pwa-banner { transition: none; }
}


/* ---------- Brand marks: never stretch, never oversize ---------- */
.boot-logo, .auth-logo, .sidebar-logo, .topbar-logo, .biz-logo { object-fit: contain; width: auto; height: auto; }
.boot-logo { max-width: 150px; max-height: 52px; margin: 0 auto 14px; }
.auth-logo { max-width: 150px; max-height: 52px; margin: 0 auto 14px; }
.sidebar-logo { max-width: 145px; max-height: 40px; }
.sidebar-logo-icon { width: 32px; height: 32px; object-fit: contain; flex: none; display: none; }
.topbar-logo { display: none; max-width: 110px; max-height: 32px; }
@media (max-width: 860px) {
  .topbar-logo { display: block; }
  .topbar h1 { font-size: .98rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Business logos keep their aspect ratio in every context */
.biz-logo { max-width: 140px; max-height: 56px; }
.biz-logo.preview { max-width: 120px; max-height: 120px; }
.biz-logo.thumb, .thumb-48 img { width: 48px; height: 48px; object-fit: contain; }
.biz-initials { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px;
  background: rgba(255,107,53,.12); color: var(--accent, #FF6B35); font-weight: 800; font-size: .8rem; }

/* ---------- Icon system (Lucide outline) ---------- */
.ic { display: block; flex: none; }
.sidebar-nav .ico, .bottom-nav .ico { display: grid; place-items: center; }
.sidebar-nav .ico { width: 20px; height: 20px; }
.bottom-nav .ico { width: 22px; height: 22px; font-size: inherit; }
.btn .ic, .icon-btn .ic { display: inline-block; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.nav-group { margin: 12px 10px 4px; font-size: .68rem; letter-spacing: .11em; text-transform: uppercase;
  color: rgba(255,255,255,.42); font-weight: 700; }
.shell.collapsed .nav-group { display: none; }

/* ---------- Account sheet ---------- */
.profile-head { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 12px;
  padding: 4px 2px 14px; border-bottom: 1px solid var(--line, #e3e6ec); margin-bottom: 12px; }
.profile-head .avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent, #FF6B35); color: #fff; font-weight: 800; }
.profile-head strong { display: block; font-size: .96rem; }
.profile-head span { font-size: .8rem; color: var(--muted, #6C757D); }
.min-w-0 { min-width: 0; }
.sheet-links a { flex-direction: column; }

/* ---------- No horizontal overflow anywhere ---------- */
html, body { max-width: 100%; overflow-x: hidden; }
.view, .card, .main { min-width: 0; }


/* ---------- Empty states, skeletons, thumbnails, validation ---------- */
.empty { display: grid; justify-items: center; gap: 6px; }
.empty-ico { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
  background: rgba(255,107,53,.1); color: var(--accent, #FF6B35); margin-bottom: 4px; }
.empty-title { font-family: "Poppins", sans-serif; font-size: 1rem; color: var(--text, #1f2328); }
.empty-msg { margin: 0; max-width: 42ch; font-size: .88rem; }
.empty-action { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.skeleton-card { display: grid; gap: 14px; }
.skeleton-row { display: flex; align-items: center; gap: 12px; }
.skeleton-row .skeleton { display: block; }
.skeleton-row .sk-pill { width: 68px; margin-left: auto; height: 22px; border-radius: 11px; }

.thumb-img { border-radius: 10px; object-fit: cover; background: #f2efeb; }
.thumb-img.broken { visibility: hidden; }
.thumb-fallback { display: inline-grid; place-items: center; border-radius: 10px; font-size: .75rem;
  font-weight: 800; color: var(--muted, #6C757D); background: #f2efeb; }

.input.invalid, .invalid { border-color: #c62828 !important; background: #fff6f5; }
.input.invalid:focus { outline-color: #c62828; }
.field-error:not(:empty) { display: block; margin-top: 4px; font-weight: 600; }

.kv.diag dd { word-break: break-word; }
.cell-media { display: flex; align-items: center; gap: 10px; }
.cell-media > span { min-width: 0; }
