/* ============================================================
   Fawtara – theme modelled on the reference video:
   soft grey canvas, white rounded cards, black sliding pill nav,
   orange count badges, black + soft-blue hero KPI cards,
   floating dark tool rail.
   ============================================================ */
:root {
  --bg: #f1f1ef;
  --surface: #ffffff;
  --surface-2: #f6f6f4;
  --surface-3: #ececea;
  --ink: #121316;
  --ink-2: #3a3b40;
  --muted: #85868c;
  --line: #e6e6e2;
  --pill: #121316;
  --pill-ink: #ffffff;
  --hero: #121316;
  --hero-ink: #ffffff;
  --hero-muted: #a7a8ad;
  --blue-soft: #c9d9f3;
  --blue-soft-ink: #1c2a44;
  --blue: #3e64b3;
  --orange: #e4572e;
  --orange-soft: #fbe3da;
  --green: #2f9e5b;
  --green-soft: #ddf1e4;
  --red: #d24343;
  --red-soft: #f9dfdf;
  --amber: #d0901a;
  --amber-soft: #fbeccc;
  --violet: #7b5cd6;
  --shadow: 0 1px 2px rgba(17, 18, 22, .04), 0 8px 24px rgba(17, 18, 22, .05);
  --shadow-lg: 0 24px 60px rgba(17, 18, 22, .18);
  --r: 20px;
  --r-sm: 12px;
  --font: "Plus Jakarta Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.22, .9, .3, 1);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0c0d0f;
  --surface: #16171a;
  --surface-2: #1c1d21;
  --surface-3: #24262b;
  --ink: #f2f2ef;
  --ink-2: #c9cacf;
  --muted: #8b8d94;
  --line: #26282d;
  --pill: #f2f2ef;
  --pill-ink: #121316;
  --hero: #f2f2ef;
  --hero-ink: #121316;
  --hero-muted: #6b6c72;
  --blue-soft: #22324e;
  --blue-soft-ink: #d6e2f7;
  --blue: #7fa2e6;
  --orange-soft: #3a2119;
  --green-soft: #15301f;
  --red-soft: #3a1a1a;
  --amber-soft: #382a10;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

[lang="ar"] { --font: "IBM Plex Sans Arabic", "Plus Jakarta Sans", system-ui, "Segoe UI", sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background .35s var(--ease), color .35s var(--ease);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
::selection { background: var(--blue-soft); }

/* ---------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
  padding: 14px 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--pill); color: var(--pill-ink);
  display: grid; place-items: center;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { justify-self: center; position: relative; display: flex; gap: 2px; padding: 4px; border-radius: 999px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-pill {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--pill); border-radius: 0; z-index: 0;
  clip-path: inset(0 100% 0 0 round 999px); pointer-events: none;
}
.nav a {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 999px; text-decoration: none; font-weight: 500; font-size: 13px;
  color: var(--ink-2); white-space: nowrap; transition: color .3s var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--pill-ink); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--orange); color: #fff;
  font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center; line-height: 1;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: transform .2s var(--ease), background .2s;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 7px; height: 7px; background: var(--orange); border-radius: 50%; border: 2px solid var(--surface); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: #cfe7e4; color: #1e4b46; font-weight: 700; font-size: 12px;
  display: grid; place-items: center; cursor: pointer; border: 0;
}
[data-theme="dark"] .avatar { background: #1f3a37; color: #bfe6e1; }

/* ---------------------------------------------------------- floating rail */
.rail {
  position: fixed; inset-inline-start: 18px; top: 50%; transform: translateY(-50%); z-index: 30;
  display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 999px;
  background: #121316; box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .rail { background: #23252a; }
.rail button {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: #d7d8dc; cursor: pointer;
  display: grid; place-items: center; position: relative; transition: background .2s, color .2s;
}
.rail button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.rail button svg { width: 17px; height: 17px; }
.rail button .tip {
  position: absolute; inset-inline-start: 50px; white-space: nowrap; background: var(--pill); color: var(--pill-ink);
  font-size: 12px; padding: 5px 10px; border-radius: 8px; opacity: 0; pointer-events: none; transform: translateX(-4px);
  transition: .2s var(--ease);
}
[dir="rtl"] .rail button .tip { transform: translateX(4px); }
.rail button:hover .tip { opacity: 1; transform: none; }

/* ---------------------------------------------------------- page shell */
.main { padding: 8px 32px 64px 96px; max-width: 1500px; margin: 0 auto; }
[dir="rtl"] .main { padding: 8px 96px 64px 32px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 18px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs span:last-child { color: var(--blue); }
.crumbs .sep { opacity: .6; }
h1.title { font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.head-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-chip {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: 999px; padding: 7px 16px;
  box-shadow: var(--shadow); font-size: 12px;
}
.status-chip .live { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.status-chip .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-chip.warn .live::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.status-chip small { display: block; color: var(--muted); font-size: 10.5px; }
.status-chip .meter { width: 56px; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.status-chip .meter i { display: block; height: 100%; background: var(--orange); border-radius: 4px; }

/* sub tabs (segmented pills) */
.tabs { position: relative; display: inline-flex; gap: 2px; padding: 4px; background: var(--surface-3); border-radius: 999px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tabs .nav-pill { background: var(--surface); box-shadow: var(--shadow); }
.tabs button {
  position: relative; z-index: 1; border: 0; background: transparent; padding: 7px 14px; border-radius: 999px;
  cursor: pointer; font-size: 12.5px; color: var(--muted); white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tabs button.active { color: var(--ink); font-weight: 600; }
.tabs .count { font-size: 10.5px; background: var(--surface-2); border-radius: 999px; padding: 1px 6px; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

/* ---------------------------------------------------------- cards & grid */
.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.g-hero { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.g-editor { grid-template-columns: minmax(0, 1fr) 320px; }
.card {
  background: var(--surface); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); min-width: 0;
  transition: background .35s var(--ease), transform .3s var(--ease);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13.5px; }
.card-title .ico { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; }
.card-title .ico svg { width: 14px; height: 14px; }
.kpi { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 10px; min-height: 128px; }
.kpi .label { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); }
.kpi .label .ico { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; }
.kpi .label .ico svg { width: 13px; height: 13px; }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.kpi .value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-inline-start: 4px; }
.kpi .foot { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .spark { position: absolute; inset-inline-end: 16px; top: 44px; width: 96px; height: 40px; }
.kpi.dark { background: var(--hero); color: var(--hero-ink); }
.kpi.dark .label, .kpi.dark .foot { color: var(--hero-muted); }
.kpi.dark .label .ico { background: rgba(127, 127, 127, .22); }
.kpi.blue { background: var(--blue-soft); color: var(--blue-soft-ink); }
.kpi.blue .label, .kpi.blue .foot { color: color-mix(in srgb, var(--blue-soft-ink) 65%, transparent); }
.kpi.blue .label .ico { background: rgba(255, 255, 255, .4); }
[data-theme="dark"] .kpi.blue .label .ico { background: rgba(255, 255, 255, .08); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.blue { background: var(--blue-soft); color: var(--blue-soft-ink); }
.tag.grey { background: var(--surface-3); color: var(--muted); }
.tag.orange { background: var(--orange-soft); color: var(--orange); }

/* greeting hero */
.hello .eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--orange); font-weight: 600; }
.hello h2 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 4px; }
.hello p { margin: 0; color: var(--ink-2); font-size: 13px; }
.hello p b { color: var(--ink); }
.hello p .warn { color: var(--orange); }
.timeline { position: relative; margin-top: 34px; height: 54px; }
.timeline .line { position: absolute; top: 12px; inset-inline: 0; height: 2px; background: var(--blue); opacity: .55; border-radius: 2px; }
.timeline .tick { position: absolute; top: 34px; font-size: 11px; color: var(--muted); transform: translateX(-50%); }
[dir="rtl"] .timeline .tick { transform: translateX(50%); }
.timeline .ev { position: absolute; top: 7px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); transform: translateX(-50%); cursor: default; }
[dir="rtl"] .timeline .ev { transform: translateX(50%); }
.timeline .now { position: absolute; top: -8px; width: 2px; height: 28px; background: var(--orange); }
.timeline .now span { position: absolute; bottom: 100%; inset-inline-start: 50%; transform: translateX(-50%); background: var(--orange); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
[dir="rtl"] .timeline .now span { transform: translateX(50%); }

/* ---------------------------------------------------------- buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: transform .18s var(--ease), background .2s, opacity .2s; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--pill); color: var(--pill-ink); border-color: var(--pill); }
.btn.accent { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field > span .req { color: var(--orange); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-sm);
  padding: 10px 12px; outline: none; transition: border .2s, background .2s, box-shadow .2s; min-width: 0;
}
.input:focus { border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 15%, transparent); }
.input.sm { padding: 7px 9px; font-size: 13px; border-radius: 10px; }
.search { position: relative; }
.search svg { position: absolute; top: 50%; inset-inline-start: 12px; width: 15px; height: 15px; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-inline-start: 36px; border-radius: 999px; background: var(--surface); min-width: 240px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 0; cursor: pointer; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .25s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on { background: var(--green); }
.switch.on::after { inset-inline-start: 19px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 22px 0 12px; }
.hint { font-size: 12px; color: var(--muted); }
.alert { border-radius: var(--r-sm); padding: 12px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert.red { background: var(--red-soft); color: var(--red); }
.alert.amber { background: var(--amber-soft); color: var(--amber); }
.alert.blue { background: var(--blue-soft); color: var(--blue-soft-ink); }
.alert.green { background: var(--green-soft); color: var(--green); }
.alert ul { margin: 4px 0 0; padding-inline-start: 18px; }
.alert > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.menu button svg, .card-title svg, .tag svg { width: 15px; height: 15px; flex: none; }

/* ---------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: start; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl .end { text-align: end; }
.tbl .strong { font-weight: 600; }
.tbl .sub { display: block; color: var(--muted); font-size: 11.5px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .4; margin-bottom: 8px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); }

/* lines editor */
.lines td { padding: 8px 6px; vertical-align: top; }
.lines .input.sm { background: var(--surface); }
.lines .tax-row { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.line-total { font-weight: 600; padding-top: 14px; text-align: end; white-space: nowrap; }
.totals { display: grid; gap: 8px; font-size: 13px; }
.totals .row { display: flex; justify-content: space-between; gap: 12px; }
.totals .row span:first-child { color: var(--muted); }
.totals .grand { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 4px; font-size: 20px; font-weight: 700; }
.totals .grand span:first-child { color: var(--ink); font-size: 14px; font-weight: 600; align-self: center; }

/* ---------------------------------------------------------- charts */
.chart { width: 100%; height: 220px; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 2 4; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-inline-end: 6px; }
.bars-io { display: flex; align-items: center; gap: 5px; height: 110px; margin: 16px 0 10px; }
.bars-io .b { flex: 1; display: flex; flex-direction: column; justify-content: center; height: 100%; position: relative; }
.bars-io .b i { display: block; width: 100%; border-radius: 2px; }
.bars-io .up { background: var(--green); align-self: stretch; }
.bars-io .dn { background: var(--orange); }
.funnel .row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; font-size: 12.5px; }
.funnel .bar { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.funnel .bar i { display: block; height: 100%; border-radius: 6px; background: var(--ink-2); transition: width .8s var(--ease); }
.gauge { max-width: 260px; display: block; margin: auto; }
.gauge text { font-family: var(--font); }

/* ---------------------------------------------------------- POS */
.pos { display: grid; grid-template-columns: 1fr 400px; gap: 14px; align-items: start; }
.pos-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pos-item {
  text-align: start; border: 1px solid var(--line); background: var(--surface-2); border-radius: 16px; padding: 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; min-height: 110px; transition: transform .18s var(--ease), border .2s, background .2s;
}
.pos-item:hover { transform: translateY(-2px); border-color: var(--ink-2); background: var(--surface); }
.pos-item .nm { font-weight: 600; font-size: 13px; }
.pos-item .pr { margin-top: auto; font-weight: 700; }
.pos-item .cd { font-size: 11px; color: var(--muted); }
.cart { position: sticky; top: 84px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.qty { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 999px; padding: 2px; }
.qty button { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--surface); cursor: pointer; }
.qty input { width: 52px; text-align: center; border: 0; background: transparent; outline: none; }
.pay-methods { display: flex; flex-wrap: wrap; gap: 6px; }
.pay-methods button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 12px; }
.pay-methods button.on { background: var(--pill); color: var(--pill-ink); border-color: var(--pill); }

/* ---------------------------------------------------------- document view / print */
.doc-paper { background: var(--surface); border-radius: var(--r); padding: 36px; box-shadow: var(--shadow); }
.doc-paper .doc-top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 20px; }
.doc-paper h2 { margin: 0 0 4px; font-size: 22px; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.party { background: var(--surface-2); border-radius: 14px; padding: 14px 16px; font-size: 12.5px; }
.party b { display: block; font-size: 14px; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.receipt-paper { width: 320px; margin: 0 auto; background: #fff; color: #111; padding: 18px; border-radius: 6px; font-size: 12px; box-shadow: var(--shadow); }
.receipt-paper .c { text-align: center; }
.receipt-paper hr { border: 0; border-top: 1px dashed #999; margin: 10px 0; }
.receipt-paper table { width: 100%; border-collapse: collapse; }
.receipt-paper td { padding: 2px 0; vertical-align: top; }
pre.json { background: var(--surface-2); border-radius: 12px; padding: 14px; max-height: 420px; overflow: auto; font-size: 11.5px; direction: ltr; text-align: left; }

/* ---------------------------------------------------------- modal, toast, menu, palette */
.overlay { position: fixed; inset: 0; background: rgba(10, 10, 12, .38); backdrop-filter: blur(3px); z-index: 80; display: grid; place-items: center; padding: 20px; animation: fade .2s; }
.modal { background: var(--surface); border-radius: 22px; width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: var(--shadow-lg); animation: pop .28s var(--ease); }
.modal.sm { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.toasts { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--pill); color: var(--pill-ink); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: 380px; animation: slide .3s var(--ease); display: flex; gap: 10px; align-items: center; }
.toast.err::before, .toast.ok::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.toast.err::before { background: var(--red); }
.toast.ok::before { background: var(--green); }
.menu { position: absolute; z-index: 90; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; border: 1px solid var(--line); animation: pop .2s var(--ease); }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: transparent; padding: 9px 12px; border-radius: 10px; cursor: pointer; text-align: start; font-size: 13px; }
.menu button:hover { background: var(--surface-2); }
.menu .who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 12px; }
.palette { width: min(560px, 100%); align-self: start; margin-top: 12vh; }
.palette .input { border: 0; background: transparent; font-size: 16px; padding: 18px 20px; box-shadow: none; }
.palette-list { border-top: 1px solid var(--line); max-height: 50vh; overflow: auto; padding: 6px; }
.palette-list button { display: flex; width: 100%; justify-content: space-between; border: 0; background: transparent; padding: 10px 14px; border-radius: 10px; cursor: pointer; text-align: start; }
.palette-list button:hover, .palette-list button.sel { background: var(--surface-2); }

/* ---------------------------------------------------------- auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--hero); color: var(--hero-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side h2 { font-size: 38px; letter-spacing: -.03em; line-height: 1.1; margin: 0; max-width: 460px; }
.auth-side p { color: var(--hero-muted); max-width: 420px; }
.auth-side .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.auth-side .chips span { border: 1px solid rgba(127,127,127,.35); border-radius: 999px; padding: 6px 12px; font-size: 12px; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form form { width: min(380px, 100%); display: grid; gap: 14px; }
.auth-form h1 { margin: 0 0 6px; font-size: 26px; }
.auth-tools { position: absolute; top: 20px; inset-inline-end: 20px; display: flex; gap: 8px; }

/* ---------------------------------------------------------- bulk bar, import, licence, credit */
.bulk-bar {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; border-radius: 999px;
  background: var(--pill); color: var(--pill-ink); box-shadow: var(--shadow-lg); animation: slide .3s var(--ease);
  max-width: calc(100vw - 32px); overflow-x: auto; white-space: nowrap; font-size: 13px;
}
[dir="rtl"] .bulk-bar { padding: 8px 16px 8px 10px; }
.bulk-bar .sep { width: 1px; height: 20px; background: color-mix(in srgb, var(--pill-ink) 25%, transparent); margin: 0 4px; }
.bulk-bar .btn { background: transparent; color: var(--pill-ink); border-color: color-mix(in srgb, var(--pill-ink) 22%, transparent); }
.bulk-bar .btn.primary { background: var(--pill-ink); color: var(--pill); }
.bulk-bar .btn.danger { color: #ff8f7a; }
.tbl input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; }
.drop {
  border: 2px dashed var(--line); border-radius: 16px; padding: 28px; background: var(--surface-2); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); transition: border .2s, background .2s;
}
.drop svg { width: 26px; height: 26px; }
.drop.over, .drop:hover { border-color: var(--blue); background: var(--surface); }
.lic-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.lic-banner .grow { flex: 1; }
.machine-code { font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: .08em; font-weight: 600; direction: ltr; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.credit { text-align: center; color: var(--muted); font-size: 12px; padding: 28px 0 8px; }
.credit a { color: var(--ink-2); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--line); }
.credit a:hover { color: var(--blue); border-color: var(--blue); }
.auth-side .credit { text-align: start; padding: 0; color: var(--hero-muted); }
.auth-side .credit a { color: var(--hero-ink); border-color: rgba(127,127,127,.4); }

/* ---------------------------------------------------------- motion */
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slide { from { opacity: 0; transform: translateY(12px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.view > * { animation: rise .5s var(--ease) both; }
.view > *:nth-child(2) { animation-delay: .04s; }
.view > *:nth-child(3) { animation-delay: .08s; }
.view > *:nth-child(4) { animation-delay: .12s; }
.view > *:nth-child(5) { animation-delay: .16s; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-hero, .g-main, .g-editor, .pos { grid-template-columns: minmax(0, 1fr); }
  .cart { position: static; }
}
@media (max-width: 860px) {
  .topbar { grid-template-columns: auto auto; padding: 12px 16px; row-gap: 10px; }
  .nav { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .main, [dir="rtl"] .main { padding: 4px 16px 96px; }
  .rail { top: auto; bottom: 16px; inset-inline-start: 50%; transform: translateX(-50%); flex-direction: row; }
  [dir="rtl"] .rail { transform: translateX(50%); }
  .rail button .tip { display: none; }
  .g-2, .g-4, .parties { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .form-grid .span-2 { grid-column: auto; }
  .doc-paper { padding: 20px; }
  .search .input { min-width: 0; }
}

/* ---------------------------------------------------------- print */
@media print {
  body { background: #fff; color: #111; }
  .topbar, .rail, .page-head, .no-print, .toasts, .bulk-bar, .lic-banner { display: none !important; }
  .main { padding: 0 !important; max-width: none; }
  .doc-paper, .receipt-paper { box-shadow: none; padding: 0; }
  .card { box-shadow: none; }
}
