/* =====================================================================
   SPOT Sweet Cafe - Management System
   Brand: deep green #154628 / cream #F7F1E1
   ===================================================================== */

:root {
  --green-900: #0d2c1a;
  --green-800: #113a22;
  --green-700: #154628;
  --green-600: #1d5c35;
  --green-500: #2a7a48;
  --green-400: #3d9a5f;
  --green-200: #a8d5ba;
  --green-050: #eaf3ed;

  --cream: #f7f1e1;
  --cream-dark: #ebe2cc;
  --cream-light: #fdfbf5;

  --ink: #1b2420;
  --ink-soft: #4a5a52;
  --ink-faint: #8b9a92;

  --line: #e2e0d5;
  --line-strong: #cfccbc;

  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warn: #a86a00;
  --warn-bg: #fdf3e0;
  --ok: #1d6b3f;
  --ok-bg: #e7f4ec;
  --info: #14607a;
  --info-bg: #e4f2f6;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(21, 70, 40, .06), 0 4px 14px rgba(21, 70, 40, .06);
  --shadow-lg: 0 8px 30px rgba(21, 70, 40, .16);
  --sidebar-w: 252px;
  --topbar-h: 60px;
  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: #f4f5f2;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--green-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --------------------------- Boot splash ---------------------------- */
/* Shown only while a stored session is being verified, so a returning user
   never sees the login card flash past. */
.boot-splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  place-items: center;
  align-content: center;
  gap: 26px;
  background: linear-gradient(150deg, var(--green-800), var(--green-900));
}
.boot-splash img { width: 190px; opacity: .95; }
.boot-bar {
  width: 190px;
  height: 3px;
  border-radius: 2px;
  background: rgba(247, 241, 225, .18);
  overflow: hidden;
}
.boot-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: var(--cream);
  animation: bootSlide 1s ease-in-out infinite;
}
@keyframes bootSlide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Set before first paint by the inline script in index.html. */
html.has-session .login-screen { display: none; }
html.has-session .boot-splash { display: grid; }

/* ------------------------------ Login ------------------------------ */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 600px at 15% -10%, var(--green-600), transparent 60%),
    linear-gradient(150deg, var(--green-800), var(--green-900));
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--cream-light);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

.login-logo {
  display: block;
  width: 168px;
  margin: 0 auto 6px;
  filter: brightness(.28) sepia(1) hue-rotate(85deg) saturate(3);
}

.login-sub {
  text-align: center;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

/* ------------------------------ Shell ------------------------------ */
.app { display: none; min-height: 100vh; }
.app.active { display: block; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--green-700), var(--green-900));
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(247, 241, 225, .12);
}
.sidebar-brand img { width: 118px; display: block; }
.sidebar-brand span {
  display: block;
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: .18em;
  color: rgba(247, 241, 225, .5);
  text-transform: uppercase;
}

.nav { flex: 1; overflow-y: auto; padding: 12px 10px 24px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(247, 241, 225, .18); border-radius: 3px; }

.nav-group {
  margin: 16px 0 6px;
  padding: 0 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(247, 241, 225, .38);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: rgba(247, 241, 225, .82);
  cursor: pointer;
  font-size: 13.5px;
  transition: background .12s, color .12s;
  user-select: none;
}
.nav-item:hover { background: rgba(247, 241, 225, .09); color: var(--cream); text-decoration: none; }
.nav-item.active { background: var(--cream); color: var(--green-800); font-weight: 600; }
.nav-item .ico { width: 17px; text-align: center; flex-shrink: 0; opacity: .9; }
.nav-item .badge-dot {
  margin-left: auto;
  background: #e0574b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar h1 { font-size: 17px; }
.topbar .spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px 5px 5px;
  border-radius: 20px;
  background: var(--green-050);
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--green-700);
  color: var(--cream);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.user-chip .who { line-height: 1.25; }
.user-chip .who b { font-size: 12.5px; display: block; }
.user-chip .who small { font-size: 11px; color: var(--ink-faint); }

.content { padding: 22px 24px 60px; flex: 1; }

/* ------------------------------ Cards ------------------------------ */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, #fff, #fcfcfa);
}
.card-head h3 { font-size: 14.5px; }
.card-head .spacer { flex: 1; }
.card-head .sub { font-size: 12px; color: var(--ink-faint); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1400px) { .grid.c5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1180px) {
  .grid.c4, .grid.c3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
  .grid.c2, .grid.c3, .grid.c4, .grid.c5 { grid-template-columns: 1fr; }
}

