/*
 * AccounTech design system
 * ---------------------------------------------------------------------------
 * One stylesheet, shared by every page. Organized as:
 *   1. Design tokens (CSS custom properties)
 *   2. Reset + base element styles
 *   3. Layout shell (sidebar / topbar / content)
 *   4. Components (cards, buttons, tables, forms, badges, modal, toast, tabs)
 *   5. Module accent themes + utilities
 *   6. Responsive + accessibility
 *
 * Design language: a modern ledger. Financial tables get tabular monospace
 * figures, panels carry a thin colored "ledger stripe" that identifies which
 * system they belong to, and the palette stays disciplined - deep ink shell,
 * quiet neutral surface, one accent color per system.
 */

/* ------------------------------------------------------------------------ */
/* 1. Design tokens                                                         */
/* ------------------------------------------------------------------------ */

:root {
  /* Neutral surface */
  --color-bg: #F5F6FA;
  --color-surface: #FFFFFF;
  --color-surface-sunken: #F0F1F6;
  --color-border: #E2E4ED;
  --color-border-strong: #CBCEDC;

  /* Ink shell (sidebar, headers) */
  --color-ink-950: #0B1020;
  --color-ink-900: #10162B;
  --color-ink-800: #1A2138;
  --color-ink-700: #2A3350;
  --color-ink-400: #8A93B8;

  /* Text */
  --color-text: #12172B;
  --color-text-muted: #5B6478;
  --color-text-faint: #8992AC;
  --color-text-on-dark: #E7E9F5;
  --color-text-on-dark-muted: #9AA3C4;

  /* Module accents */
  --color-admin: #4C5FD5;
  --color-admin-soft: #EEF0FC;
  --color-accounting: #0E9F6E;
  --color-accounting-soft: #E7F8F1;
  --color-hr: #7C5CFF;
  --color-hr-soft: #F1EDFF;
  --color-invoicing: #E08E0B;
  --color-invoicing-soft: #FCF1DD;

  /* Status */
  --color-success: #12B76A;
  --color-success-soft: #E7F8EF;
  --color-warning: #F79009;
  --color-warning-soft: #FEF2DE;
  --color-danger: #F04438;
  --color-danger-soft: #FDECEC;
  --color-info: #2E90FA;
  --color-info-soft: #E9F2FE;

  /* Typography */
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  /* Layout */
  --sidebar-width: 248px;
  --topbar-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 22, 43, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 22, 43, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 22, 43, 0.14);

  /* The "active module" accent - each app shell sets this once. */
  --accent: var(--color-admin);
  --accent-soft: var(--color-admin-soft);
}

/* ------------------------------------------------------------------------ */
/* 2. Reset + base                                                          */
/* ------------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

.num, .mono, td.num, .figure {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

::selection { background: var(--accent-soft); color: var(--color-text); }

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------------------------------ */
/* 3. App shell layout                                                      */
/* ------------------------------------------------------------------------ */

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

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--color-ink-950), var(--color-ink-900));
  color: var(--color-text-on-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: white;
  flex-shrink: 0;
}
.brand-text { font-family: var(--font-display); font-weight: 600; font-size: 16px; line-height: 1.2; }
.brand-text small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 11px; color: var(--color-text-on-dark-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-on-dark-muted); padding: 12px 10px 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text-on-dark-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--color-text-on-dark); text-decoration: none; }
.nav-item.active { background: var(--accent); color: white; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; flex-shrink: 0; }

.sidebar-footer { padding: 14px 20px 18px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: var(--color-text-on-dark-muted); }

