:root {
  --primary: #223a63;
  --primary-dark: #16273f;
  --primary-light: #e8ecf3;
  --chrome: #152238;
  --chrome-active: #24395c;
  --chrome-text: rgba(255, 255, 255, .68);
  --accent: #223a63;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --text: #161e2b;
  --text-muted: #64748b;
  --border: #dde3ea;
  --danger: #ad4136;
  --danger-light: #f7e6e4;
  --success: #2f8f6f;
  --success-light: #e6f2ec;
  --warning: #a8710c;
  --warning-light: #f7edda;
  --radius: 8px;
  --shadow: none;
  --shadow-float: 0 10px 30px rgba(15, 23, 42, .16);
  --topbar-h: 56px;
  --sidebar-w: 222px;
  --bottom-nav-h: 60px;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  /* When a background image is set (state.js applyBackground()) it's applied as
     an inline background-image here; these properties make it cover the full
     screen and stay put while the page content scrolls. */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }

h1, h2, h3, .brand, .display-font { font-family: var(--font-display); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "topbar topbar" "sidebar content";
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--chrome);
  color: white;
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-toggle { display: none; color: white; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-display);
}
.topbar-spacer { flex: 1; }
.online-indicator {
  width: 9px; height: 9px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, .22);
}
.online-indicator.offline { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .25); }

.sidebar {
  grid-area: sidebar;
  background: var(--chrome);
  border-right: 1px solid rgba(255,255,255,.06);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* Stays in view while the content column scrolls, instead of scrolling away
     with the page - own scrollbar if the nav list itself is ever taller than
     the viewport. The mobile media query below overrides this back to a
     slide-out drawer, so this only affects the desktop/tablet layout. */
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--chrome-text);
  font-weight: 600;
  font-size: 13.5px;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active { background: var(--chrome-active); color: white; }
.nav-icon { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.nav-icon svg { display: block; }

/* A clickable row inside a light .card dropdown (e.g. item-search results) -
   .nav-link looks the same shape but its pale text color is only readable
   on the dark sidebar; this is that same shape for a white background. */
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.search-result-item:hover { background: var(--primary-light); }

.sidebar-backdrop { display: none; }

.content {
  grid-area: content;
  padding: 20px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 40px;
  /* Grid items default to min-width:auto, which let wide tables stretch the page past a phone screen. */
  min-width: 0;
}

.cards-grid > * { min-width: 0; }
.cards-grid.two-col { grid-template-columns: 1fr 1fr; }
.cards-grid.three-col { grid-template-columns: 1fr 1fr 1fr; }
.cards-grid.wide-narrow { grid-template-columns: 2fr 1fr; }
@media (max-width: 860px) {
  .cards-grid.two-col, .cards-grid.three-col, .cards-grid.wide-narrow { grid-template-columns: 1fr; }
}

[hidden] { display: none !important; }

/* ---------- signed out: brand bar and login card only ---------- */
body.logged-out .sidebar,
body.logged-out .sidebar-backdrop,
body.logged-out .bottom-nav,
body.logged-out .nav-toggle,
body.logged-out .account-btn,
body.logged-out .online-indicator { display: none !important; }
body.logged-out .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "content"; padding-bottom: 0; }

.login-wrap { min-height: calc(100vh - var(--topbar-h) - 60px); display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-float); padding: 28px; width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.login-brand h1 { margin: 0; font-size: 22px; }
.login-mark { width: 48px; height: 48px; font-size: 22px; font-family: var(--font-display); font-weight: 700; background: var(--chrome); color: white; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.login-secondary { margin-top: 10px; }
.notice { background: var(--warning-light); color: var(--warning); padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.form-error { background: var(--danger-light); color: var(--danger); padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.version-note { text-align: center; color: var(--text-muted); font-size: 12px; margin: 16px 0 0; }
.sidebar-version { margin-top: auto; padding: 10px 12px; color: rgba(255,255,255,.38); font-size: 11px; }

/* ---------- account button and menu ---------- */
.account-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 45vw;
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.16); color: white;
  border-radius: 8px; padding: 4px 12px 4px 4px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
}
.account-avatar {
  width: 26px; height: 26px; border-radius: 6px; background: rgba(255,255,255,.9); color: var(--chrome);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; font-family: var(--font-display);
}
.account-avatar.big { width: 44px; height: 44px; font-size: 20px; border-radius: 10px; background: var(--chrome); color: white; }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.menu-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- orders ---------- */
.tabs { overflow-x: auto; }
.tab-btn { white-space: nowrap; }
.order-total { display: flex; justify-content: flex-end; align-items: baseline; gap: 12px; margin-top: 12px; font-size: 16px; }
.order-total strong { font-size: 20px; font-family: var(--font-display); }

/* ---------- client shop ---------- */
.shop-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.shop-layout > * { min-width: 0; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.shop-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; cursor: pointer; }
.shop-card-photo {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; margin: -14px -14px 6px;
  background: var(--primary-light); display: flex; align-items: center; justify-content: center;
}
.shop-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.shop-card-photo .placeholder-icon { font-size: 34px; opacity: .55; }
.shop-card-name { font-weight: 700; }
.shop-card-price { font-size: 17px; font-weight: 700; margin-top: 6px; font-family: var(--font-display); }
.shop-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; flex-wrap: wrap; }
.shop-card-foot .btn { position: relative; z-index: 1; }
.shop-find-more { text-align: center; padding: 16px; }