/* ------------------------------ Stats ------------------------------ */
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--green-500);
}
.stat.warn::before { background: var(--warn); }
.stat.danger::before { background: var(--danger); }
.stat.info::before { background: var(--info); }
.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-faint);
  font-weight: 600;
}
.stat .value { font-size: 25px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.02em; }
.stat .value.sm { font-size: 20px; }
.stat .meta { font-size: 12px; color: var(--ink-soft); }
.stat .meta .up { color: var(--ok); font-weight: 600; }
.stat .meta .down { color: var(--danger); font-weight: 600; }

/* ------------------------------ Tables ----------------------------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  padding: 8px 12px;
  background: #f8f8f5;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  line-height: 1.25;
  color: var(--ink-soft);
  font-weight: 700;
  /* Headers wrap rather than widen their column. A nowrap header like
     "LATE MINUTES" would otherwise reserve 110px for a single digit and
     squeeze the name columns into four wrapped lines. */
  white-space: normal;
  position: sticky;
  top: 0;
}
table.data td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0efe9;
  vertical-align: middle;
  /* Cells stay on one line so every row is the same height. A wide table
     scrolls sideways inside its card, which reads far better than rows that
     balloon to four wrapped lines. Add class="wrap" to opt a column out. */
  white-space: nowrap;
}
table.data td.wrap, table.data th.wrap { white-space: normal; }
table.data tbody tr:hover { background: #fafaf7; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tfoot td {
  font-weight: 700;
  background: #f8f8f5;
  border-top: 2px solid var(--line-strong);
  border-bottom: none;
}
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--ink-faint); }
.strong { font-weight: 700; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-faint);
}
.empty .big { font-size: 30px; opacity: .35; margin-bottom: 8px; }

/* ----------------------------- Controls ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--green-700);
  color: var(--cream);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, box-shadow .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--green-600); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: #f6f6f2; border-color: var(--ink-faint); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #922019; }
.btn.warn { background: var(--warn); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field label .req { color: var(--danger); }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=email], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(42, 122, 72, .13);
}
input:disabled, select:disabled { background: #f5f5f2; color: var(--ink-faint); }
textarea { resize: vertical; min-height: 62px; }
select { cursor: pointer; }

.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: #fbfbf8;
  border-bottom: 1px solid var(--line);
}
.filters .field { margin: 0; min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 200px; }

/* ------------------------------ Badges ----------------------------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  background: #eee;
  color: #555;
}
.badge.ok, .badge.posted, .badge.received, .badge.completed,
.badge.active, .badge.approved, .badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.warn, .badge.draft, .badge.requested, .badge.in_progress,
.badge.scheduled, .badge.on_leave, .badge.in_transit { background: var(--warn-bg); color: var(--warn); }
.badge.danger, .badge.cancelled, .badge.rejected, .badge.expired,
.badge.terminated, .badge.critical, .badge.void { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* ------------------------------ Modal ------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 44, 26, .48);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 200;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow-lg);
  animation: pop .16s ease-out;
}
.modal.wide { max-width: 1020px; }
.modal.xwide { max-width: 1240px; }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.99); } }

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-head h3 { font-size: 15.5px; flex: 1; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  background: #fbfbf8;
  border-radius: 0 0 12px 12px;
}

/* ------------------------------ Toast ------------------------------ */
#toasts {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.toast {
  background: var(--green-800);
  color: var(--cream);
  padding: 12px 17px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: 420px;
  animation: slide .2s ease-out;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.toast.error { background: #8f1f18; }
.toast.warn { background: #8a5600; }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } }

/* ------------------------------ Misc ------------------------------- */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border-left: 3px solid;
}
.alert.error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.alert.info { background: var(--info-bg); color: var(--info); border-color: var(--info); }

.tabs {
  display: flex;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: #fbfbf8;
  overflow-x: auto;
}
.tab {
  padding: 11px 15px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--green-600); }
.tab.active { color: var(--green-700); border-bottom-color: var(--green-700); }

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--green-050);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress {
  height: 6px;
  background: var(--green-050);
  border-radius: 3px;
  overflow: hidden;
}
.progress span { display: block; height: 100%; background: var(--green-500); }
.progress.warn span { background: var(--warn); }
.progress.danger span { background: var(--danger); }