.main-area { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.topbar-title .eyebrow { display: block; font-family: var(--font-body); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 2px; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-surface); }
.user-chip:hover { background: var(--color-surface-sunken); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.user-chip-name { font-size: 13px; font-weight: 600; }
.user-chip-role { font-size: 11px; color: var(--color-text-muted); }

.content { padding: 28px 32px 60px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ------------------------------------------------------------------------ */
/* 4. Components                                                            */
/* ------------------------------------------------------------------------ */

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 24px; flex-wrap: wrap; }
.tab-btn {
  border: none; background: none; cursor: pointer;
  padding: 10px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--color-text-muted); border-bottom: 2px solid transparent;
  font-family: var(--font-body);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadein 0.15s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-ledger { border-left: 3px solid var(--accent); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; }
.card-subtitle { color: var(--color-text-muted); font-size: 12.5px; margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Stat cards */
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 18px 20px; border-left: 3px solid var(--accent); }
.stat-label { font-size: 12px; color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; }
.stat-sub { font-size: 12px; color: var(--color-text-faint); margin-top: 4px; }
.stat-sub.up { color: var(--color-success); }
.stat-sub.down { color: var(--color-danger); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; font-family: var(--font-body);
  transition: transform 0.05s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { filter: brightness(0.93); text-decoration: none; }
.btn-secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-sunken); text-decoration: none; }
.btn-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.btn-danger:hover:not(:disabled) { background: var(--color-danger); color: white; text-decoration: none; }
.btn-ghost { background: none; color: var(--color-text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-sunken); color: var(--color-text); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* Forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; font-size: 13.5px; font-family: inherit;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 70px; }
.field-hint { font-size: 11.5px; color: var(--color-text-faint); margin-top: 4px; }
.field-error { font-size: 11.5px; color: var(--color-danger); margin-top: 4px; }
.form-row { display: flex; gap: 12px; }
.form-row > .field { flex: 1; }
fieldset { border: none; padding: 0; margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 14px; background: var(--color-surface-sunken);
  color: var(--color-text-muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-sunken); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table-empty { padding: 40px 20px; text-align: center; color: var(--color-text-faint); }

/* POS - till layout: catalogue on the left, running sale on the right */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.pos-item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px; max-height: 460px; overflow-y: auto; padding-top: 4px;
}
.pos-item {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  padding: 10px; text-align: left; cursor: pointer;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); font: inherit; color: inherit;
  transition: border-color 120ms ease, transform 120ms ease;
}
.pos-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.pos-item:active { transform: translateY(0); }
.pos-item-img {
  width: 100%; height: 72px; object-fit: cover; border-radius: var(--radius-sm);
  background: var(--color-surface-sunken); border: 1px solid var(--color-border);
}
.pos-item-img-empty { display: grid; place-items: center; color: var(--color-text-faint); }
.pos-item-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.pos-item-price { font-size: 12.5px; color: var(--color-text-muted); }

.pos-cart { position: sticky; top: 16px; }
.pos-empty { padding: 24px 0; text-align: center; }
.pos-cart-lines { max-height: 260px; overflow-y: auto; }
.pos-cart-line {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px;
  align-items: center; padding: 8px 0; border-bottom: 1px solid var(--color-border);
}
.pos-cart-name { font-size: 13px; min-width: 0; }
.pos-qty { display: flex; align-items: center; gap: 6px; }
.pos-cart-total { font-size: 13px; font-weight: 600; }
.pos-totals { padding-top: 12px; }
.pos-grand { font-size: 17px; }
.pos-complete { width: 100%; margin-top: 16px; padding: 12px; font-size: 15px; }
.text-danger { color: var(--color-danger); }

@media (max-width: 1100px) {
  .pos-layout { grid-template-columns: 1fr; }
  .pos-cart { position: static; }
}

/* Item pictures and the catalogue-aware line item editor */
.item-thumb {
  width: 34px; height: 34px; object-fit: cover; display: block;
  border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background: var(--color-surface-sunken);
}
.item-thumb-empty {
  display: grid; place-items: center;
  color: var(--color-text-faint); font-size: 14px;
}
.item-image-preview {
  max-width: 160px; max-height: 160px; object-fit: contain; display: block;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface-sunken); margin-bottom: 8px;
}
.item-image-full {
  max-width: 100%; max-height: 60vh; object-fit: contain; display: block; margin: 0 auto;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
}
.line-item-row { padding-bottom: 4px; }
.line-item-row .line-item-actions:not(:empty) { margin: -6px 0 8px; }