/* ---------- product photo (stock + details) ---------- */
.product-thumb {
  width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none;
  background: var(--primary-light); vertical-align: middle;
}
.product-row-name { display: flex; align-items: center; gap: 10px; }
.detail-photo { width: 100%; max-height: 260px; object-fit: contain; border-radius: 8px; background: var(--primary-light); margin-bottom: 12px; }
.image-upload-preview { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; background: var(--primary-light); }
.image-upload-row { display: flex; align-items: center; gap: 12px; }
.cart { position: sticky; top: calc(var(--topbar-h) + 16px); }
.cart h2 { margin-top: 0; font-size: 18px; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) 72px 32px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cart-line-name { font-weight: 600; font-size: 14px; min-width: 0; }
.cart-line input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; width: 100%; }

@media (max-width: 860px) {
  .shop-layout { grid-template-columns: 1fr; }
  .cart { position: static; }
  .account-name { display: none; }
  .account-btn { padding: 4px; }
}

/* ---------- log out: always visible, clearly labelled ---------- */
.logout-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  background: rgba(255,255,255,.09); color: white; border: 1px solid rgba(255,255,255,.16); border-radius: 6px;
  padding: 7px 12px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.logout-btn:hover { background: rgba(255,255,255,.16); }
body.logged-out .logout-btn { display: none !important; }

/* ---------- bottom bar "More" opens the full menu ---------- */
button.bottom-link { background: none; border: none; font: inherit; cursor: pointer; padding: 0; }
.more-dots { font-size: 22px; line-height: 18px; font-weight: 800; }
.bottom-icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.bottom-icon svg { display: block; }

.bottom-nav { display: none; }

/* ---------- page header ---------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  margin-bottom: 18px;
}
.page-header h1 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.page-header .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .12s ease, transform .05s ease;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
  background: transparent; border: none; color: inherit; cursor: pointer;
  padding: 6px; border-radius: 8px; display: inline-flex;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }

/* ---------- cards / grid ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.stat-card-head { display: flex; align-items: center; justify-content: space-between; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-icon {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { display: block; }
.stat-card.warn .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.danger .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-card.success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: clamp(17px, 2.1vw, 22px);
  font-weight: 700;
  margin-top: 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.stat-card.warn .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2, .card h3 { margin-top: 0; font-size: 15px; font-weight: 700; }

/* ---------- activity log (Settings) - rendered from ACTIVITY_LOG.md ---------- */
.activity-log {
  margin-top: 12px;
  max-height: 520px;
  overflow-y: auto;
  padding: 4px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.activity-log h2 { font-size: 18px; margin: 18px 0 8px; }
.activity-log h3 { font-size: 15px; margin: 16px 0 6px; }
.activity-log h4 { font-size: 13.5px; margin: 12px 0 4px; }
.activity-log p { margin: 6px 0; line-height: 1.55; font-size: 13.5px; }
.activity-log ul { margin: 6px 0; padding-left: 20px; }
.activity-log li { margin: 3px 0; font-size: 13.5px; }
.activity-log hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.activity-log code { background: var(--primary-light); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.activity-log table { font-size: 13px; }

/* ---------- recent activity feed (Settings) ---------- */
.activity-row { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: none; }
.activity-row-icon { flex: none; width: 22px; text-align: center; font-size: 14px; }
.activity-row-body { flex: 1; min-width: 0; font-size: 13.5px; }

/* ---------- mini list (dashboard: top products, low stock, activity) - no horizontal scroll ---------- */
.mini-list { display: flex; flex-direction: column; }
.mini-list-head, .mini-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.mini-list-head { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); font-weight: 600; }
.mini-row:last-child { border-bottom: none; }
.mini-row.mini-row-link { cursor: pointer; }
.mini-row.mini-row-link:hover { background: var(--primary-light); margin: 0 -8px; padding: 9px 8px; border-radius: 6px; }
.mini-col-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-col-num { flex: none; width: 76px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-col-date { flex: none; width: 80px; color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }

/* ---------- dashboard: revenue trend mini chart ---------- */
.trend-chart-wrap { display: flex; align-items: flex-end; gap: 4px; height: 96px; margin-top: 6px; }
.trend-bar {
  flex: 1 1 0; min-width: 4px; background: var(--primary); border-radius: 3px 3px 0 0;
  min-height: 3px; cursor: default; transition: background .12s ease;
}
.trend-bar:hover { background: var(--primary-dark); }
.trend-chart-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11.5px; color: var(--text-muted); }

/* ---------- dashboard: quick actions ---------- */
.quick-actions { display: flex; flex-direction: column; gap: 8px; }
.quick-action {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.quick-action:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.quick-action .stat-icon { width: 24px; height: 24px; border-radius: 6px; }

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

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: #eef1f5; color: var(--text-muted); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid.single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px;
  background: var(--surface); color: var(--text); width: 100%; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.field-hint { font-size: 12px; color: var(--text-muted); }
.field-row { display: flex; gap: 10px; align-items: center; }
.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px 12px; }
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--primary-light); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.bulk-bar select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input, .search-bar select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; }
.search-bar input { flex: 1; min-width: 180px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; padding: 0;
}
.modal {
  background: var(--surface); border-radius: 14px 14px 0 0;
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  padding: 20px; box-shadow: var(--shadow-float);
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 14px; }
}

