/* =========================================================================
   Zigo — interface styles
   Tokens first (light, then dark), then base, shell, components, screens,
   print. Colours are only ever used through tokens so both themes work.
   ========================================================================= */

/* ----------------------------- tokens ------------------------------------ */
:root {
  color-scheme: light;
  /* surfaces */
  --bg: #F4F6F5;
  --surface: #FFFFFF;
  --surface-2: #F7F9F8;
  --surface-3: #EEF2F0;
  --overlay: rgba(10, 24, 20, 0.48);
  /* text */
  --text: #16211E;
  --text-2: #33433E;
  --text-muted: #5B6964;
  --text-faint: #687671;
  /* lines */
  --line: #DDE4E1;
  --line-strong: #C3CEC9;
  /* brand: malachite with a saffron spark */
  --brand: #0E6B5A;
  --brand-strong: #0A5447;
  --brand-ink: #FFFFFF;
  --brand-soft: #E2F1EC;
  --brand-text: #0B5C4D;
  --chart-1: #0A8A6E;          /* single-series chart marks (validated vs light surface) */
  --accent: #E39A2D;
  /* status */
  --success: #1F7A4D; --success-soft: #E5F3EB; --success-line: #BFE0CD; --success-ink: #165E3A;
  --warning: #A8640F; --warning-soft: #FCF1DE; --warning-line: #F0D3A2; --warning-ink: #7A4A0B;
  --danger:  #B42318; --danger-soft:  #FCEBE9; --danger-line:  #F4C3BD; --danger-ink:  #8E1C13;
  --info:    #2C64A6; --info-soft:    #E8F0FA; --info-line:    #C3D6EE; --info-ink:    #1F4C80;
  /* shape & depth */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(16, 33, 29, 0.06);
  --shadow-2: 0 10px 30px rgba(16, 33, 29, 0.14);
  --focus: 0 0 0 3px rgba(14, 107, 90, 0.28);
  /* type */
  --font-ui: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Public Sans', system-ui, sans-serif;
  /* layout */
  --sidebar-w: 248px;
  --rail-w: 72px;
  --topbar-h: 64px;
  --content-pad: 28px;
  --content-max: 1280px;

  /* names used by older inline styles in the screens */
  --ink: var(--text);
  --ink-soft: var(--text-2);
  --paper: var(--bg);
  --paper-card: var(--surface);
  --rust: var(--brand);
  --rust-dark: var(--brand-strong);
  --green: var(--success);
  --amber: var(--warning);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0D1412;
  --surface: #141D1A;
  --surface-2: #18231F;
  --surface-3: #1E2B27;
  --overlay: rgba(0, 0, 0, 0.6);
  --text: #E3EBE8;
  --text-2: #C3D0CB;
  --text-muted: #93A39D;
  --text-faint: #879690;
  --line: #26342F;
  --line-strong: #35463F;
  --brand: #3CC7A3;
  --brand-strong: #63D7B8;
  --brand-ink: #062019;
  --brand-soft: rgba(60, 199, 163, 0.14);
  --brand-text: #6FDCBF;
  --chart-1: #1FA383;          /* validated vs dark surface */
  --accent: #F2B45A;
  --success: #4CC38A; --success-soft: rgba(76, 195, 138, 0.14); --success-line: rgba(76, 195, 138, 0.35); --success-ink: #7FD9AC;
  --warning: #E8B04B; --warning-soft: rgba(232, 176, 75, 0.14); --warning-line: rgba(232, 176, 75, 0.35); --warning-ink: #F1C778;
  --danger:  #F0705F; --danger-soft:  rgba(240, 112, 95, 0.14); --danger-line:  rgba(240, 112, 95, 0.38); --danger-ink:  #F59A8D;
  --info:    #6FA8E8; --info-soft:    rgba(111, 168, 232, 0.14); --info-line:    rgba(111, 168, 232, 0.35); --info-ink:    #9CC4F0;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 12px 34px rgba(0, 0, 0, 0.55);
  --focus: 0 0 0 3px rgba(60, 199, 163, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0D1412;
    --surface: #141D1A;
    --surface-2: #18231F;
    --surface-3: #1E2B27;
    --overlay: rgba(0, 0, 0, 0.6);
    --text: #E3EBE8;
    --text-2: #C3D0CB;
    --text-muted: #93A39D;
    --text-faint: #879690;
    --line: #26342F;
    --line-strong: #35463F;
    --brand: #3CC7A3;
    --brand-strong: #63D7B8;
    --brand-ink: #062019;
    --brand-soft: rgba(60, 199, 163, 0.14);
    --brand-text: #6FDCBF;
    --chart-1: #1FA383;
    --accent: #F2B45A;
    --success: #4CC38A; --success-soft: rgba(76, 195, 138, 0.14); --success-line: rgba(76, 195, 138, 0.35); --success-ink: #7FD9AC;
    --warning: #E8B04B; --warning-soft: rgba(232, 176, 75, 0.14); --warning-line: rgba(232, 176, 75, 0.35); --warning-ink: #F1C778;
    --danger:  #F0705F; --danger-soft:  rgba(240, 112, 95, 0.14); --danger-line:  rgba(240, 112, 95, 0.38); --danger-ink:  #F59A8D;
    --info:    #6FA8E8; --info-soft:    rgba(111, 168, 232, 0.14); --info-line:    rgba(111, 168, 232, 0.35); --info-ink:    #9CC4F0;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 12px 34px rgba(0, 0, 0, 0.55);
    --focus: 0 0 0 3px rgba(60, 199, 163, 0.35);
  }
}

/* ------------------------------ base ------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--text); margin: 0; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 600; }
h4 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 10px; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, video, canvas { max-width: 100%; }
hr { border: none; border-top: 1px solid var(--line); }
::selection { background: var(--brand-soft); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

/* figures line up in columns; no monospace needed */
.mono, .num, td.num, th.num, .stat-value, .invoice-no, .totals-box .row span:last-child {
  font-variant-numeric: tabular-nums;
}
.mono { letter-spacing: 0.01em; }
.num, td.num, th.num { text-align: right; }
.muted { color: var(--text-muted); font-weight: 400; font-size: 13px; }
.opt { font-weight: 400; color: var(--text-faint); }
.ok-text { color: var(--success); }
.error-text { color: var(--danger) !important; font-weight: 600; }
.low-stock-tag { color: var(--danger); font-weight: 700; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--brand); color: var(--brand-ink); padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: 12px; text-decoration: none; }

/* ------------------------------ logo ------------------------------------- */
.zigo-logo { display: block; height: 32px; width: auto; color: var(--text); }
.zigo-tile { fill: #0E6B5A; }
.zigo-spark { fill: #E39A2D; }

/* ------------------------------ shell ------------------------------------ */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  padding: 0 0 24px;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.brand-link { display: flex; align-items: center; color: var(--text); }
.brand-link:hover { text-decoration: none; }
.brand .brand-full { height: 30px; }
.brand .brand-mark { height: 32px; display: none; }
.sidebar-close {
  display: none; margin-left: auto;
  width: 40px; height: 40px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  align-items: center; justify-content: center;
}
.sidebar-close svg { width: 22px; height: 22px; }
.sidebar-close:hover { background: var(--surface-3); color: var(--text); }

.nav { display: flex; flex-direction: column; padding: 0 12px; }
.nav-group + .nav-group { margin-top: 6px; }
.nav-group-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 10px 10px 6px;
  background: none; border: none; cursor: pointer;
  font-family: inherit; text-align: left; border-radius: var(--radius-sm);
}
.nav-group-label { font-size: 12px; font-weight: 600; color: var(--text-faint); white-space: nowrap; letter-spacing: 0.01em; }
.nav-group-toggle:hover .nav-group-label { color: var(--text-muted); }
.nav-chevron { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-faint); transition: transform .18s ease; }
.nav-group.is-collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-group.is-collapsed .nav-group-items { display: none; }

.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  color: var(--text-2);
  padding: 8px 10px; min-height: 38px;
  border-radius: var(--radius-sm);
  font-weight: 500; font-size: 14px;
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.nav-link.is-active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--accent);
}
.nav-icon { width: 19px; height: 19px; flex-shrink: 0; color: var(--text-muted); }
.nav-link:hover .nav-icon { color: var(--text-2); }
.nav-link.is-active .nav-icon { color: var(--brand-text); }
.nav-text { overflow: hidden; text-overflow: ellipsis; }

.nav-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--topbar-h);
  padding: 0 var(--content-pad);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