/* Line/bar chart drawn with plain divs so no chart library is needed. */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 8px; }
.bars .bar {
  flex: 1;
  background: linear-gradient(180deg, var(--green-400), var(--green-600));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  position: relative;
  transition: opacity .12s;
}
.bars .bar:hover { opacity: .75; }
.bars .bar[data-label]:hover::after {
  content: attr(data-label);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green-900);
  color: var(--cream);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  margin-bottom: 5px;
  z-index: 5;
}

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; font-size: 13px; }
.kv dt { color: var(--ink-faint); font-weight: 600; }
.kv dd { margin: 0; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-faint);
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.section-title:first-child { margin-top: 0; }

.line-items th { font-size: 10.5px; }
.line-items td { padding: 6px 8px; }
.line-items input, .line-items select { padding: 6px 8px; font-size: 12.5px; }
.line-items .del {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font-size: 16px; padding: 0 6px;
}

.report-head {
  text-align: center;
  padding: 18px;
  border-bottom: 2px solid var(--green-700);
  margin-bottom: 4px;
}
.report-head h2 { font-size: 19px; color: var(--green-700); }
.report-head .co { font-size: 13px; font-weight: 700; letter-spacing: .05em; }
.report-head .period { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

.total-row td { border-top: 2px solid var(--green-700) !important; font-weight: 700; background: var(--green-050) !important; }
.sub-row td { border-top: 1px solid var(--line-strong) !important; font-weight: 600; background: #fafaf7 !important; }
.indent { padding-left: 30px !important; }

/* =====================================================================
   Print
   Two modes, set by UI.print(): `printing-page` prints the report in the
   content area, `printing-modal` prints only the open dialog (receipts).
   ===================================================================== */
@page {
  size: A4;
  margin: 12mm 10mm;
}

/* A stock movement sheet carries eleven columns of figures. Turning the paper
   keeps them readable; shrinking the type to fit portrait does not. */
@page wide-sheet {
  size: A4 landscape;
  margin: 10mm;
}
body.printing-wide { page: wide-sheet; }

@media print {
  /* Keep the brand tints on totals and headers; browsers drop them by default. */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  html, body { background: #fff; font-size: 10pt; }

  /* Application chrome never belongs on paper. */
  .sidebar, .topbar, .nav, .filters, .tabs, .btn, .btn-row,
  .no-print, #toasts, .menu-toggle, .modal-close, .modal-foot,
  .pos-toolbar, .pos-cats, .pos-pay, .pos-order-head { display: none !important; }

  /* The shell is sized to the viewport on screen. Left alone in print that
     100vh reserves a whole blank page before anything is drawn. */
  .app, .main { min-height: 0 !important; }
  .main { margin-left: 0; display: block; }
  .content { padding: 0; }

  .card {
    box-shadow: none;
    border: none;
    margin: 0 0 8pt;
    break-inside: auto;
  }
  .card-head { border-bottom: 1pt solid #ccc; padding: 0 0 4pt; background: none; }
  .card-body { padding: 0; }

  /* ---- Report header repeats the identity on the first page ---- */
  .report-head { padding: 0 0 8pt; margin-bottom: 8pt; border-bottom: 1.5pt solid var(--green-700); }
  .report-head h2 { font-size: 15pt; }
  .report-head .co { font-size: 11pt; }
  .report-head .period { font-size: 9pt; }

  /* ---- Summary tiles: compact strip instead of full-width blocks ---- */
  .grid { gap: 6pt !important; }
  .grid.c2, .grid.c3, .grid.c4, .grid.c5 {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(90pt, 1fr)) !important;
  }
  .stat {
    padding: 5pt 7pt;
    box-shadow: none;
    border: 0.5pt solid #d5d5cc;
    border-radius: 3pt;
    break-inside: avoid;
  }
  .stat::before { width: 2pt; }
  .stat .label { font-size: 6.5pt; letter-spacing: .04em; }
  .stat .value { font-size: 12pt; margin: 2pt 0 0; }
  .stat .value.sm { font-size: 11pt; }
  .stat .meta { font-size: 7pt; }

  /* ---- Tables carry the substance: keep them tight and unbroken ---- */
  table.data { font-size: 8.5pt; width: 100%; }
  table.data thead { display: table-header-group; }
  table.data tfoot { display: table-footer-group; }
  table.data tr { break-inside: avoid; page-break-inside: avoid; }
  table.data th {
    padding: 4pt 5pt;
    font-size: 6.5pt;
    background: #f0efe9 !important;
    border-bottom: 0.5pt solid #b9b6a8;
    position: static;
  }
  table.data td { padding: 3pt 5pt; border-bottom: 0.4pt solid #e8e6dd; }
  table.data tbody tr:hover { background: none; }
  .table-wrap { overflow: visible !important; }

  .total-row td {
    background: #e9f0eb !important;
    border-top: 1pt solid var(--green-700) !important;
    font-size: 9pt;
  }
  .sub-row td { background: #f7f7f4 !important; }

  .section-title { margin: 10pt 0 4pt; font-size: 8pt; page-break-after: avoid; }

  /* ---- Charts are screen affordances; a printed report wants the figures ---- */
  .bars { height: 45pt; }
  .bars .bar[data-label]:hover::after { display: none; }

  .badge {
    border: 0.4pt solid currentColor;
    padding: 0.5pt 3pt;
    font-size: 7pt;
  }
  .progress { display: none; }
  .kv { font-size: 9pt; }
  .empty { padding: 10pt; font-size: 9pt; }

  a { text-decoration: none; color: inherit; }
  a[href^="#"]::after { content: ""; }

  /* ---- Mode: printing an open dialog (receipt, till summary) ---- */
  /* The whole application shell goes, not just its contents: an empty shell
     still occupies space and pushes the dialog onto a second page. */
  body.printing-modal .app { display: none !important; }
  body.printing-modal .modal-backdrop {
    display: block !important;
    position: static;
    background: none;
    backdrop-filter: none;
    padding: 0;
    overflow: visible;
  }
  body.printing-modal .modal {
    box-shadow: none;
    max-width: 100%;
    animation: none;
  }
  body.printing-modal .modal-head { display: none; }
  body.printing-modal .modal-body {
    max-height: none;
    overflow: visible;
    padding: 0;
  }

  /* ---- Mode: printing the page; any open dialog stays off the paper ---- */
  body.printing-page .modal-backdrop { display: none !important; }

  /* ---- Receipt sized for an 80mm till roll ---- */
  body.printing-receipt .receipt {
    border: none;
    max-width: 72mm;
    margin: 0;
    padding: 0;
    font-size: 9pt;
  }
  body.printing-receipt .receipt-logo { width: 26mm; }
}

/* An 80mm roll needs its own page size, not A4. */
@media print {
  body.printing-receipt { width: 76mm; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }

/* Branch access picker in user administration. */
.branch-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fbfbf8;
}
.branch-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
}
.branch-option:hover { border-color: var(--green-500); }
.branch-option input { width: auto; margin: 0; cursor: pointer; }
.branch-option:has(input:checked) {
  background: var(--green-050);
  border-color: var(--green-500);
  font-weight: 600;
  color: var(--green-800);
}

/* ---------------------------- Product images -------------------------- */
/* Uploads are square-cropped in the browser, so every image is the same
   shape and a missing photo falls back to a lettered tile of equal size. */
.product-img {
  display: block;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--green-050);
}
.product-img-blank {
  display: grid;
  place-items: center;
  color: var(--green-600);
  font-weight: 700;
  letter-spacing: .04em;
  background: linear-gradient(145deg, var(--green-050), #dfeae3);
}

.product-img.thumb { width: 38px; height: 38px; font-size: 12px; }
.product-img.mini { width: 28px; height: 28px; font-size: 10px; flex-shrink: 0; }
.product-img.large { width: 128px; height: 128px; font-size: 34px; border-radius: var(--radius); }

/* Picture control inside the product form. */
.image-editor {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbf8;
}
.image-preview { flex-shrink: 0; }
.image-preview .spinner { margin: 40px; }
.image-actions { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.image-actions p { width: 100%; }

/* Columns that only earn their space on screen. */
@media print {
  .hide-print { display: none !important; }
}

/* -------------------------- Comparison table -------------------------- */
/* Branches sit in columns and metrics in rows, so the eye runs across one
   measure at a time. The metric column stays put while wide tables scroll. */
table.data.cmp .cmp-metric {
  position: sticky;
  left: 0;
  background: #fff;
  font-weight: 600;
  white-space: nowrap;
  z-index: 1;
  border-right: 1px solid var(--line);
}
table.data.cmp thead .cmp-metric { background: #f8f8f5; z-index: 2; }
table.data.cmp .sub-row td { position: static; }

.cmp-hint {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-faint);
  text-transform: none;
  letter-spacing: 0;
}

.cmp-branch { min-width: 130px; text-align: right !important; }
.cmp-branch-name { display: block; font-size: 11.5px; color: var(--ink); }
.cmp-branch-meta {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--ink-faint);
  text-transform: none;
  letter-spacing: 0;
}
.cmp-branch.kitchen .cmp-branch-name { color: var(--ink-faint); }

.cmp-leader { background: var(--ok-bg); font-weight: 700; }
.cmp-best { color: #c9931f; margin-left: 4px; font-size: 11px; }
.cmp-kitchen { color: var(--ink-faint); }

table.data.cmp .cmp-total {
  background: #f8f8f5;
  font-weight: 700;
  border-left: 1px solid var(--line-strong);
}

/* Attendance register: dense inline editing, one row per employee. */
table.data.att-register td { padding: 5px 8px; }
table.data.att-register input,
table.data.att-register select { padding: 5px 7px; font-size: 12.5px; }
table.data.att-register input:disabled { background: #f2f2ee; color: var(--ink-faint); }
table.data.att-register tbody tr:hover { background: #fafaf7; }

/* ---------------------- Monthly attendance sheet ---------------------- */
/* A month per row means many narrow columns; the name column stays put
   while the grid scrolls, and each status keeps a colour of its own. */
table.data.att-sheet { font-size: 11px; }
table.data.att-sheet th,
table.data.att-sheet td { padding: 3px 2px; text-align: center; }

table.data.att-sheet .att-name {
  position: sticky;
  left: 0;
  background: #fff;
  text-align: left;
  white-space: nowrap;
  padding: 4px 10px 4px 8px;
  border-right: 1px solid var(--line);
  z-index: 1;
  min-width: 190px;
}
table.data.att-sheet thead .att-name,
table.data.att-sheet tfoot .att-name { background: #f8f8f5; z-index: 2; }
.att-sub { display: block; font-size: 10px; color: var(--ink-faint); font-weight: 400; }

.att-cell { width: 22px; min-width: 22px; font-weight: 700; }
th.att-cell { font-size: 9.5px; color: var(--ink-faint); }
th.att-restday { color: var(--danger); }

.att-p { background: #e7f4ec; color: #1d6b3f; }
.att-l { background: #fdf3e0; color: #a86a00; }
.att-a { background: #fdecea; color: #b3261e; }
.att-v { background: #e4f2f6; color: #14607a; }
.att-s { background: #eee7f6; color: #5b3f8c; }
.att-h { background: #f0efe9; color: #6b6a5f; }
.att-w { background: #f6f6f2; color: #9a998e; }
.att-none { color: #cfcdc2; font-weight: 400; }

.att-total { min-width: 42px; background: #fbfbf8; font-variant-numeric: tabular-nums; }

.att-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 6px 0 12px;
  font-size: 12px;
  color: var(--ink-soft);
}
.att-legend b {
  display: inline-block;
  width: 20px;
  text-align: center;
  border-radius: 3px;
  margin-right: 4px;
}

/* Space for the signatures the sheet is checked and approved with. */
.att-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
  margin-top: 34px;
  padding-top: 6px;
}
.att-signatures div {
  border-top: 1px solid var(--line-strong);
  padding-top: 6px;
  font-size: 11.5px;
  color: var(--ink-faint);
  text-align: center;
}

@media print {
  /* Squeeze the month onto the page; landscape gives it more room still. */
  table.data.att-sheet { font-size: 6.5pt; }
  table.data.att-sheet th,
  table.data.att-sheet td { padding: 1pt 0; }
  table.data.att-sheet .att-name { min-width: 0; font-size: 7pt; padding: 1pt 4pt; }
  .att-sub { display: none; }
  .att-cell { width: auto; min-width: 0; }
  .att-legend { font-size: 7pt; gap: 8pt; }
  .att-signatures { margin-top: 18pt; }
}