/* ---------- toast ---------- */
.toast-root { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--chrome); color: white; padding: 10px 16px; border-radius: 8px; font-size: 14px;
  box-shadow: var(--shadow-float); animation: fadeIn .15s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn { background: none; border: none; padding: 10px 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; font-size: 14px; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- line item rows (sale form) ---------- */
.line-item-row { display: grid; grid-template-columns: 2fr 90px 100px 100px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.line-item-row input, .line-item-row select { padding: 8px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 13.5px; width: 100%; }
.line-item-total { font-weight: 700; font-size: 13.5px; text-align: right; }

.loading { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 10px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- custom requests ---------- */
.request-photo { max-width: 320px; border-radius: 8px; margin-top: 8px; }

/* ---------- printed invoices / receipts (kept plain black-on-white regardless of theme) ---------- */
#print-area { display: none; }
/* Styled after the conventional Algerian business-invoice layout: centered
   letterhead, a two-column contact/registration block, a boxed document
   number + place/date bar, a bordered client box, a numbered items table and
   a bordered totals box with the amount spelled out in words underneath -
   used for both the sale invoice/combined invoice (sales.js) and the client-
   order proforma (orders.js). */
.invoice-doc { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #111; }
.invoice-doc .invoice-title { text-align: center; margin-bottom: 10px; }
.invoice-doc .invoice-title h1 { margin: 0; font-size: 22px; font-family: inherit; letter-spacing: .02em; }
.invoice-doc .invoice-title .invoice-subtitle { font-size: 13px; color: #444; margin-top: 2px; }
.invoice-doc .invoice-contact { display: flex; justify-content: space-between; gap: 20px; font-size: 12px; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 10px; }
.invoice-doc .invoice-contact > div { flex: 1; }
.invoice-doc .invoice-contact div div { margin: 1px 0; }
.invoice-doc .invoice-contact .invoice-contact-right { text-align: right; }
.invoice-doc .invoice-numberbar { display: flex; justify-content: space-between; align-items: center; margin: 12px 0; }
.invoice-doc .invoice-number-box { border: 1px solid #111; padding: 6px 14px; font-weight: 700; }
.invoice-doc .invoice-place-date { font-weight: 600; font-size: 13px; }
.invoice-doc .invoice-client-box { border: 1px solid #111; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.invoice-doc .invoice-client-box .invoice-client-label { font-weight: 700; margin-bottom: 4px; }
.invoice-doc table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 14px 0; }
.invoice-doc th, .invoice-doc td { border: 1px solid #ccc; padding: 6px 8px; text-align: left; }
.invoice-doc th { background: #f2f2f2; }
.invoice-doc th:last-child, .invoice-doc td:last-child, .invoice-doc .num { text-align: right; }
.invoice-doc .invoice-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 10px; flex-wrap: wrap; }
.invoice-doc .invoice-words { flex: 1; min-width: 220px; font-size: 12px; font-style: italic; }
.invoice-doc .invoice-totals { margin-left: auto; width: 260px; font-size: 14px; border: 1px solid #111; padding: 6px 10px; }
.invoice-doc .invoice-totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.invoice-doc .invoice-totals .grand { font-weight: 800; font-size: 15px; border-top: 1px solid #111; margin-top: 4px; padding-top: 6px; }
.invoice-doc .invoice-foot { margin-top: 24px; font-size: 12px; color: #555; text-align: center; }
.invoice-doc .invoice-note { margin-top: 14px; font-size: 12px; }

.receipt-doc { font-family: "Courier New", Consolas, monospace; color: #000; width: 100%; font-size: 12px; }
.receipt-doc .r-center { text-align: center; }
.receipt-doc .r-line { border-top: 1px dashed #000; margin: 6px 0; }
.receipt-doc .r-row { display: flex; justify-content: space-between; gap: 6px; }
.receipt-doc .r-item { margin: 4px 0; }
.receipt-doc .r-item .r-name { font-weight: 700; }
.receipt-doc .r-total { font-weight: 700; font-size: 14px; }

@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "content";
    padding-bottom: var(--bottom-nav-h);
  }
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
    width: 240px; transform: translateX(-100%);
    transition: transform .2s ease; z-index: 40;
    box-shadow: 4px 0 20px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.3); z-index: 30;
  }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-h);
    background: var(--surface); border-top: 1px solid var(--border); z-index: 25;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--text-muted); font-size: 10.5px; font-weight: 600;
  }
  .bottom-link.active { color: var(--primary); }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .line-item-row { grid-template-columns: 1fr; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
  .line-item-total { text-align: left; }
}