@supports (backdrop-filter: blur(4px)) {
  .topbar { background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); }
}
.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo { display: none; }
.topbar-logo .zigo-logo { height: 30px; }
.page-title { font-size: 20px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-end { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.nav-toggle { margin-left: -8px; color: var(--text-2); }

.theme-switch { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.theme-switch .icon-btn { width: 30px; height: 30px; border-radius: 999px; }
.theme-switch .icon-btn svg { width: 17px; height: 17px; }
.theme-switch .icon-btn[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 3px 4px 3px 3px; min-width: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: var(--brand-ink);
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-name { font-weight: 600; font-size: 13.5px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 12px; color: var(--text-muted); }

.content { padding: 24px var(--content-pad) 48px; width: 100%; max-width: var(--content-max); flex: 1; }
.content:focus { outline: none; }

/* desktop: collapsed icon rail */
@media (min-width: 992px) {
  html.sidebar-collapsed .sidebar { width: var(--rail-w); scrollbar-width: none; }
  html.sidebar-collapsed .sidebar::-webkit-scrollbar { display: none; }
  html.sidebar-collapsed .brand { padding: 0; justify-content: center; }
  html.sidebar-collapsed .brand .brand-full { display: none; }
  html.sidebar-collapsed .brand .brand-mark { display: block; }
  html.sidebar-collapsed .nav-text,
  html.sidebar-collapsed .nav-group-label,
  html.sidebar-collapsed .nav-chevron {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  html.sidebar-collapsed .nav-group.is-collapsed .nav-group-items { display: block; }
  html.sidebar-collapsed .nav-group-toggle {
    height: 9px; padding: 0; margin: 4px 0; cursor: default; pointer-events: none;
    border-top: 1px solid var(--line); border-radius: 0;
  }
  html.sidebar-collapsed .nav-group:first-child .nav-group-toggle { border-top: none; }
  html.sidebar-collapsed .nav-link { justify-content: center; padding: 10px 0; }
  html.sidebar-collapsed .nav-icon { width: 21px; height: 21px; }
  html.sidebar-collapsed .nav-link::after {
    content: attr(data-label);
    position: fixed; left: calc(var(--rail-w) + 8px); top: var(--tip-y, -100px);
    transform: translate(-4px, -50%);
    background: var(--text); color: var(--bg);
    padding: 6px 10px; border-radius: var(--radius-sm);
    font-size: 12.5px; font-weight: 500; white-space: nowrap;
    box-shadow: var(--shadow-2);
    opacity: 0; pointer-events: none; z-index: 60;
    transition: opacity .12s ease, transform .12s ease;
  }
  html.sidebar-collapsed .nav-link:hover::after,
  html.sidebar-collapsed .nav-link:focus-visible::after { opacity: 1; transform: translate(0, -50%); }
  html.nav-ready .sidebar { transition: width .2s ease; }
}

/* phones & tablets: slide-in drawer */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(296px, 86vw); height: auto;
    transform: translateX(-100%); visibility: hidden;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 60;
  }
  .brand { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-2); }
  html.nav-ready .sidebar { transition: transform .24s ease, visibility .24s; }
  .sidebar-close { display: inline-flex; }
  .nav-link { min-height: 44px; }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: var(--overlay); }
  .nav-backdrop[hidden] { display: none; }
  body.nav-open { overflow: hidden; }
  .topbar-logo { display: inline-flex; }
  html:not(.js) .sidebar { position: static; transform: none; visibility: visible; width: 100%; height: auto; }
  html:not(.js) .app-shell { flex-direction: column; }
  html:not(.js) .nav-toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html.nav-ready .sidebar, .nav-chevron, .nav-link::after, .scan-bar span { transition: none !important; }
}

/* ----------------------------- cards ------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-1);
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: 14px; }
.card h3 { font-size: 16.5px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head h3 { font-size: 17px; }
.section-sub { color: var(--text-muted); font-size: 13px; font-weight: 400; font-family: var(--font-ui); }
.section-note { margin: -4px 0 16px; color: var(--text-2); line-height: 1.6; }
.sub-head { font-size: 15px; margin: 8px 0 10px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-inline { color: var(--text-muted); padding: 10px 0 14px; }

/* action bar above invoice / order documents */
.doc-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.doc-actions > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* invoices and orders are white paper in both themes */
.doc-paper {
  --surface: #FFFFFF; --surface-2: #F7F8F7; --surface-3: #EFF1F0;
  --text: #1A1F1D; --text-2: #3A4441; --text-muted: #5E6865; --text-faint: #687671;
  --line: #DCE1DF; --line-strong: #BFC7C3;
  --brand-text: #0B5C4D;
  color: var(--text);
  background: #FFFFFF;
  border-color: var(--line);
  color-scheme: light;
}
.doc-paper table tr:hover td { background: transparent; }

/* ----------------------------- buttons ----------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit; font-weight: 600; font-size: 14px; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-muted); padding-left: 10px; padding-right: 10px; }
.btn-ghost:hover { color: var(--text); background: var(--surface-3); }
.btn-danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.inline-form { display: inline; }
.link-btn { background: none; border: none; padding: 0 0 0 8px; color: var(--brand-text); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.remove-row-btn { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: var(--radius-sm); }
.remove-row-btn:hover { background: var(--danger-soft); }

/* ------------------------------ forms ------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
.form-group { margin-bottom: 14px; display: flex; flex-direction: column; min-width: 0; }
.form-group.full { grid-column: 1 / -1; }
label, .label { font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--text-2); }
.label { display: block; }
.field-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; line-height: 1.45; }

input, select, textarea {
  max-width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14.5px; line-height: 1.3;
  background-color: var(--surface);
  color: var(--text);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.form-group > input, .form-group > select, .form-group > textarea { width: 100%; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input[readonly] { background-color: var(--surface-2); color: var(--text-muted); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--surface-3); color: var(--text-faint); cursor: not-allowed; }
textarea { resize: vertical; min-height: 76px; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%238A9893' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input[type="file"] { padding: 6px; min-height: 0; font-size: 13px; cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); padding: 6px 12px; margin-right: 10px; cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--brand); padding: 0; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text); cursor: pointer; }
.checkbox-row input { width: 18px; flex-shrink: 0; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 24px; }
.form-error { color: var(--danger); font-weight: 600; }

/* ----------------------- filter bar / list toolbar ----------------------- */
.toolbar {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar > div:empty { display: none; }
.search-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; flex: 1 1 520px; }
.search-row > input[type="text"], .search-row > input[type="search"], .search-row > input:not([type]) { flex: 1 1 220px; min-width: 0; }
.search-row label { margin-bottom: 0; }
.list-summary { margin: -4px 0 12px; color: var(--text-muted); font-size: 13.5px; }
.list-summary strong, .list-summary .mono { color: var(--text); }
.list-summary .sep { margin: 0 6px; color: var(--line-strong); }

.date-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand-text); text-decoration: none; }
.chip.is-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.date-range { display: flex; gap: 8px; flex-wrap: wrap; }
.date-field { display: inline-flex; flex-direction: column; gap: 4px; margin: 0; font-weight: 600; font-size: 12.5px; color: var(--text-muted); }
.date-field > span { white-space: nowrap; }

/* ------------------------------ tables ----------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th {
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}
th.num, td.num { text-align: right; }
thead th:first-child { border-top-left-radius: var(--radius-sm); }
thead th:last-child { border-top-right-radius: var(--radius-sm); }
tbody tr:last-child td { border-bottom-color: transparent; }
tbody tr:hover td { background: var(--surface-2); }
td .btn-sm + .btn-sm, td .btn-sm + form, td form + .btn-sm, td form + form { margin-left: 4px; }
.grid-table th, .grid-table td { padding: 6px 6px; font-size: 12.5px; }

/* --------------------------- status & badges ----------------------------- */
.stamp {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.35;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
  text-transform: capitalize;
}
.stamp::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.stamp-paid { background: var(--success-soft); color: var(--success-ink); }
.stamp-unpaid { background: var(--danger-soft); color: var(--danger-ink); }
.stamp-partial { background: var(--warning-soft); color: var(--warning-ink); }
.stamp-cancelled { background: var(--surface-3); color: var(--text-muted); }
.stamp-issued { background: var(--info-soft); color: var(--info-ink); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge-role { background: var(--brand-soft); color: var(--brand-text); text-transform: capitalize; }
.badge-extra { background: var(--warning-soft); color: var(--warning-ink); }
.src-tag { display: inline-block; font-size: 12px; color: var(--text-2); background: var(--surface-3); border-radius: 4px; padding: 1px 7px; margin-top: 3px; white-space: nowrap; }
.src-tag.is-online { background: var(--info-soft); color: var(--info-ink); }
.pax-pill { background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 4px 12px; font-size: 13px; }

/* ------------------------------ alerts ----------------------------------- */
.alert {
  padding: 12px 14px 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 500;
  border: 1px solid var(--warning-line);
  border-left: 4px solid var(--warning);
  background: var(--warning-soft); color: var(--warning-ink);
}
.alert-success { background: var(--success-soft); color: var(--success-ink); border-color: var(--success-line); border-left-color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-line); border-left-color: var(--danger); }
.alert-warn { margin: 12px 0 0; }

/* --------------------------- dashboard stats ----------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px 15px;
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.stat-label { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; overflow-wrap: anywhere; line-height: 1.15; }
a.stat-card:hover { border-color: var(--brand); text-decoration: none; }

/* --------------------------- invoices & totals --------------------------- */
.line-items-table { min-width: 760px; }
.line-items-table input, .line-items-table select { width: 100%; min-height: 36px; padding: 7px 9px; font-size: 14px; }
.line-items-table select { padding-right: 28px; }
.line-items-table td { vertical-align: top; padding: 8px 6px; }
.totals-box { margin-left: auto; width: 340px; max-width: 100%; }
.totals-box .row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; color: var(--text-2); }
.totals-box .row.grand { border-top: 2px solid var(--text); font-weight: 700; font-size: 17px; padding-top: 10px; margin-top: 6px; color: var(--text); }
.totals-box .row.muted-row { color: var(--text-muted); font-size: 13px; }
.invoice-header { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 2px solid var(--text); }
.invoice-no { font-size: 22px; font-weight: 700; color: var(--brand-text); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 24px; margin-bottom: 20px; }
.two-col > *, .form-grid > *, .stat-grid > *, .form-group > * { min-width: 0; }
.address-block h3 { font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.quick-add-select { min-width: 320px; max-width: 100%; margin-left: 8px; }

/* modal dialogs (payment etc.) */
[id$="Modal"] { padding: 16px; background: var(--overlay) !important; z-index: 70 !important; }
[id$="Modal"] > .card { box-shadow: var(--shadow-2); width: 420px !important; max-height: calc(100vh - 32px); overflow: auto; margin: 0; }

/* ----------------------------- booking form ------------------------------ */
.suggest-wrap { position: relative; }
.suggest-box {
  position: absolute; z-index: 30; left: 0; right: 0; top: 70px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-2); max-height: 300px; overflow: auto;
}
.suggest-opt { display: block; width: 100%; text-align: left; padding: 10px 12px; border: none; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.suggest-opt:hover, .suggest-opt:focus { background: var(--surface-3); outline: none; }
.suggest-opt span { display: block; font-size: 12.5px; color: var(--text-muted); }
.suggest-empty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; }

.guest-card, .room-row {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 6px; margin-bottom: 12px; background: var(--surface-2);
}
.guest-card.is-extra { border-left: 4px solid var(--warning); }
.room-row.is-clash { border-color: var(--danger); background: var(--danger-soft); }
.guest-card-head, .room-row-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.guest-card-title { margin: 0; font-size: 15px; }
.guest-remove { margin-left: auto; color: var(--danger); }
.room-row-title { font-weight: 700; color: var(--text); font-family: var(--font-display); }
.room-occ { font-size: 12.5px; color: var(--text-muted); }
.room-row-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr); gap: 0 14px; }
.room-row-grid select, .room-row-grid input { width: 100%; min-width: 0; }
.room-row-foot { font-size: 12.5px; min-height: 18px; padding-bottom: 6px; }
.early-box { border-top: 1px dashed var(--line); padding: 10px 0 4px; margin-top: 2px; }
.early-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 0 14px; margin-top: 10px; }
.early-grid input { width: 100%; min-width: 0; }
.early-calc { grid-column: 1 / -1; font-size: 13px; color: var(--text-muted); min-height: 18px; padding-bottom: 8px; }
.early-calc strong { color: var(--text); }
.early-calc.is-error { color: var(--danger); }
.room-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.room-assign { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.room-assign select { min-height: 34px; padding: 5px 30px 5px 10px; font-size: 13.5px; max-width: 200px; }
.section-head .room-assign { margin-left: auto; }
.stay-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.inline-select select { min-height: 32px; padding: 4px 30px 4px 10px; font-size: 14px; }

.file-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 4px 0 10px; }
.file-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.file-label { margin: 0; }
.file-field input[type="file"] { width: 100%; }
.file-thumb { display: block; width: 100%; max-width: 240px; height: 120px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-3); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb.is-new { outline: 2px solid var(--success); outline-offset: 1px; }
.file-thumb-pdf { display: flex; align-items: center; justify-content: center; height: 100%; font-weight: 700; color: var(--danger); }
.file-hint { font-size: 12px; color: var(--text-muted); }