/* Chart of accounts: grouped by French class (1-7) */
tr.table-group-row td {
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 14px;
}
tr.table-group-row:hover td { background: var(--color-surface-sunken); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }
.badge-neutral { background: var(--color-surface-sunken); color: var(--color-text-muted); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 16, 32, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px; backdrop-filter: blur(2px);
}
.modal { background: var(--color-surface); border-radius: var(--radius-lg); width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; }
.modal.modal-wide { max-width: 760px; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--color-text-muted); line-height: 1; padding: 4px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 10px; }

/* Toasts */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--color-ink-900); color: white; padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13px; max-width: 340px; animation: toast-in 0.2s ease; }
.toast.error { background: var(--color-danger); }
.toast.success { background: var(--color-success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--color-text-muted); }
.empty-state h3 { color: var(--color-text); margin-bottom: 6px; }

/* Alert / banner */
.alert { border-radius: var(--radius-md); padding: 12px 16px; font-size: 13px; border: 1px solid transparent; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert-warning { background: var(--color-warning-soft); border-color: rgba(247,144,9,0.25); color: #8A5A05; }
.alert-danger { background: var(--color-danger-soft); border-color: rgba(240,68,56,0.25); color: #9A241B; }
.alert-info { background: var(--color-info-soft); border-color: rgba(46,144,250,0.25); color: #16548F; }

/* Progress bar (leave balance, etc.) */
.progress { height: 6px; border-radius: 999px; background: var(--color-surface-sunken); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Utility */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-sm { font-size: 12.5px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.pill-search { display: flex; align-items: center; gap: 8px; }
.divider { height: 1px; background: var(--color-border); margin: 18px 0; border: none; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin-bottom: 10px; }
.skeleton { background: linear-gradient(90deg, var(--color-surface-sunken) 25%, var(--color-border) 37%, var(--color-surface-sunken) 63%); background-size: 400% 100%; animation: skeleton 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Simple inline SVG chart styling hooks */
.chart-bar { fill: var(--accent); }
.chart-bar-secondary { fill: var(--color-border-strong); }
.chart-axis { stroke: var(--color-border); stroke-width: 1; }
.chart-label { font-family: var(--font-mono); font-size: 10px; fill: var(--color-text-faint); }

/* ------------------------------------------------------------------------ */
/* 5. Module accent themes                                                  */
/* ------------------------------------------------------------------------ */

.theme-admin { --accent: var(--color-admin); --accent-soft: var(--color-admin-soft); }
.theme-accounting { --accent: var(--color-accounting); --accent-soft: var(--color-accounting-soft); }
.theme-hr { --accent: var(--color-hr); --accent-soft: var(--color-hr-soft); }
.theme-invoicing { --accent: var(--color-invoicing); --accent-soft: var(--color-invoicing-soft); }

/* ------------------------------------------------------------------------ */
/* 6. Login page                                                            */
/* ------------------------------------------------------------------------ */

.login-shell {
  min-height: 100vh; display: flex;
  background: var(--color-ink-950);
}
.login-side {
  flex: 1.1; display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px; color: var(--color-text-on-dark);
  background:
    radial-gradient(circle at 15% 20%, rgba(76,95,213,0.25), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(14,159,110,0.2), transparent 40%),
    var(--color-ink-950);
  position: relative;
  overflow: hidden;
}
.login-side .ledger-lines { position: absolute; inset: 0; opacity: 0.5; pointer-events: none; }
.login-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.login-brand .brand-mark { width: 40px; height: 40px; background: white; color: var(--color-ink-950); font-size: 17px; }
.login-brand-text { font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.login-pitch { position: relative; z-index: 1; max-width: 420px; }
.login-pitch h1 { color: white; font-size: 34px; line-height: 1.15; margin-bottom: 14px; }
.login-pitch p { color: var(--color-text-on-dark-muted); font-size: 14.5px; line-height: 1.6; }
.login-modules { display: flex; gap: 10px; margin-top: 28px; position: relative; z-index: 1; flex-wrap: wrap; }
.login-module-chip { display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); padding: 7px 12px; border-radius: 999px; font-size: 12px; color: var(--color-text-on-dark); }
.login-module-chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.login-foot { font-size: 12px; color: var(--color-text-on-dark-muted); position: relative; z-index: 1; }

.login-form-side { width: 460px; flex-shrink: 0; background: var(--color-bg); display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h2 { margin-bottom: 4px; }
.login-card .card-subtitle { margin-bottom: 26px; }
.login-demo-box { background: var(--color-surface-sunken); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md); padding: 12px 14px; margin-top: 20px; font-size: 12px; color: var(--color-text-muted); }
.login-demo-box strong { color: var(--color-text); }
.login-demo-row { display: flex; justify-content: space-between; padding: 3px 0; font-family: var(--font-mono); }

@media (max-width: 900px) {
  .login-side { display: none; }
  .login-form-side { width: 100%; }
}

/* ------------------------------------------------------------------------ */
/* Print (used by the "Print" button on invoices and payslips)              */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* Print                                                                     */
/*                                                                           */
/* Two cases to handle:                                                      */
/*   1. A dialog is open (receipt, invoice, payslip) -> print just that.     */
/*      openModal() puts `has-modal` on <body> so this is a plain class      */
/*      check rather than relying on :has() support.                         */
/*   2. Nothing open (a report on screen) -> print the content area and drop  */
/*      the navigation and controls, which mean nothing on paper.            */
/*                                                                           */
/* Both use display:none rather than visibility:hidden. Hidden elements      */
/* still take up space, which is what squeezed printed documents into a      */
/* narrow column - the app shell was invisible but still occupying the page. */
/* ------------------------------------------------------------------------ */
@media print {
  @page { margin: 14mm; }

  html, body {
    background: #fff !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 11pt;
  }

  /* Keep badge and heading colours legible instead of washing out to grey. */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* Never print floating UI. */
  .toast-stack,
  .modal-footer,
  .modal-close,
  .sidebar-toggle { display: none !important; }

  /* --- Case 1: a dialog is open ----------------------------------------- */
  body.has-modal .app-shell { display: none !important; }

  body.has-modal .modal-backdrop {
    position: static !important;
    display: block !important;
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    z-index: auto !important;
  }
  body.has-modal .modal {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    animation: none !important;
  }
  body.has-modal .modal-body {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  body.has-modal .modal-header {
    padding: 0 0 10px !important;
    border-bottom: 1px solid #ddd !important;
  }

  /* A till receipt looks wrong stretched across a full page. */
  .pos-receipt { max-width: 92mm; margin: 0 auto; }

  /* --- Case 2: printing what's on screen -------------------------------- */
  body:not(.has-modal) .sidebar,
  body:not(.has-modal) .topbar,
  body:not(.has-modal) .tabs,
  body:not(.has-modal) .card-header .btn,
  body:not(.has-modal) .card-header input,
  body:not(.has-modal) .card-header select,
  body:not(.has-modal) .alert { display: none !important; }

  body:not(.has-modal) .app-shell { display: block !important; }
  body:not(.has-modal) .main-area { display: block !important; }
  body:not(.has-modal) .content {
    display: block !important;
    padding: 0 !important;
    max-width: none !important;
    overflow: visible !important;
  }
  /* Only the tab actually on screen should reach the paper. */
  body:not(.has-modal) .tab-panel { display: none !important; }
  body:not(.has-modal) .tab-panel.active { display: block !important; }

  /* --- Shared: make cards and tables behave on paper -------------------- */
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: auto;
    page-break-inside: auto;
    margin-bottom: 12px !important;
  }
  .table-wrap {
    overflow: visible !important;
    border: none !important;
    max-height: none !important;
  }
  table { width: 100% !important; border-collapse: collapse !important; font-size: 10pt !important; }
  thead { display: table-header-group; } /* repeat headers across pages */
  tr, .pos-cart-line, .stat-card { break-inside: avoid; page-break-inside: avoid; }
  img { max-width: 100% !important; }
}

/* Responsive shell */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .content { padding: 20px 16px 60px; }
  .sidebar-toggle { display: inline-flex !important; }
}
.sidebar-toggle { display: none; }