.scan-status { margin: 4px 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; line-height: 1.5; }
.scan-status.is-ok { background: var(--success-soft); border-color: var(--success-line); color: var(--success-ink); }
.scan-status.is-error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger-ink); }
.scan-bar { display: block; height: 4px; margin-top: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.scan-bar span { display: block; height: 100%; background: var(--brand); transition: width .2s ease; }
.scan-conflicts { margin-top: 6px; color: var(--warning-ink); }
.scan-conflicts .btn { margin-left: 6px; }
.scan-note { margin-top: 4px; font-size: 12.5px; opacity: .85; }
input.scanned, select.scanned, textarea.scanned { background-color: var(--success-soft); border-color: var(--success-line); }

.extra-charge { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 4px 0 10px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.extra-charge label { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.extra-charge input { width: 170px; }
.extra-charge-total { color: var(--text-2); padding-bottom: 10px; font-size: 13.5px; }

.bill-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.bill-grid .totals-box { width: 100%; margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }

/* segmented choices: inspection OK/Issue/N/A, booking channel */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg-opt { position: relative; margin: 0; font-weight: 600; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt span { display: inline-block; padding: 6px 12px; min-width: 54px; text-align: center; }
.seg-opt + .seg-opt span { border-left: 1px solid var(--line-strong); }
.seg-opt input:focus-visible + span { box-shadow: inset var(--focus); }
.seg-ok input:checked + span { background: var(--success); color: #fff; }
.seg-issue input:checked + span { background: var(--danger); color: #fff; }
.seg-na input:checked + span { background: var(--text-faint); color: #fff; }
.seg-wide { display: flex; width: 100%; border-radius: var(--radius-sm); }
.seg-wide .seg-opt { flex: 1; }
.seg-wide .seg-opt span { display: block; padding: 10px 12px; font-size: 13.5px; }
.seg-channel input:checked + span, .seg-pick input:checked + span { background: var(--brand); color: var(--brand-ink); }
#booking_source_other { margin-top: 8px; }

details.insp { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; background: var(--surface); }
details.insp > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; cursor: pointer; list-style: none; font-weight: 600; color: var(--text); }
details.insp > summary::-webkit-details-marker { display: none; }
details.insp > summary::before { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(-45deg); margin-right: 6px; transition: transform .15s; }
details.insp[open] > summary::before { transform: rotate(45deg); }
details.insp[open] > summary { border-bottom: 1px solid var(--line); }
.insp-title { flex: 1; }
.insp-progress { font-weight: 500; font-size: 13px; color: var(--text-muted); }
details.insp > :not(summary) { margin-left: 16px; margin-right: 16px; }
details.insp[open] { padding-bottom: 12px; }
.insp-meta { font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.insp-actions { display: flex; gap: 8px; margin-top: 12px; margin-bottom: 6px; }
.insp-list { list-style: none; padding: 0; }
.insp-item { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 220px); align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.insp-item.has-issue { background: var(--danger-soft); margin: 0 -16px; padding: 8px 16px; }
.insp-label { font-size: 14px; }
.insp-note { min-height: 34px; padding: 6px 10px; font-size: 13.5px; width: 100%; }

.history-list { list-style: none; margin: 0; padding: 0; }
.history-item { position: relative; padding: 10px 0 14px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.history-item::before { content: ''; position: absolute; left: -7px; top: 15px; width: 12px; height: 12px; border-radius: 50%; background: var(--line-strong); border: 2px solid var(--surface); }
.history-created::before { background: var(--success); }
.history-updated::before { background: var(--warning); }
.history-payment::before { background: var(--info); }
.history-cancelled::before { background: var(--danger); }
.history-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; color: var(--text-muted); }
.history-action { font-weight: 700; font-size: 12.5px; color: var(--text-2); text-transform: capitalize; }
.history-who { font-weight: 600; color: var(--text); }
.history-summary { margin-top: 3px; line-height: 1.55; }
.history-details { margin-top: 6px; }
.history-details summary { cursor: pointer; font-size: 13px; color: var(--brand-text); font-weight: 600; }
.history-details table { margin-top: 6px; }
.history-details td { font-size: 13px; vertical-align: top; }

.kyc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.kyc-person { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface-2); min-width: 0; }
.kyc-name { margin-bottom: 2px; }
.kyc-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; overflow-wrap: anywhere; }
.kyc-files { display: flex; gap: 8px; flex-wrap: wrap; }
.kyc-file { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 86px; font-size: 11.5px; color: var(--text-muted); text-decoration: none; }
.kyc-file img, .kyc-file .file-thumb-pdf { width: 86px; height: 64px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-3); }

/* ------------------------------ sign in ---------------------------------- */
.login-page { min-height: 100vh; min-height: 100dvh; margin: 0; background: var(--bg); }
.login-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.login-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 24px;
  padding: 56px clamp(32px, 6vw, 88px);
  background: #0B3B32;
  color: #E7F2EE;
}
/* the Z from the logo, oversized and faint, as a quiet backdrop */
.login-brand::after {
  content: ''; position: absolute; right: -14%; bottom: -18%; width: 78%; aspect-ratio: 1;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M12 13.5h15.5L12.5 27h15' fill='none' stroke='%23ffffff' stroke-opacity='0.06' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  pointer-events: none;
}
.login-logo { height: 54px; width: auto; align-self: flex-start; color: #F4FAF7; }
.login-logo .zigo-tile { fill: #12806B; }
.login-tagline { font-family: var(--font-display); font-size: clamp(26px, 3vw, 38px); font-weight: 700; line-height: 1.15; max-width: 16ch; margin: 0; color: #FFFFFF; letter-spacing: -0.02em; }
.login-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; color: #BFD9D1; font-size: 15px; }
.login-points li { display: flex; gap: 12px; align-items: center; }
.login-points li::before { content: ''; width: 8px; height: 8px; flex-shrink: 0; transform: rotate(45deg); background: #E39A2D; border-radius: 1px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 400px; }
.login-logo-small { display: none; height: 40px; width: auto; margin-bottom: 28px; }
.login-title { font-size: 28px; margin-bottom: 6px; }
.login-sub { color: var(--text-muted); margin-bottom: 22px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form .btn { min-height: 46px; font-size: 15px; margin-top: 6px; }
.login-form input { min-height: 46px; }
.password-wrap { position: relative; }
.password-wrap input { width: 100%; padding-right: 70px; }
.password-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: transparent; color: var(--brand-text); font: inherit; font-weight: 600; font-size: 13px; padding: 6px 8px; cursor: pointer; border-radius: var(--radius-sm); }
.password-toggle:hover { background: var(--surface-3); }
.login-hint { margin-top: 18px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

/* ---------------------------- responsive --------------------------------- */
@media (max-width: 1100px) {
  :root { --content-pad: 22px; }
  .user-meta { display: none; }
}
@media (max-width: 900px) {
  .form-grid, .two-col { grid-template-columns: minmax(0, 1fr); }
  .bill-grid { grid-template-columns: minmax(0, 1fr); }
  .stay-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-shell { grid-template-columns: minmax(0, 1fr); }
  .login-brand { display: none; }
  .login-logo-small { display: block; }
}
@media (max-width: 767.98px) {
  :root { --content-pad: 16px; --topbar-h: 58px; }
  body { font-size: 15px; }
  .content { padding-top: 16px; padding-bottom: 36px;
             padding-left: max(var(--content-pad), env(safe-area-inset-left));
             padding-right: max(var(--content-pad), env(safe-area-inset-right)); }
  .topbar { gap: 6px; }
  .page-title { font-size: 17px; }
  .theme-switch { display: none; }
  .topbar-end { gap: 4px; }
  .user-chip { padding: 0; }
  .avatar { width: 32px; height: 32px; }
  .card { padding: 16px; border-radius: var(--radius); margin-bottom: 14px; }
  h2 { font-size: 18px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 13px 13px 12px; }
  .stat-label { font-size: 12.5px; }
  .stat-value { font-size: 19px; }
  /* 16px stops iOS zooming into fields */
  input, select, textarea { font-size: 16px; min-height: 44px; }
  .line-items-table input, .line-items-table select { font-size: 14px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .toolbar { align-items: stretch; }
  .toolbar > div { width: 100%; }
  .toolbar > div > .btn { flex: 1 1 auto; }
  .search-row { flex-basis: 100%; }
  .search-row > input, .search-row > select { flex: 1 1 150px; min-width: 0; }
  .search-row > .btn { flex: 1 1 100%; }
  .date-presets { flex-wrap: nowrap; overflow-x: auto; margin-left: calc(-1 * var(--content-pad)); margin-right: calc(-1 * var(--content-pad)); padding: 0 var(--content-pad) 2px; scrollbar-width: none; }
  .date-presets::-webkit-scrollbar { display: none; }
  .chip { padding: 8px 14px; }
  .date-range { width: 100%; }
  .date-range .date-field, .search-row > .date-field { flex: 1 1 140px; }
  .date-field input, .date-field select { width: 100%; }
  form[style*="display:flex"], div[style*="display:flex"] { flex-wrap: wrap; }
  .totals-box { width: 100%; }
  .invoice-no { font-size: 19px; }
  .quick-add-select { min-width: 0; width: 100%; margin: 6px 0 0; }
  .doc-actions > div { width: 100%; }
  .doc-actions > div > .btn, .doc-actions > div > form { flex: 1 1 auto; }
  .doc-actions > div > form .btn { width: 100%; }

  /* data tables become a stack of cards, each value labelled */
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td { display: block; width: 100%; }
  table.stack-sm thead { display: none; }
  table.stack-sm tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack-sm tbody tr:last-child { border-bottom: none; }
  table.stack-sm tr:hover td { background: transparent; }
  table.stack-sm td { border: none; padding: 4px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 14px; text-align: right; }
  table.stack-sm td::before { content: attr(data-label); flex-shrink: 0; color: var(--text-muted); font-size: 13px; font-weight: 500; text-align: left; }
  table.stack-sm td:first-child { font-weight: 600; font-size: 15px; }
  table.stack-sm td.cell-actions { justify-content: flex-start; gap: 8px; flex-wrap: wrap; padding-top: 8px; }
  table.stack-sm td.cell-actions::before { display: none; }
  table.stack-sm td[colspan] { display: block; text-align: left; }
  table.stack-sm td[colspan]::before { display: none; }
  table.stack-sm td > br { display: none; }
  .table-wrap > table:not(.stack-sm):has(> thead) { min-width: 620px; }

  .file-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .file-grid .file-field:first-child { grid-column: 1 / -1; }
  .file-thumb { max-width: none; height: 110px; }
  .insp-item { grid-template-columns: minmax(0, 1fr) auto; }
  .insp-item .insp-note { grid-column: 1 / -1; }
  .seg-opt span { padding: 8px 11px; min-width: 46px; }
  .guest-card, .room-row { padding: 12px 12px 4px; }
  .extra-charge input { width: 100%; }
  .extra-charge label { flex: 1 1 100%; }
  .room-row-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .room-row-grid .form-group:first-child { grid-column: 1 / -1; }
  .early-grid { grid-template-columns: minmax(0, 1fr); }
  .room-assign select { max-width: 160px; }
  .stay-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  [id$="Modal"] { align-items: flex-end !important; padding: 0; }
  [id$="Modal"] > .card { width: 100% !important; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
}
@media (max-width: 380px) {
  .stat-value { font-size: 17px; }
  .file-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (pointer: coarse) {
  .icon-btn { width: 42px; height: 42px; }
  .theme-switch .icon-btn { width: 34px; height: 34px; }
}

/* -------------------------------- print ---------------------------------- */
@media print {
  .sidebar, .topbar, .no-print, .nav-toggle, .nav-backdrop, .skip-link, .doc-actions, .alert { display: none !important; }
  body { background: #fff; color: #000; }
  .main, .content { padding: 0; margin: 0; max-width: none; }
  .card { box-shadow: none; border: none; padding: 0; }
  .table-wrap { overflow: visible !important; }
  .table-wrap > table { min-width: 0 !important; }
  table.stack-sm thead { display: table-header-group !important; }
}

/* ----------------------------- page intro -------------------------------- */
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.page-intro-title { font-size: 24px; }
.page-intro-sub { color: var(--text-muted); margin: 2px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-foot { margin-top: 6px; font-size: 12.5px; color: var(--text-muted); }
.stat-of { font-size: 0.65em; color: var(--text-muted); font-weight: 600; }
a.stat-card { color: inherit; display: block; transition: border-color .12s ease; }
.stat-card-warn .stat-value { color: var(--warning-ink); }
.stat-card-alert .stat-value { color: var(--danger); }
.meter { margin-top: 10px; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.card-attention { border-left: 4px solid var(--accent); }
.count-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px; padding: 0 7px; margin-left: 6px; border-radius: 999px; background: var(--accent); color: #2B1A02; font-family: var(--font-ui); font-size: 12.5px; font-weight: 700; vertical-align: 2px; }
.table-caption { font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 4px 0 8px; }
table.spaced { margin-bottom: 18px; }
@media (max-width: 767.98px) {
  .page-intro { align-items: stretch; }
  .page-intro-title { font-size: 20px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 calc(50% - 8px); }
}

/* theme choice inside the phone menu */
.sidebar-foot { display: none; padding: 16px 18px 0; margin-top: 12px; border-top: 1px solid var(--line); }
.sidebar-foot-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-faint); margin-bottom: 8px; }
.theme-switch-wide { display: flex; width: 100%; border-radius: var(--radius-sm); }
.theme-switch-wide .icon-btn { flex: 1; width: auto; height: 36px; border-radius: 5px; font: inherit; font-size: 13px; font-weight: 600; }
@media (max-width: 767.98px) {
  .sidebar-foot { display: block; }
  /* the first column is the card's heading */
  table.stack-sm td:first-child { justify-content: flex-start; text-align: left; font-size: 16px; padding-bottom: 6px; }
  table.stack-sm td:first-child::before { display: none; }
}

/* list pages on phones: actions first, extra filters folded away */
.filter-toggle { display: none; }
@media (max-width: 767.98px) {
  .toolbar > div:last-child:not(:first-child) { order: -1; }
  .filter-toggle { display: inline-flex; flex: 0 0 auto; order: 2; }
  .search-row > input[type="text"], .search-row > input[type="search"] { order: 1; }
  .search-row.filters-collapsed > :not(input[type="text"]):not(input[type="search"]):not(.filter-toggle):not(input[type="hidden"]) { display: none; }
  .search-row.filters-collapsed > input[type="text"], .search-row.filters-collapsed > input[type="search"] { flex: 1 1 0; }
  .search-row:not(.filters-collapsed) > :not(.filter-toggle) { order: 3; }
  .search-row:not(.filters-collapsed) > input[type="text"] { order: 1; }
  .search-row.filters-collapsed .btn[type="submit"] { display: none; }
}
@media (max-width: 767.98px) {
  .toolbar > .btn:last-child { order: -1; flex: 1 1 100%; }
  table.stack-sm td > .cell-v { min-width: 0; }
  table.stack-sm td.cell-actions > .cell-v { display: flex; flex-wrap: wrap; gap: 8px; }
  table.stack-sm td.cell-actions > .cell-v .btn-sm + .btn-sm, table.stack-sm td.cell-actions > .cell-v form { margin-left: 0; }
}

/* =====================================================================
   Room booking invoice — matches the hotel's printed format and the PDF
   (src/utils/pdfHotelInvoice.js). Sizes are the PDF's points x 1.333.
   ===================================================================== */
@font-face { font-family: 'Zigo Invoice'; src: url('/fonts/Inter-Regular.woff') format('woff'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Zigo Invoice'; src: url('/fonts/Inter-Bold.woff') format('woff'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Zigo Invoice Serif'; src: url('/fonts/PlayfairDisplay-Regular.woff') format('woff'); font-weight: 400; font-display: swap; }

.hotel-doc {
  --hd-gold: #C89116;
  max-width: 794px; margin-left: auto; margin-right: auto;
  padding: 16px 0 26px;
  font-family: 'Zigo Invoice', 'Public Sans', Arial, sans-serif;
  font-size: 14.6px; line-height: 1.38; color: #111;
  display: flex; flex-direction: column;
}
.hotel-doc .hd-head { text-align: center; }
.hd-logo { display: block; margin: 0 auto; width: auto; max-width: 141px; max-height: 117px; }
.hd-contact { font-size: 12px; margin-top: 6px; }
.hd-rule { height: 2px; margin: 12px 5.2% 0 5.2%; background: linear-gradient(90deg, #000, var(--hd-gold)); }
.hd-rule-rev { background: linear-gradient(90deg, var(--hd-gold), #000); margin: 4px 6.5% 6px 5.5%; }
.hd-parties { display: flex; justify-content: space-between; gap: 24px; padding: 14px 9.8% 0 10.1%; }
.hd-billed { max-width: 50%; }
.hd-strong { font-weight: 700; }
.hd-meta { text-align: right; }
.hd-title { font-weight: 700; font-size: 16.7px; margin-bottom: 2px; }
.hd-small { font-size: 12px; color: #444; }
.hd-pre { white-space: pre-line; }
.hd-table { width: 85%; margin: 104px 6.1% 0 8.9%; border-collapse: collapse; font-size: 13.3px; table-layout: fixed; }
.hd-table th:nth-child(1) { width: 20.4%; } .hd-table th:nth-child(2) { width: 12.6%; }
.hd-table th:nth-child(3) { width: 23.3%; } .hd-table th:nth-child(4) { width: 23.5%; } .hd-table th:nth-child(5) { width: 18.4%; }
/* compact layout (all room invoices), matching the PDF download */
.hd-compact .hd-logo { max-width: 123px; max-height: 93px; }
.hd-compact .hd-rule { margin-top: 9px; }
.hd-compact .hd-parties { padding-top: 10px; line-height: 1.3; }
.hd-compact .hd-table { margin-top: 18px; }
.hd-compact .hd-table thead th { padding: 8px 6px 9px; }
.hd-compact .hd-table tbody td { padding: 8px 6px 10px; }
.hd-compact .hd-totals { padding-top: 9px; }
.hd-compact .hd-taxes { margin-top: 7px; }
.hd-compact .hd-total { margin-top: 6px; padding-top: 8px; }
.hd-compact .hd-foot { margin-top: 40px; font-size: 13.3px; line-height: 1.35; }
.hd-compact .hd-note { font-size: 11.5px; margin-bottom: 8px; }
.hd-compact .hd-brand { font-size: 22px; }
.hd-table tr.hd-row-early td { padding-top: 4px; }
.hd-table th, .hd-table td { border: none; background: transparent; text-align: center; vertical-align: middle; color: #111; }
.hd-table thead th { font-weight: 700; font-size: 13.3px; padding: 14px 6px 15px; border-top: 1px solid #000; border-bottom: 1px solid #000; white-space: normal; }
.hd-table tbody td { padding: 14px 6px 26px; }
.hd-table tbody tr:last-child td { border-bottom: 1px solid #000; }
.hd-table .hd-desc { text-align: left; padding-left: 12px; width: 21%; }
.hd-table td.hd-desc strong { display: block; font-size: 13.3px; margin-bottom: 3px; }
.hd-table td.hd-desc small { display: block; font-size: 10.7px; line-height: 1.45; }
.hd-table .hd-sac { font-weight: 700; }
.hd-table tbody tr:hover td { background: transparent; }
.hd-bottom { display: flex; justify-content: space-between; gap: 20px; padding: 0 6.1% 0 10.1%; }
.hd-notes { font-size: 12px; color: #333; padding-top: 16px; max-width: 46%; }
.hd-notes p { margin: 0 0 6px; }
.hd-totals { width: 39.5%; margin-left: auto; font-size: 13.3px; padding-top: 14px; }
.hd-trow { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; padding: 1px 12px 1px 0; }
.hd-trow span:first-child { font-weight: 700; text-align: center; padding-left: 4px; }
.hd-trow span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.hd-taxes { margin-top: 26px; }
.hd-total { border-top: 1px solid #000; margin-top: 16px; padding-top: 18px; }
.hd-total span:last-child { font-weight: 700; font-size: 12.7px; }
.hd-foot { margin-top: 120px; text-align: center; font-size: 14.6px; line-height: 1.5; }
.hd-note { font-size: 12px; margin: 0 0 12px; }
.hd-brand { font-family: 'Zigo Invoice Serif', Georgia, serif; font-size: 24px; line-height: 1.25; color: #000; }
.hd-brand span { color: var(--hd-gold); }
.hd-brand-lg { font-size: 32px; padding: 18px 0 6px; }
.hd-foot-logo { display: block; margin: 0 auto 2px; max-height: 36px; width: auto; }

@media (max-width: 767.98px) {
  .hotel-doc { font-size: 13px; }
  .hd-parties { flex-direction: column; gap: 14px; padding: 12px 16px 0; }
  .hd-billed { max-width: none; }
  .hd-meta { text-align: left; }
  .hd-table { width: 640px; margin: 28px 0 0; }
  .doc-paper.hotel-doc { overflow-x: auto; }
  .hd-bottom { flex-direction: column-reverse; padding: 0 12px; }
  .hd-notes, .hd-totals { max-width: none; width: 100%; }
  .hd-foot { margin-top: 48px; font-size: 12.5px; padding: 0 12px; }
  .hd-rule { margin-left: 12px; margin-right: 12px; }
}

@media print {
  @page { size: A4; margin: 0; }
  .doc-paper.hotel-doc {
    width: 210mm; min-height: 296mm; max-width: none; margin: 0; padding: 6mm 0 6mm;
    border: none; border-radius: 0; box-shadow: none;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .hotel-doc .hd-foot { margin-top: auto; }
  .hotel-doc ~ .card, .hotel-doc ~ div, .hotel-doc ~ section { display: none !important; }
}

/* ---------- stay account (room invoice page: room + food dues) ---------- */
.stay-account-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stay-account-totals > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stay-account-totals span { font-size: 12px; color: var(--text-muted); }
.stay-account-totals strong { font-size: 18px; }
.stay-account-totals .is-due { border-color: var(--danger); background: var(--danger-soft); }
.stay-account-totals .is-due strong { color: var(--danger-ink); }
.stay-account-totals .is-clear strong { color: var(--success-ink); }
.stay-account-actions { margin-top: 12px; }
@media (max-width: 767.98px) { .stay-account-totals { grid-template-columns: minmax(0, 1fr); } }

/* ======================= marketing: coupons, groups, insights ======================= */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.chip-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; text-align: center; }
.chip.is-on .chip-count { background: rgba(255,255,255,.22); color: inherit; }

/* customer picker */
.cust-picker { position: relative; }
.cust-picker input[type="search"] { width: 100%; }
.cust-picker-list { position: absolute; left: 0; right: 0; z-index: 30; margin-top: 4px; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-2); }
.cust-picker-opt { padding: 9px 12px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--line); }
.cust-picker-opt:last-child { border-bottom: 0; }
.cust-picker-opt.is-active, .cust-picker-opt:hover { background: var(--brand-soft); }
.cust-picker-empty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; }
.cust-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cust-chips:empty { display: none; }
.cust-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 16px; background: var(--brand-soft); color: var(--text); font-size: 13px; }
.cust-chip button { border: 0; background: transparent; color: var(--text-muted); font-size: 16px; line-height: 1; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; }
.cust-chip button:hover { background: var(--surface-3); color: var(--text); }
.cust-chip-warn { font-size: 11px; color: var(--warning-ink); background: var(--warning-soft); border-radius: 8px; padding: 0 6px; }
.group-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.group-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.group-check { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0; align-items: flex-start; }
.group-check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

/* coupon card + details */
.coupon-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.coupon-layout > .card { margin-bottom: 0; }
.coupon-card { border: 2px dashed var(--chart-1); border-radius: 12px; padding: 22px; text-align: center; }
.coupon-brand { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.coupon-discount { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--brand-text); margin: 8px 0; }
.coupon-desc { margin-bottom: 12px; }
.coupon-code { display: inline-block; font-size: 22px; font-weight: 700; letter-spacing: .12em; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); margin-bottom: 14px; }
.coupon-qr { display: block; width: 200px; height: 200px; margin: 0 auto; background: #fff; padding: 6px; border-radius: 8px; }
.coupon-terms { font-size: 12.5px; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.kv dt { color: var(--text-muted); font-size: 13px; }
.kv dd { margin: 0; }
@media print { .coupon-layout { display: block; } .coupon-card-wrap { max-width: 520px; margin: 0 auto; } }

/* redeem */
.redeem-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.redeem-grid > .card { margin-bottom: 0; }
.redeem-lookup { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.redeem-lookup input { font-size: 18px; letter-spacing: .06em; font-family: var(--font-mono, ui-monospace, monospace); }
.redeem-or { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 12px; margin: 14px 0; }
.redeem-or::before, .redeem-or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.scan-box { position: relative; margin-top: 12px; border-radius: var(--radius); overflow: hidden; background: #000; }
.scan-box video { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.scan-frame { position: absolute; inset: 18% 22%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.scan-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; background: var(--surface); }
.scan-photo { margin-top: 10px; cursor: pointer; }
.redeem-coupon { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.redeem-coupon.is-good { border-color: var(--success-line); background: var(--success-soft); }
.redeem-coupon.is-bad { border-color: var(--danger-line); background: var(--danger-soft); }
.redeem-coupon-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.redeem-code { font-size: 18px; font-weight: 700; letter-spacing: .08em; }
.redeem-disc { font-family: var(--font-display); font-size: 24px; font-weight: 700; margin: 6px 0 2px; }
.redeem-calc { min-height: 22px; margin: 4px 0 12px; font-size: 14.5px; }

/* email */
.email-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.email-grid > .card { margin-bottom: 0; }
.email-preview { display: flex; align-items: center; gap: 14px; border: 2px dashed var(--chart-1); border-radius: 10px; padding: 12px 14px; }
.email-preview .coupon-discount { font-size: 20px; margin: 0; }
.email-preview .coupon-code { font-size: 15px; margin: 0; padding: 6px 10px; }
.email-preview img { margin-left: auto; background: #fff; border-radius: 6px; }

/* customer insights */
.report-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.insights-filters { padding: 14px 16px; }
.insights-filter-row { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.insights-filter-row input[type="search"] { min-width: 200px; flex: 1; }
.insights-check { margin: 0 0 8px; }
.insights-advanced { align-self: center; }
.insights-advanced summary { cursor: pointer; color: var(--text-muted); font-size: 13px; padding: 8px 0; }
.insights-advanced[open] { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; flex-basis: 100%; }
.insights-advanced[open] summary { flex-basis: 100%; padding-bottom: 0; }
.kpi-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg, 14px); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 12.5px; color: var(--text-muted); }
.kpi strong { font-family: var(--font-display); font-size: 26px; line-height: 1.15; color: var(--text); }
.kpi small { font-size: 12px; color: var(--text-muted); }
.segment-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.segment-card { display: flex; flex-direction: column; gap: 1px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; background: var(--surface); }
.segment-card:hover { border-color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.segment-card strong { font-family: var(--font-display); font-size: 22px; }
.segment-card span { font-weight: 600; }
.segment-card small { color: var(--text-muted); font-size: 12px; }
.insights-two { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.insights-two > .card { margin-bottom: 16px; }
/* bar charts: one series in --chart-1, 2px gaps, 4px rounded tops, hover/focus tooltip */
.vbar-chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; height: 190px; padding: 18px 0 22px; border-bottom: 1px solid var(--line-strong); }
.vbar-chart-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.vbar { position: relative; display: flex; align-items: flex-end; justify-content: center; height: 100%; color: inherit; text-decoration: none; outline: none; }
.vbar-fill { display: block; width: 72%; max-width: 34px; background: var(--chart-1); border-radius: 4px 4px 0 0; transition: opacity .12s; }
.vbar-val { position: absolute; top: -16px; font-size: 12px; color: var(--text-2); }
.vbar-label { position: absolute; bottom: -20px; font-size: 11.5px; color: var(--text-muted); }
.vbar.is-weekend .vbar-label { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.vbar-chart:hover .vbar-fill { opacity: .55; }
.vbar:hover .vbar-fill, .vbar:focus-visible .vbar-fill { opacity: 1; }
.vbar:focus-visible { box-shadow: 0 0 0 2px var(--focus, var(--brand)); border-radius: 4px; }
.vbar:hover::after, .vbar:focus-visible::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); z-index: 5;
  white-space: nowrap; padding: 6px 9px; border-radius: 8px; background: var(--text); color: var(--surface); font-size: 12px; box-shadow: var(--shadow-2); pointer-events: none; }
.vbar:first-child:hover::after, .vbar:first-child:focus-visible::after { left: 0; transform: none; }
.vbar:last-child:hover::after, .vbar:last-child:focus-visible::after { left: auto; right: 0; transform: none; }
.chart-table { margin-top: 26px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--text-muted); }
.hbar { display: inline-block; vertical-align: middle; width: calc(100% - 44px); height: 10px; background: var(--surface-3); border-radius: 0 5px 5px 0; }
.hbar-fill { display: block; height: 100%; background: var(--chart-1); border-radius: 0 4px 4px 0; }
.insights-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.save-group { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.save-group-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.seg-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.seg-chip { font-size: 11px; padding: 1px 7px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); }
.seg-chip.seg-frequent, .seg-chip.seg-highvalue { background: var(--brand-soft); color: var(--brand-text); }
.seg-chip.seg-lapsed { background: var(--warning-soft); color: var(--warning-ink); }
.seg-chip.seg-new { background: var(--info-soft); color: var(--info-ink); }
/* month grid: one hue, light -> dark = more visits (dark mode: dark -> bright) */
.heat-table th, .heat-table td { padding: 7px 6px; }
.heat-table td.heat { text-align: center; font-variant-numeric: tabular-nums; min-width: 34px; border: 2px solid var(--surface); }
.heat.lv1 { background: color-mix(in oklab, var(--chart-1) 24%, var(--surface)); }
.heat.lv2 { background: color-mix(in oklab, var(--chart-1) 46%, var(--surface)); }
.heat.lv3 { background: color-mix(in oklab, var(--chart-1) 72%, var(--surface)); color: var(--surface); }
.heat.lv4 { background: var(--chart-1); color: var(--surface); font-weight: 700; }
.heat-table th.is-picked { color: var(--brand-text); text-decoration: underline; }
.heat-table tfoot th { border-top: 1px solid var(--line-strong); font-weight: 600; }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .segment-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights-two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
  .coupon-layout, .redeem-grid, .email-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi strong { font-size: 22px; }
  .group-add { grid-template-columns: minmax(0, 1fr); }
  .vbar-chart { height: 160px; }
  .vbar-label { font-size: 10px; }
  .insights-filter-row > * { flex: 1 1 140px; }
  .report-tabs { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .report-tabs .chip { flex: 0 0 auto; }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
}

/* =========================== modules (apps) =========================== */
.app-icon { display: block; flex-shrink: 0; }
/* page heading: module name above the page title */
.page-heading { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.page-module { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-decoration: none; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-module:hover { color: var(--brand-text); text-decoration: none; }

/* top-right switcher */
.apps-switch { position: relative; }
.apps-btn svg { width: 18px; height: 18px; }
.apps-btn[aria-expanded="true"] { background: var(--brand-soft); color: var(--brand-text); }
.apps-panel { position: absolute; right: 0; top: calc(100% + 10px); z-index: 60; width: 372px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg, 14px); box-shadow: var(--shadow-2); padding: 12px; }
.apps-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 10px; font-size: 13px; }
.apps-panel-home { font-size: 13px; font-weight: 600; }
.apps-panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.app-mini { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px 10px; border-radius: var(--radius); color: var(--text); text-decoration: none; text-align: center; font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.app-mini:hover, .app-mini:focus-visible { background: var(--surface-2); text-decoration: none; outline: none; }
.app-mini:focus-visible { box-shadow: 0 0 0 2px var(--brand); }
.app-mini.is-current { background: var(--brand-soft); color: var(--brand-text); }
.app-mini-icon, .app-tile-icon { display: grid; place-items: center; background: #fff; border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,20,.08), 0 3px 10px rgba(16,24,20,.07); }
.app-mini-icon { width: 52px; height: 52px; border-radius: 13px; }

/* apps home */
body.is-apps-home .sidebar, body.is-apps-home .nav-backdrop, body.is-apps-home .nav-toggle { display: none !important; }
body.is-apps-home .main { margin-left: 0 !important; }
body.is-apps-home .topbar-logo { display: inline-flex !important; }
body.is-apps-home .content { background:
  radial-gradient(1200px 520px at 85% -10%, color-mix(in oklab, var(--brand) 9%, transparent), transparent 70%),
  radial-gradient(900px 480px at -10% 110%, color-mix(in oklab, #F5A524 9%, transparent), transparent 70%); min-height: calc(100vh - var(--topbar-h)); }
.apps-home { max-width: 980px; margin: 0 auto; padding: 18px 0 40px; }
body.is-apps-home .content { max-width: none; }
body.is-apps-home .content > .alert { max-width: 980px; margin-left: auto; margin-right: auto; }
.apps-home-head { text-align: center; margin-bottom: 30px; }
.apps-home-head h2 { font-size: 26px; margin-bottom: 6px; }
.apps-home-head p { margin: 0; }
.apps-hint-icon { display: inline-block; vertical-align: -3px; }
.apps-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px 18px; }
.app-tile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 8px; border-radius: var(--radius-lg, 14px); color: var(--text); text-decoration: none; text-align: center; transition: background .15s; }
.app-tile:hover, .app-tile:focus-visible { background: color-mix(in oklab, var(--surface) 70%, transparent); text-decoration: none; outline: none; }
.app-tile:focus-visible { box-shadow: 0 0 0 2px var(--brand); }
.app-tile-icon { position: relative; width: 96px; height: 96px; border-radius: 22px; transition: transform .15s, box-shadow .15s; }
.app-tile:hover .app-tile-icon { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(16,24,20,.08), 0 10px 22px rgba(16,24,20,.12); }
.app-tile-name { font-weight: 600; font-size: 15px; }
.app-tile-note { font-size: 12.5px; color: var(--text-muted); max-width: 190px; line-height: 1.35; }
.app-badge { position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
@media (prefers-reduced-motion: reduce) { .app-tile-icon, .app-tile { transition: none; } .app-tile:hover .app-tile-icon { transform: none; } }

/* side menu: the current module */
.nav-apps { margin-bottom: 4px; }
.nav-module { display: flex; align-items: center; gap: 10px; padding: 12px 10px 8px; margin-top: 6px; border-top: 1px solid var(--line); }
.nav-module-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #fff; box-shadow: 0 1px 2px rgba(16,24,20,.1); flex-shrink: 0; }
.nav-module-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-app-icon { display: grid; place-items: center; }
@media (min-width: 992px) {
  html.sidebar-collapsed .nav-module { justify-content: center; padding: 10px 0 6px; }
  html.sidebar-collapsed .nav-module-name { display: none; }
}

/* dark: the icon cards stay light so the colours read the same */
:root[data-theme="dark"] .app-mini-icon, :root[data-theme="dark"] .app-tile-icon, :root[data-theme="dark"] .nav-module-icon { background: #EEF3F1; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-mini-icon, :root:not([data-theme="light"]) .app-tile-icon, :root:not([data-theme="light"]) .nav-module-icon { background: #EEF3F1; }
}

@media (max-width: 991.98px) { .apps-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 767.98px) {
  .apps-home { padding-top: 6px; }
  .apps-home-head { margin-bottom: 20px; }
  .apps-home-head h2 { font-size: 22px; }
  .apps-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 6px; }
  .app-tile { padding: 8px 2px; gap: 8px; }
  .app-tile-icon { width: 72px; height: 72px; border-radius: 18px; }
  .app-tile-icon .app-icon { width: 40px; height: 40px; }
  .app-tile-name { font-size: 13px; }
  .app-tile-note { display: none; }
  .apps-panel { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h) + 6px); width: auto; }
  .page-module { display: none; }
}
@media (max-width: 380px) { .apps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- IST clock, pre-bookings, dashboard widgets ---------- */
.dash-hello { display: flex; flex-direction: column; gap: 8px; }
.ist-clock { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); width: max-content; max-width: 100%; }
.ist-clock-icon { width: 26px; height: 26px; color: var(--brand-text); flex-shrink: 0; }
.ist-clock-time { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text); }
.ist-zone { font-family: var(--font-ui); font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--brand-text); background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; vertical-align: 3px; }
.ist-clock-date { font-size: 12.5px; color: var(--text-muted); }
.apps-home-head .ist-clock { margin: 10px auto 0; }
.kpi-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row-actions { white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 4px; }
.pre-day .section-head h3 { font-size: 16px; }
.pre-away { font-weight: 600; color: var(--brand-text); }
.dash-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.dash-two > .card { margin-bottom: 0; }
.dash-widget .section-head { align-items: flex-start; }
.widget-list { list-style: none; margin: 0; padding: 0; }
.widget-list li + li { border-top: 1px solid var(--line); }
.widget-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 6px; color: var(--text); text-decoration: none; border-radius: 8px; }
.widget-row:hover { background: var(--surface-2); text-decoration: none; }
.widget-row small { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; }
.widget-main { min-width: 0; }
.widget-main strong, .widget-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.widget-amt { text-align: right; }
.widget-date, .widget-room { text-align: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 5px 4px; }
.widget-room strong { font-family: var(--font-mono, ui-monospace, monospace); font-size: 14px; display: block; line-height: 1.25; overflow-wrap: anywhere; }
.widget-room.is-in { background: var(--brand-soft); border-color: color-mix(in oklab, var(--brand) 35%, var(--line)); }
.widget-room.is-food { background: var(--warning-soft); border-color: var(--warning-line); }
.widget-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-muted); }
.widget-total { text-align: right; }
.widget-total span { display: block; font-size: 12px; color: var(--text-muted); }
.widget-total strong { font-family: var(--font-display); font-size: 22px; color: var(--danger-ink); }
@media (max-width: 1100px) { .dash-two { grid-template-columns: minmax(0, 1fr); } .kpi-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767.98px) {
  .widget-row { grid-template-columns: 58px minmax(0, 1fr) auto; gap: 8px; }
  .ist-clock-time { font-size: 19px; }
}

/* ---------- upload loader + reused documents ---------- */
.upload-loader { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(3px); }
.upload-loader[hidden] { display: none; }
.upload-loader-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg, 14px); box-shadow: var(--shadow-2); padding: 26px 30px; text-align: center; min-width: 260px; max-width: calc(100vw - 32px); }
.upload-loader-text { margin: 14px 0 4px; font-weight: 600; font-size: 15px; color: var(--text); }
.upload-loader-sub { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.spinner { display: inline-block; width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: zigo-spin .8s linear infinite; }
@keyframes zigo-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
body.is-uploading { overflow: hidden; }
.file-thumb.is-reused { outline: 2px solid var(--brand); outline-offset: 1px; }
.reuse-note { font-size: 12px; color: var(--brand-text); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.link-btn { border: 0; background: none; padding: 0; color: var(--text-muted); text-decoration: underline; cursor: pointer; font: inherit; }
.link-btn:hover { color: var(--danger-ink); }

/* ---------------------- data export & bulk import ------------------------ */
.lead-note { margin: -4px 0 16px; max-width: 820px; font-size: 14px; line-height: 1.5; }
.export-range { align-items: flex-end; flex-wrap: wrap; gap: 10px; }
.export-range .form-group { margin-bottom: 0; }
.export-all { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--brand-soft); }
.export-table td .muted { font-size: 12px; }
.import-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 16px; }
.import-type { display: flex; flex-direction: column; margin-bottom: 0; }
.import-type h3 { margin: 0 0 6px; }
.import-type p { flex: 1; margin: 0 0 14px; line-height: 1.45; }
.import-type-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.import-steps { margin: 0; padding-left: 20px; line-height: 1.6; }
.import-steps li { margin-bottom: 6px; }
.import-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.import-grid > .card { margin-bottom: 0; }
.import-grid + .card { margin-top: 16px; }
.ref-list { border-top: 1px solid var(--line); padding: 8px 0; }
.ref-list:first-of-type { border-top: 0; }
.ref-list summary { cursor: pointer; }
.ref-list ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow: auto; columns: 2; column-gap: 16px; font-size: 13px; }
.ref-list li { break-inside: avoid; padding: 2px 0; }
.field-guide code, .ref-list code { font-size: 12.5px; }
.import-confirm { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-color: var(--brand); }
.kpi-file { font-size: 15px; word-break: break-all; }
@media (max-width: 860px) {
  .import-grid { grid-template-columns: 1fr; }
  .ref-list ul { columns: 1; }
}
.btn-export { display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------ rooms list ------------------------------- */
.rooms-now { font-size: 13px; }
.room-stay { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.45; }
.room-stay strong { color: var(--text-2); font-weight: 600; }
.stamp-maint { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.rooms-table tr.is-maint td:first-child strong { text-decoration: none; }
.room-actions-cell { white-space: nowrap; text-align: right; }
.room-actions-cell > * { vertical-align: middle; }
.status-menu { position: relative; display: inline-block; margin-left: 4px; }
.status-menu > summary { list-style: none; cursor: pointer; }
.status-menu > summary::-webkit-details-marker { display: none; }
.status-menu[open] > summary { background: var(--surface-3); }
.status-menu-list {
  position: fixed; z-index: 60; min-width: 230px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14); padding: 4px; text-align: left; white-space: normal;
}
.status-menu-list form { margin: 0; }
.status-opt {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.status-opt:hover:not(:disabled), .status-opt:focus-visible { background: var(--surface-3); }
.status-opt:disabled { cursor: default; opacity: 0.6; }
.status-opt strong { display: block; font-size: 13.5px; }
.status-opt small { display: block; color: var(--text-muted); font-size: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--success); }
.status-cleaning .status-dot { background: var(--warning); }
.status-maintenance .status-dot { background: var(--text-muted); }

/* ------------------------------ table tools ------------------------------ */
.tt-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin: 0 0 10px; }
.tt-info { font-size: 13px; color: var(--text-2); }
.tt-info strong { color: var(--text); font-weight: 600; }
.tt-muted { color: var(--text-muted); font-weight: 400; }
.tt-controls { display: flex; align-items: center; gap: 8px; }
.tt-size { width: auto; min-width: 0; padding: 5px 30px 5px 10px; font-size: 13px; height: auto; }
.tt-col-btn { display: inline-flex; align-items: center; gap: 6px; }
.tt-hidden { display: none !important; }
tr.tt-off { display: none !important; }
.tt-pager { display: flex; align-items: center; justify-content: flex-end; gap: 4px; flex-wrap: wrap; margin: 12px 0 0; }
.tt-pager[hidden] { display: none; }
.tt-pg {
  min-width: 34px; height: 34px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.tt-pg:hover:not(:disabled) { background: var(--surface-3); }
.tt-pg.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tt-pg:disabled { opacity: 0.4; cursor: default; }
.tt-gap { padding: 0 4px; color: var(--text-muted); }
.tt-pg-of { margin-left: 8px; font-size: 12.5px; color: var(--text-muted); }
.tt-panel {
  position: fixed; z-index: 70; width: 300px; max-width: calc(100vw - 16px); max-height: min(70vh, 520px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16); padding: 10px;
}
.tt-panel-head { display: flex; flex-direction: column; gap: 2px; padding: 2px 4px 8px; font-size: 13.5px; }
.tt-panel-head .tt-muted { font-size: 12px; }
.tt-col-list { list-style: none; margin: 0; padding: 0; }
.tt-col { display: flex; align-items: center; gap: 6px; padding: 4px 4px; border-radius: 6px; border: 1px solid transparent; }
.tt-col:hover { background: var(--surface-2); }
.tt-col.is-off label span { color: var(--text-muted); }
.tt-col.is-drag { opacity: 0.4; }
.tt-col.is-over { border-color: var(--brand); }
.tt-col label { flex: 1; display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; font-weight: 500; cursor: pointer; min-width: 0; }
.tt-col label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-grip { cursor: grab; color: var(--text-muted); font-size: 12px; letter-spacing: -2px; user-select: none; }
.tt-move { display: flex; gap: 2px; }
.tt-move button {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); cursor: pointer; font-size: 13px; line-height: 1;
}
.tt-move button:hover:not(:disabled) { background: var(--surface-3); }
.tt-move button:disabled { opacity: 0.35; cursor: default; }
.tt-panel-foot { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
@media (max-width: 640px) {
  .tt-pg-of { width: 100%; text-align: right; margin: 4px 0 0; }
}
@media print {
  .tt-bar, .tt-pager { display: none !important; }
  tr.tt-off { display: table-row !important; }
}
.report-scope { margin: 0 0 12px; font-size: 13.5px; color: var(--text-2); }

/* ------------------------------ payments -------------------------------- */
.pay-actions { white-space: nowrap; text-align: right; }
.pay-actions .inline-form { display: inline; }
.btn-danger-text { color: var(--danger-ink); }
.pay-modal { position: fixed; inset: 0; background: rgba(27, 36, 48, 0.5); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.pay-modal[hidden] { display: none; }
.pay-modal-box { width: 380px; max-width: 100%; margin: 0; }

/* ------------------------- confirm / unsaved dialog ----------------------- */
.zg-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 33, 0.55); }
.zg-modal[hidden] { display: none; }
.zg-box { width: 440px; max-width: 100%; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); padding: 20px 20px 16px; }
.zg-box h3 { margin: 0 0 8px; font-size: 17px; }
.zg-body { color: var(--text-2); font-size: 14px; line-height: 1.5; }
.zg-body p { margin: 0 0 8px; }
.zg-changes { margin: 0 0 10px; padding-left: 18px; color: var(--text); }
.zg-changes li { margin: 2px 0; }
.zg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
body.zg-open { overflow: hidden; }
@media (max-width: 480px) { .zg-actions { flex-direction: column-reverse; } .zg-actions .btn { width: 100%; } }

/* ------------------------------ account menu ----------------------------- */
.user-menu { position: relative; }
button.user-chip { border: 1px solid transparent; background: transparent; color: inherit; font: inherit; border-radius: 999px; cursor: pointer; text-align: left; padding-right: 8px; }
button.user-chip:hover, button.user-chip[aria-expanded="true"] { background: var(--surface-3); }
.user-caret { width: 15px; height: 15px; color: var(--text-muted); flex: none; }
.avatar-img { object-fit: cover; background: var(--surface-3); }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80; width: 270px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16); padding: 6px;
}
.user-dd-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-dd-head strong { display: block; font-size: 14px; }
.user-dd-head span { display: block; font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.user-dd-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 0;
  background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.user-dd-item:hover, .user-dd-item:focus-visible { background: var(--surface-3); outline: none; }
.user-dd-item svg { width: 18px; height: 18px; color: var(--text-muted); flex: none; }
.user-dd-item small { display: block; font-size: 12px; color: var(--text-muted); }
.user-dd-form { margin: 4px 0 0; border-top: 1px solid var(--line); padding-top: 4px; }
@media (max-width: 991.98px) { .user-caret { display: none; } button.user-chip { padding: 0; } }

/* ------------------------------ account pages ----------------------------- */
.account-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.account-grid > .card { margin-bottom: 0; }
.profile-photo { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.avatar-xl { width: 88px; height: 88px; border-radius: 50%; font-size: 30px; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; }
.profile-name { margin: 0 0 6px; font-size: 20px; }
.avatar-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.profile-facts { margin: 18px 0 0; display: grid; gap: 10px; }
.profile-facts div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.profile-facts dt { color: var(--text-muted); font-size: 13.5px; }
.profile-facts dd { margin: 0; font-weight: 600; text-align: right; }
.sq-question { margin: 2px 0 8px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); font-weight: 600; }
.sq-card { max-width: 720px; }
.sq-set { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 4px; margin: 0 0 14px; }
.sq-set legend { font-weight: 700; padding: 0 6px; font-size: 13.5px; }
.login-forgot { text-align: center; margin: 14px 0 0; font-size: 14px; }
.login-shell-single { grid-template-columns: 1fr; }
@media (max-width: 860px) { .account-grid { grid-template-columns: 1fr; } }
.profile-facts-tight { margin-top: 4px; gap: 8px; }
.profile-facts-tight div { padding-top: 8px; }

/* ------------------------------ salary slips ------------------------------ */
.slip-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.slip-facts div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.slip-facts span { display: block; font-size: 12px; color: var(--text-muted); }
.slip-facts strong { font-size: 15px; }
.slip-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.slip-grid > .card { margin-bottom: 16px; }
.slip-table .num-input { width: 130px; text-align: right; margin-left: auto; }
.slip-table tfoot th { font-size: 14px; }
.slip-net { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.slip-net > div:first-child span { display: block; font-size: 12.5px; color: var(--text-muted); }
.slip-net > div:first-child strong { display: block; font-size: 26px; }
.slip-net small { display: block; color: var(--text-2); max-width: 420px; }
.payslip { background: #fff; color: #1B2430; max-width: 860px; margin: 0 auto; padding: 28px 32px; border: 1px solid var(--line); border-radius: 10px; }
.payslip table { width: 100%; border-collapse: collapse; }
.payslip th, .payslip td { border: 1px solid #C9D0D8; padding: 6px 8px; font-size: 13px; color: #1B2430; background: #fff; }
.payslip th { background: #F1F4F7; font-weight: 600; text-align: left; color: #5B6675; }
.payslip .num { text-align: right; font-variant-numeric: tabular-nums; }
.ps-head { display: flex; gap: 16px; align-items: center; border-bottom: 2px solid #1B2430; padding-bottom: 12px; }
.ps-head h2 { margin: 0 0 2px; font-size: 20px; color: #1B2430; }
.ps-head p { margin: 0; font-size: 12.5px; color: #5B6675; }
.ps-logo { max-height: 56px; max-width: 120px; object-fit: contain; }
.ps-title { text-align: center; margin: 14px 0; font-size: 16px; color: #1B2430; }
.ps-info { margin-bottom: 14px; }
.ps-lines thead th, .ps-lines tfoot th { color: #1B2430; }
.ps-net { border: 2px solid #1B2430; border-radius: 8px; padding: 10px 14px; margin-top: 14px; }
.ps-net div { display: flex; justify-content: space-between; align-items: baseline; }
.ps-net span { font-weight: 700; letter-spacing: 0.05em; color: #5B6675; }
.ps-net strong { font-size: 22px; color: #1B2430; }
.ps-net p { margin: 4px 0 0; font-size: 13px; color: #1B2430; }
.ps-remarks { font-size: 13px; color: #1B2430; }
.ps-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; font-size: 12px; color: #5B6675; }
@media (max-width: 860px) { .slip-grid { grid-template-columns: 1fr; } .payslip { padding: 16px; } .ps-info th, .ps-info td { font-size: 12px; } }
@media print {
  .payslip { border: 0; padding: 0; max-width: none; }
  .payslip ~ * { display: none; }
}

/* ------------------------------ table sorting ------------------------------ */
.tt-sort { all: unset; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font: inherit; color: inherit; border-radius: 4px; }
.tt-sort:hover { color: var(--text); }
.tt-sort:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
th.num .tt-sort { flex-direction: row-reverse; }
.tt-arrow { width: 10px; height: 12px; flex: none; opacity: 0.35; background:
  linear-gradient(to bottom, transparent 0 0) center/0 0 no-repeat; position: relative; }
.tt-arrow::before, .tt-arrow::after { content: ''; position: absolute; left: 1px; border: 4px solid transparent; }
.tt-arrow::before { top: -3px; border-bottom-color: currentColor; }
.tt-arrow::after { bottom: -3px; border-top-color: currentColor; }
th[aria-sort="ascending"] .tt-arrow, th[aria-sort="descending"] .tt-arrow { opacity: 1; color: var(--brand); }
th[aria-sort="ascending"] .tt-arrow::after { display: none; }
th[aria-sort="descending"] .tt-arrow::before { display: none; }
th.tt-sorted { color: var(--text); }

/* ------------------------------ theme colours ----------------------------- */
/* Chosen in Settings (per user) or Company Settings (default). Teal is the base palette above. */
:root[data-accent="ocean"] { --brand: #0369A1; --brand-strong: #075985; --brand-ink: #FFFFFF; --brand-soft: #E0F2FE; --brand-text: #075985; --focus: 0 0 0 3px rgba(3,105,161, 0.28); }
:root[data-accent="ocean"][data-theme="dark"] { --brand: #38BDF8; --brand-strong: #7DD3FC; --brand-ink: #04263A; --brand-soft: rgba(56,189,248, 0.15); --brand-text: #7DD3FC; --focus: 0 0 0 3px rgba(56,189,248, 0.35); }
@media (prefers-color-scheme: dark) { :root[data-accent="ocean"]:not([data-theme="light"]) { --brand: #38BDF8; --brand-strong: #7DD3FC; --brand-ink: #04263A; --brand-soft: rgba(56,189,248, 0.15); --brand-text: #7DD3FC; --focus: 0 0 0 3px rgba(56,189,248, 0.35); } }
:root[data-accent="indigo"] { --brand: #4338CA; --brand-strong: #3730A3; --brand-ink: #FFFFFF; --brand-soft: #E8E7FD; --brand-text: #3730A3; --focus: 0 0 0 3px rgba(67,56,202, 0.28); }
:root[data-accent="indigo"][data-theme="dark"] { --brand: #818CF8; --brand-strong: #A5B4FC; --brand-ink: #14123D; --brand-soft: rgba(129,140,248, 0.15); --brand-text: #A5B4FC; --focus: 0 0 0 3px rgba(129,140,248, 0.35); }
@media (prefers-color-scheme: dark) { :root[data-accent="indigo"]:not([data-theme="light"]) { --brand: #818CF8; --brand-strong: #A5B4FC; --brand-ink: #14123D; --brand-soft: rgba(129,140,248, 0.15); --brand-text: #A5B4FC; --focus: 0 0 0 3px rgba(129,140,248, 0.35); } }
:root[data-accent="grape"] { --brand: #7E22CE; --brand-strong: #6B21A8; --brand-ink: #FFFFFF; --brand-soft: #F3E8FF; --brand-text: #6B21A8; --focus: 0 0 0 3px rgba(126,34,206, 0.28); }
:root[data-accent="grape"][data-theme="dark"] { --brand: #C084FC; --brand-strong: #D8B4FE; --brand-ink: #2A0B45; --brand-soft: rgba(192,132,252, 0.15); --brand-text: #D8B4FE; --focus: 0 0 0 3px rgba(192,132,252, 0.35); }
@media (prefers-color-scheme: dark) { :root[data-accent="grape"]:not([data-theme="light"]) { --brand: #C084FC; --brand-strong: #D8B4FE; --brand-ink: #2A0B45; --brand-soft: rgba(192,132,252, 0.15); --brand-text: #D8B4FE; --focus: 0 0 0 3px rgba(192,132,252, 0.35); } }
:root[data-accent="fuchsia"] { --brand: #A21CAF; --brand-strong: #86198F; --brand-ink: #FFFFFF; --brand-soft: #FAE8FF; --brand-text: #86198F; --focus: 0 0 0 3px rgba(162,28,175, 0.28); }
:root[data-accent="fuchsia"][data-theme="dark"] { --brand: #E879F9; --brand-strong: #F0ABFC; --brand-ink: #3B0742; --brand-soft: rgba(232,121,249, 0.15); --brand-text: #F0ABFC; --focus: 0 0 0 3px rgba(232,121,249, 0.35); }
@media (prefers-color-scheme: dark) { :root[data-accent="fuchsia"]:not([data-theme="light"]) { --brand: #E879F9; --brand-strong: #F0ABFC; --brand-ink: #3B0742; --brand-soft: rgba(232,121,249, 0.15); --brand-text: #F0ABFC; --focus: 0 0 0 3px rgba(232,121,249, 0.35); } }
:root[data-accent="coral"] { --brand: #E11D48; --brand-strong: #BE123C; --brand-ink: #FFFFFF; --brand-soft: #FFE4E9; --brand-text: #BE123C; --focus: 0 0 0 3px rgba(225,29,72, 0.28); }
:root[data-accent="coral"][data-theme="dark"] { --brand: #FB7185; --brand-strong: #FDA4AF; --brand-ink: #45071A; --brand-soft: rgba(251,113,133, 0.15); --brand-text: #FDA4AF; --focus: 0 0 0 3px rgba(251,113,133, 0.35); }
@media (prefers-color-scheme: dark) { :root[data-accent="coral"]:not([data-theme="light"]) { --brand: #FB7185; --brand-strong: #FDA4AF; --brand-ink: #45071A; --brand-soft: rgba(251,113,133, 0.15); --brand-text: #FDA4AF; --focus: 0 0 0 3px rgba(251,113,133, 0.35); } }
:root[data-accent="tangerine"] { --brand: #C2410C; --brand-strong: #9A3412; --brand-ink: #FFFFFF; --brand-soft: #FFEDD5; --brand-text: #9A3412; --focus: 0 0 0 3px rgba(194,65,12, 0.28); }
:root[data-accent="tangerine"][data-theme="dark"] { --brand: #FB923C; --brand-strong: #FDBA74; --brand-ink: #3D1704; --brand-soft: rgba(251,146,60, 0.15); --brand-text: #FDBA74; --focus: 0 0 0 3px rgba(251,146,60, 0.35); }
@media (prefers-color-scheme: dark) { :root[data-accent="tangerine"]:not([data-theme="light"]) { --brand: #FB923C; --brand-strong: #FDBA74; --brand-ink: #3D1704; --brand-soft: rgba(251,146,60, 0.15); --brand-text: #FDBA74; --focus: 0 0 0 3px rgba(251,146,60, 0.35); } }

/* colour picker */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 6px 0 12px; }
.swatch { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface); font-size: 13.5px; font-weight: 600; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch-dot { width: 26px; height: 26px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.swatch:hover { background: var(--surface-2); }
.swatch:has(input:checked) { border-color: var(--text); box-shadow: 0 0 0 2px var(--text) inset; }
.swatch:has(input:focus-visible) { box-shadow: var(--focus); }
.swatch-default { font-weight: 500; color: var(--text-2); }

/* ------------------------------ invoice QR codes --------------------------- */
.inv-qr-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px 28px; flex-wrap: wrap; margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--line-strong); break-inside: avoid; page-break-inside: avoid; }
.inv-pay { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 24px; }
.inv-qr-head { width: 100%; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 0; }
.inv-bank { font-size: 13.5px; line-height: 1.55; }
.inv-qr-fig { display: flex; align-items: center; gap: 10px; margin: 0; }
.inv-qr-img { width: 104px; height: 104px; object-fit: contain; background: #fff; padding: 4px; border: 1px solid var(--line); border-radius: 6px; image-rendering: pixelated; }
.inv-qr-self .inv-qr-img { width: 92px; height: 92px; }
.inv-qr-fig figcaption { display: flex; flex-direction: column; font-size: 12.5px; color: var(--text-muted); max-width: 170px; }
.inv-qr-fig figcaption strong { color: var(--text); font-size: 13px; }
.inv-qr-self { margin-left: auto; }
@media print { .inv-qr-row { border-top-color: #bbb; } .inv-qr-img { border-color: #ccc; } }

/* ------------------------------ invoice scanner --------------------------- */
/* phones only: a touch screen that's not wider than a tablet */
.scan-invoice-btn { display: none; }
@media (pointer: coarse) and (max-width: 991.98px) { .scan-invoice-btn { display: inline-flex; } }
.scan-overlay { position: fixed; inset: 0; z-index: 210; background: #0b0f0e; color: #fff; display: flex; flex-direction: column; align-items: center; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.scan-overlay[hidden] { display: none; }
.scan-top { width: 100%; max-width: 520px; display: flex; justify-content: space-between; align-items: center; padding: 6px 0 12px; font-size: 16px; }
.scan-close { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; font-size: 18px; cursor: pointer; }
.scan-stage { position: relative; width: 100%; max-width: 520px; aspect-ratio: 3 / 4; max-height: 62vh; border-radius: 16px; overflow: hidden; background: #000; }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-target { position: absolute; inset: 18% 14%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-msg { margin: 14px 0; text-align: center; font-size: 14.5px; max-width: 420px; color: rgba(255,255,255,.88); }
.scan-photo-btn { background: #fff; color: #111; }

/* ============ Reservations calendar (tape chart) ============ */
.tc-toolbar { flex-wrap: wrap; gap: 10px; }
.tc-nav, .tc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tc-jump { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.tc-range { font-size: 13px; }
.tc-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 12px; font-size: 13px; }
.tc-key { display: inline-flex; align-items: center; gap: 6px; }
.tc-key::before { content: ''; width: 22px; height: 12px; border-radius: 4px; display: inline-block; }
.tc-key b { font-variant-numeric: tabular-nums; }
.tc-key--confirmed::before { background: var(--brand); }
.tc-key--tentative::before { background: repeating-linear-gradient(135deg, var(--warning-soft) 0 4px, var(--warning-line) 4px 8px); border: 1px dashed var(--warning); }
.tc-key--no_show::before { background: var(--surface-3); border: 1px dashed var(--line-strong); }
.tc-key--cancelled::before { background: var(--danger-soft); border: 1px solid var(--danger-line); }
.tc-key--maint::before { background: repeating-linear-gradient(45deg, var(--surface-3) 0 5px, var(--surface) 5px 10px); border: 1px solid var(--line); }
.tc-hint { flex: 1 1 260px; font-size: 12.5px; }

.tc-card { padding: 0; overflow: hidden; }
.tc { position: relative; overflow: auto; max-height: calc(100vh - 250px); min-height: 240px; -webkit-overflow-scrolling: touch; }
.tc.is-saving { opacity: .6; pointer-events: none; }
.tc-inner { position: relative; }
.tc-head { display: flex; position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--line-strong); }
.tc-corner { position: sticky; left: 0; z-index: 7; width: var(--tc-label); flex: 0 0 var(--tc-label); background: var(--surface);
  padding: 8px 12px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  border-right: 1px solid var(--line-strong); display: flex; align-items: flex-end; }
.tc-days { display: flex; }
.tc-day { flex: 0 0 auto; padding: 6px 4px; text-align: center; border-right: 1px solid var(--line); line-height: 1.15; }
.tc-day.is-weekend { background: var(--surface-2); }
.tc-day.is-today { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.tc-dow { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.tc-day.is-today .tc-dow { color: var(--brand-text); }
.tc-dnum { display: block; font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tc-body { position: relative; }
.tc-today-col { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--brand-soft) 55%, transparent); pointer-events: none; z-index: 0; }
.tc-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--danger); opacity: .7; pointer-events: none; z-index: 4; }
.tc-group { position: relative; z-index: 2; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tc-group-label { position: sticky; left: 0; display: inline-block; padding: 5px 12px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.tc-row { display: flex; position: relative; border-bottom: 1px solid var(--line); min-height: 40px; }
.tc-row.has-ghost { min-height: 56px; }
.tc-row.is-target .tc-track { background-color: var(--info-soft); }
.tc-label { position: sticky; left: 0; z-index: 5; width: var(--tc-label); flex: 0 0 var(--tc-label); background: var(--surface);
  border-right: 1px solid var(--line-strong); padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 14px; }
.tc-flag { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: var(--warning-soft); color: var(--warning-ink); font-weight: 600; }
.tc-track { position: relative; flex: 0 0 auto; overflow: hidden; z-index: 1; cursor: cell;
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(var(--tc-col) - 1px), var(--line) calc(var(--tc-col) - 1px) var(--tc-col)); }
.tc-row.is-maint .tc-track { background-image:
  repeating-linear-gradient(90deg, transparent 0 calc(var(--tc-col) - 1px), var(--line) calc(var(--tc-col) - 1px) var(--tc-col)),
  repeating-linear-gradient(45deg, var(--surface-3) 0 6px, transparent 6px 12px); cursor: not-allowed; }
.tc-cell-mark { position: absolute; top: 3px; bottom: 3px; border: 2px dashed var(--brand); border-radius: 6px; pointer-events: none; }

.tc-bar { position: absolute; top: 5px; height: 30px; padding: 0 10px 0 8px; border: 0; border-radius: 7px; font: inherit; font-size: 12.5px;
  text-align: left; display: flex; align-items: center; overflow: hidden; white-space: nowrap; cursor: pointer; z-index: 3;
  background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-1); }
.tc-bar:focus-visible { outline: none; box-shadow: var(--focus); }
.tc-bar.is-movable { cursor: grab; touch-action: none; }
.tc-bar.is-dragging { cursor: grabbing; opacity: .88; z-index: 8; box-shadow: var(--shadow-2); }
.tc.is-dragging { user-select: none; -webkit-user-select: none; }
.tc-bar.clip-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.tc-bar.clip-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tc-bar.is-paid::after { content: '✓'; margin-left: 6px; font-weight: 700; opacity: .85; }
.tc-bar-text { overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.tc-multi { font-size: 10.5px; padding: 0 5px; border-radius: 999px; background: rgba(255,255,255,.25); margin-left: 4px; }
.tc-grip { position: absolute; right: 0; top: 0; bottom: 0; width: 10px; cursor: ew-resize; touch-action: none;
  background: linear-gradient(90deg, transparent 0 3px, rgba(255,255,255,.55) 3px 4px, transparent 4px 6px, rgba(255,255,255,.55) 6px 7px, transparent 7px); }
.tc-bar--tentative { background: repeating-linear-gradient(135deg, var(--warning-soft) 0 6px, var(--warning-line) 6px 12px);
  color: var(--warning-ink); border: 1px dashed var(--warning); }
.tc-bar--tentative .tc-grip { background: linear-gradient(90deg, transparent 0 3px, var(--warning) 3px 4px, transparent 4px 6px, var(--warning) 6px 7px, transparent 7px); }
.tc-bar--tentative .tc-multi { background: var(--warning-line); }
.tc-bar--ghost { top: auto; bottom: 3px; height: 14px; font-size: 10.5px; z-index: 2; box-shadow: none; padding: 0 6px; }
.tc-bar--no_show { background: var(--surface-3); color: var(--text-muted); border: 1px dashed var(--line-strong); text-decoration: line-through; }
.tc-bar--cancelled { background: var(--danger-soft); color: var(--danger-ink); border: 1px solid var(--danger-line); text-decoration: line-through; }
.tc-bar--ghost.is-paid::after { content: none; }

.tc-tip { position: absolute; z-index: 190; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12.5px;
  padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow-2); white-space: nowrap; }
.tc-tip .tc-due { color: #FFB4A8; }
.tc-pop { position: absolute; z-index: 150; width: min(320px, calc(100vw - 16px)); background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 14px 16px 12px; font-size: 13.5px; }
.tc-pop-x { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 20px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 4px; }
.tc-pop-head { display: flex; align-items: center; gap: 8px; margin: 0 22px 8px 0; font-size: 15px; }
.tc-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--brand); }
.tc-dot--tentative { background: var(--warning); }
.tc-dot--no_show { background: var(--text-faint); }
.tc-dot--cancelled { background: var(--danger); }
.tc-dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 10px; }
.tc-dl dt { color: var(--text-muted); }
.tc-dl dd { margin: 0; overflow-wrap: anywhere; }
.tc-due { color: var(--danger-ink); font-weight: 600; }
.tc-pop-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tc-pop-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.tc-pop-status .tc-danger { color: var(--danger-ink); }
.tc-pop-tip { margin: 8px 0 0; font-size: 12px; }
.tc-changes { margin: 6px 0 8px 18px; padding: 0; }
.tc-changes li { margin: 2px 0; }
.stamp-tentative { background: var(--warning-soft); color: var(--warning-ink); margin-left: 4px; }
.stamp-noshow { background: var(--surface-3); color: var(--text-muted); margin-left: 4px; }
@media (max-width: 640px) {
  .tc { max-height: calc(100vh - 210px); }
  .tc-hint { display: none; }
}
