/* FashionBiz Manager — app styles
   Palette taken from the workshop: indigo dye, tailor's chalk,
   tape-measure yellow, thread green and pin red. */
:root {
  --ink: #1E2A5A;
  --ink-2: #2B3A78;
  --ink-soft: #E8EBF5;
  --chalk: #F5F6FA;
  --paper: #FFFFFF;
  --tape: #F2C230;
  --tape-soft: #FDF3D2;
  --thread: #2F7D5B;
  --thread-soft: #E3F2EA;
  --pin: #C2412D;
  --pin-soft: #FBE7E3;
  --text: #1F2533;
  --muted: #5E6678;
  --line: #DCE0EA;
  --line-2: #ECEEF4;
  --focus: #F2C230;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(30, 42, 90, .06), 0 4px 16px rgba(30, 42, 90, .06);
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --nav-w: 232px;
  /* Theme colours a business can change in Settings → Branding. */
  --on-ink: #FFFFFF;
  --nav-bg: #1E2A5A;
  --nav-fg: #FFFFFF;
  --nav-muted: rgba(255,255,255,.72);
  --nav-faint: rgba(255,255,255,.5);
  --nav-hover: rgba(255,255,255,.07);
  --nav-line: rgba(255,255,255,.12);
  --nav-on: rgba(242,194,48,.16);
}
svg { max-width: 100%; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--chalk);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--ink-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); line-height: 1.2; margin: 0; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; font-family: var(--font); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; white-space: nowrap; }
.neg { color: var(--pin); }
.pos { color: var(--thread); }
.hidden { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav {
  background: var(--nav-bg);
  color: var(--nav-fg);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 18px 12px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-logo { width: 40px; height: 40px; flex: none; border-radius: 8px; object-fit: cover; background: #fff; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 17px; line-height: 1.15; word-break: break-word; }
.brand-biz { font-size: 11.5px; color: var(--nav-muted); line-height: 1.3; margin-top: 2px; }
.switcher {
  width: 100%; margin: 0 0 14px; padding: 8px 10px;
  background: var(--nav-hover); color: var(--nav-fg);
  border: 1px solid var(--nav-line); border-radius: var(--radius-sm);
}
.switcher option { color: var(--text); }
.nav a.item {
  display: flex; align-items: center; gap: 10px;
  color: var(--nav-muted); text-decoration: none;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-weight: 500;
}
.nav a.item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a.item:hover { background: var(--nav-hover); color: var(--nav-fg); }
.nav a.item.on { background: var(--nav-on); color: var(--nav-fg); box-shadow: inset 3px 0 0 var(--tape); }
.nav .group { margin-top: 14px; padding: 0 10px 4px; font-size: 12px; color: var(--nav-faint); }
.nav .foot { margin-top: auto; padding: 14px 8px 0; font-size: 13px; color: var(--nav-muted); border-top: 1px solid var(--nav-line); }
.nav .foot a { color: var(--nav-fg); }
.nav .switcher option { color: #1F2533; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .spacer { flex: 1; }
.net { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 4px 10px; border-radius: 999px; background: var(--chalk); text-decoration: none; }
.net .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--thread); }
.net.off .dot { background: var(--pin); }
.net.pending .dot { background: var(--tape); }
.support-bar { background: var(--tape-soft); color: var(--text); padding: 8px 28px; font-size: 14px; border-bottom: 1px solid #EBD58A; }
.content { padding: 24px 28px 96px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head .actions select { width: auto; }
.back { display: inline-block; margin-bottom: 8px; font-size: 14px; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--ink); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--ink); background: var(--ink); color: var(--on-ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--ink-2); }
.btn.alt { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.alt:hover { border-color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); padding: 6px 10px; }
.btn.ghost:hover { background: var(--ink-soft); }
.btn.danger { background: var(--paper); color: var(--pin); border-color: #E9B8AF; }
.btn.danger:hover { background: var(--pin-soft); }
.btn.tape { background: var(--tape); border-color: var(--tape); color: var(--ink); }
.btn.sm { padding: 6px 10px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.field .err { font-size: 13px; color: var(--pin); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=time], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper);
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink-2); outline: none; box-shadow: 0 0 0 3px var(--ink-soft); }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--pin); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 16px; }
.grid .span2 { grid-column: 1 / -1; }
.grid3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar input[type=search] { width: 100%; max-width: 320px; }

/* ---------- Surfaces ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-head .spacer { flex: 1; }
.cols { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); gap: 16px; align-items: start; }
.cols > div > .panel + .panel { margin-top: 16px; }
.cols > *, .cols2 > *, .grid > *, .order-head > * { min-width: 0; }
.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; align-items: start; }

/* Dashboard stat strip: one ruled band rather than a row of boxes */
.strip {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 16px; overflow: hidden;
}
.strip a, .strip div.stat { padding: 16px 18px; text-decoration: none; color: inherit; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); display: block; }
.strip > :nth-child(4n) { border-right: 0; }
.strip > :nth-last-child(-n+4) { border-bottom: 0; }
.strip a:hover { background: var(--chalk); }
.stat .v { font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat.alert .v { color: var(--pin); }
.stat.good .v { color: var(--thread); }

/* ---------- Tables & lists ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.num, .table td.num { text-align: right; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #FAFBFD; }
.table .strong { font-weight: 600; color: var(--text); }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list li .grow { flex: 1; min-width: 0; }
.list li a { text-decoration: none; color: inherit; }
.list li a:hover .t { color: var(--ink-2); text-decoration: underline; }
.list .t { font-weight: 600; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 10px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 14px; color: var(--muted); }

/* Status pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--ink-soft); color: var(--ink); white-space: nowrap; }
.pill.prod { background: var(--tape-soft); color: #7A5A00; }
.pill.ready { background: var(--thread-soft); color: var(--thread); }
.pill.done { background: #EEF0F4; color: var(--muted); }
.pill.bad { background: var(--pin-soft); color: var(--pin); }
.pill.quote { background: #F0EAF8; color: #5B3E8C; }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; background: var(--chalk); color: var(--muted); border: 1px solid var(--line); }
.tag.warn { background: var(--tape-soft); border-color: #EBD58A; color: #7A5A00; }
.tag.bad { background: var(--pin-soft); border-color: #E9B8AF; color: var(--pin); }

/* ---------- The tape measure: order progress ---------- */
.tape {
  position: relative; height: 40px; border-radius: 4px;
  background:
    repeating-linear-gradient(90deg, rgba(30,42,90,.55) 0 1px, transparent 1px 8px) bottom / 100% 7px no-repeat,
    repeating-linear-gradient(90deg, rgba(30,42,90,.7) 0 1px, transparent 1px 40px) bottom / 100% 13px no-repeat,
    var(--tape);
  overflow: hidden;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.08);
}
.tape .fill { position: absolute; inset: 0 auto 0 0; background: var(--ink); transition: width .5s ease; }
.tape .fill::after { content: ""; position: absolute; right: -6px; top: 0; bottom: 0; width: 12px; background: var(--ink); clip-path: polygon(0 0, 50% 50%, 0 100%); }
.tape-stages { display: grid; margin-top: 6px; font-size: 12px; color: var(--muted); }
.tape-stages span { text-align: center; padding: 0 2px; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.tape-stages span.on { color: var(--ink); font-weight: 700; }
.tape-stages span.past { color: var(--text); }
.tape.cancelled { background: repeating-linear-gradient(135deg, var(--pin-soft) 0 10px, #F6D3CC 10px 20px); }
.mini-tape { width: 84px; height: 8px; border-radius: 2px; background: var(--tape); position: relative; overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-tape i { position: absolute; inset: 0 auto 0 0; background: var(--ink); }

/* Order header */
.order-head { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; margin-bottom: 18px; }
.order-head .money { text-align: right; min-width: 190px; }
.order-head .money .big { font-family: var(--display); font-size: 28px; font-weight: 700; color: var(--ink); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 12px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
.timeline li.fitting::before { border-color: var(--tape); background: var(--tape); }
.timeline li.quality_check::before { border-color: var(--thread); }
.timeline li .when { font-size: 12px; color: var(--muted); }

/* Items editor */
.items-editor .row { display: grid; grid-template-columns: 1.2fr 1.6fr 80px 120px 110px 36px; gap: 8px; align-items: end; margin-bottom: 8px; }
.items-editor .row .lt { text-align: right; padding-bottom: 10px; font-weight: 600; }
.items-editor .hdr { font-size: 12px; color: var(--muted); font-weight: 600; }
.sum { margin-left: auto; width: min(320px, 100%); font-size: 14px; }
.sum div { display: flex; justify-content: space-between; padding: 4px 0; }
.sum .tot { font-weight: 700; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; font-size: 16px; }

/* Measurement grid */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 14px; }
.mview { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px 14px; }
.mview div { border-bottom: 1px dotted var(--line); padding: 4px 0; display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.mview div span { color: var(--muted); }

/* Bars chart */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; height: 150px; padding-top: 10px; }
.bars .m { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .pair i { display: block; width: 40%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .in { background: var(--ink); }
.bars .out { background: var(--tape); }
.bars .lbl { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--tape); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; text-decoration: none; }
.chip.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip .n { opacity: .7; margin-left: 4px; }

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 26, 50, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { background: var(--paper); border-radius: var(--radius); width: min(640px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(920px, 100%); }
.modal header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal header h2 { flex: 1; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line-2); background: #FAFBFD; border-radius: 0 0 var(--radius) var(--radius); }
.form-error { background: var(--pin-soft); color: var(--pin); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 12px; }
.notice { background: var(--tape-soft); border-left: 4px solid var(--tape); padding: 10px 14px; border-radius: 4px; font-size: 14px; margin-bottom: 14px; }
.notice.info { background: var(--ink-soft); border-left-color: var(--ink); }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--text); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 14px; animation: rise .2s ease; }
.toast.bad { background: var(--pin); }
.toast.ok { background: var(--thread); }
.toast.offline { background: #7A5A00; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.dropdown { position: relative; display: inline-block; }
.dropdown .menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); min-width: 210px; z-index: 20; padding: 4px; }
.dropdown .menu button { display: block; width: 100%; text-align: left; padding: 8px 12px; background: none; border: 0; border-radius: 4px; cursor: pointer; }
.dropdown .menu button:hover { background: var(--chalk); }

/* Mobile bottom bar */
.tabbar { display: none; }

@media (max-width: 1000px) {
  .cols, .cols2 { grid-template-columns: 1fr; }
  .strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .strip > :nth-child(4n) { border-right: 1px solid var(--line-2); }
  .strip > :nth-child(2n) { border-right: 0; }
  .strip > :nth-last-child(-n+4) { border-bottom: 1px solid var(--line-2); }
  .strip > :nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .nav.open { transform: none; box-shadow: 0 0 0 100vmax rgba(20,26,50,.4); }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 110px; }
  .support-bar { padding: 8px 16px; }
  .menu-btn { display: inline-flex !important; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--paper); border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 11px; font-weight: 600; text-decoration: none; color: var(--muted); border-radius: 6px; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--ink); background: var(--ink-soft); }
  .grid, .grid3 { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .order-head { grid-template-columns: 1fr; }
  .order-head .money { text-align: left; min-width: 0; }
  .stat .v { font-size: 20px; }
  .tape-stages { overflow: hidden; }
  .tape-stages span { visibility: hidden; font-size: 0; }
  .tape-stages span.on { visibility: visible; font-size: 12px; white-space: nowrap; }
  .tape-stages span.on:first-child { text-align: left; }
  .tape-stages span.on:last-child { text-align: right; }
  .items-editor .row { grid-template-columns: 1fr 1fr 70px; }
  .items-editor .row .desc { grid-column: 1 / -1; order: -1; }
  .items-editor .row .lt { grid-column: 1 / 3; text-align: left; padding: 0; }
  .items-editor .hdr { display: none; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: 8px; }
  /* Stack table rows as cards on phones */
  .table.stack thead { display: none; }
  .table.stack tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
  .table.stack td { border: 0; padding: 0; }
  .table.stack td.hide-sm { display: none; }
  .table.stack td.num { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; display: flex; flex-direction: column; }
  .modal .body { overflow-y: auto; }
}
.menu-btn { display: none !important; }

@media print {
  .nav, .topbar, .tabbar, .page-head .actions, .toolbar, .chips, .btn { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .panel { border: 0; padding: 0; }
}

/* ================= 1.2: search, notifications, files, chat ================= */
.search { position: relative; display: flex; align-items: center; flex: 0 1 340px; min-width: 0; }
.search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 32px; background: var(--chalk); border-color: transparent; }
.search input:focus { background: var(--paper); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 280px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 30; max-height: 70vh; overflow-y: auto; padding: 4px; }
.sr-group { font-size: 12px; color: var(--muted); padding: 8px 10px 2px; font-weight: 600; }
.sr-item { display: block; padding: 7px 10px; border-radius: 4px; text-decoration: none; color: inherit; }
.sr-item:hover, .sr-item:focus { background: var(--chalk); }
.sr-item .t { font-weight: 600; }
.sr-empty { padding: 12px; color: var(--muted); font-size: 14px; }
.bell-wrap { position: relative; }
.bell { position: relative; padding: 6px 8px; }
.bell svg { width: 20px; height: 20px; }
.badge { position: absolute; top: 0; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--pin); color: #fff; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; }
.bell-panel { position: absolute; right: 0; top: calc(100% + 6px); width: min(360px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(20,26,50,.18); z-index: 40; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--paper); }
.bell-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: inherit; }
.bell-item:hover { background: var(--chalk); }
.bell-item.unread { box-shadow: inset 3px 0 0 var(--tape); background: #FFFCF0; }
.bell-item .t { font-weight: 600; font-size: 14px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.file { min-width: 0; }
.file .thumb { display: block; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--chalk); border: 1px solid var(--line); }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file .pdf { display: grid; place-items: center; height: 100%; font-weight: 700; color: var(--pin); }
.file-name { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; max-height: 420px; overflow-y: auto; padding: 2px; }
.bubble { max-width: 82%; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.bubble.customer { align-self: flex-start; background: var(--chalk); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.bubble.staff { align-self: flex-end; background: var(--ink-soft); border-bottom-right-radius: 3px; }
.bubble .files { margin-top: 6px; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.chat-reply { display: flex; gap: 8px; align-items: flex-end; }
.chat-reply textarea { min-height: 44px; }
.invite-code { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: .08em; color: var(--ink); background: var(--tape-soft); border: 2px dashed var(--tape); border-radius: var(--radius); text-align: center; padding: 10px; }
.invite-msg { white-space: pre-wrap; font: 14px/1.5 var(--font); background: var(--chalk); padding: 12px; border-radius: var(--radius-sm); }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix input { width: 18px; height: 18px; accent-color: var(--ink); }
.note-box { background: var(--chalk); border-left: 3px solid var(--ink); padding: 8px 12px; border-radius: 4px; margin-top: 8px; font-size: 14px; }
.stars { color: var(--tape); font-size: 18px; letter-spacing: 2px; }
.hidden-input, .trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ================= Training ================= */
.lvl { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.lvl i { width: 16px; height: 8px; border-radius: 2px; background: var(--line); display: inline-block; position: relative; }
.lvl i.on { background: var(--thread); }
.lvl i.req::after { content: ""; position: absolute; right: -2px; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }
.lvl .small { margin-left: 6px; color: var(--muted); }
.bar { display: inline-block; width: 100%; height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--ink); }
.bar.warn i { background: var(--tape); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.seg-b { border: 0; background: var(--paper); padding: 7px 11px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; border-right: 1px solid var(--line); }
.seg-b:last-child { border-right: 0; }
.seg-b.on.present { background: var(--thread); color: #fff; }
.seg-b.on.late { background: var(--tape); color: var(--ink); }
.seg-b.on.absent { background: var(--pin); color: #fff; }
.seg-b.on.excused { background: var(--ink-2); color: #fff; }
.seg-b:disabled { cursor: default; }
.days { display: flex; flex-wrap: wrap; gap: 4px; }
.day { width: 26px; height: 26px; border-radius: 4px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--line-2); color: var(--muted); }
.day.present { background: var(--thread-soft); color: var(--thread); }
.day.late { background: var(--tape-soft); color: #7A5A00; }
.day.absent { background: var(--pin-soft); color: var(--pin); }
.day.excused { background: var(--ink-soft); color: var(--ink); }
.day.pending { outline: 2px dashed var(--tape); outline-offset: -2px; }
.day-tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--line-2); }
.day-tag.present { background: var(--thread-soft); color: var(--thread); }
.day-tag.late { background: var(--tape-soft); color: #7A5A00; }
.day-tag.absent { background: var(--pin-soft); color: var(--pin); }
.lesson { border-bottom: 1px solid var(--line-2); padding: 10px 0; }
.lesson summary { cursor: pointer; }
.lesson-body { white-space: pre-line; line-height: 1.65; }
.lesson-body.big { font-size: 16px; max-width: 72ch; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover { border-color: var(--ink-2); }
.card-link + .card-link { margin-top: 0; }
.matrix-skills td.lv { font-weight: 700; color: var(--muted); }
.matrix-skills td.lv2 { background: var(--tape-soft); color: #7A5A00; }
.matrix-skills td.met { background: var(--thread-soft); color: var(--thread); }
.matrix-skills td.lv1 { background: var(--pin-soft); color: var(--pin); }
.checkin { display: flex; gap: 14px; align-items: center; justify-content: space-between; background: var(--ink); color: var(--on-ink); padding: 16px 18px; border-radius: var(--radius); margin-bottom: 16px; flex-wrap: wrap; }
.checkin .small { color: #C9D0EA; }
.checkin.done { justify-content: flex-start; background: var(--thread-soft); color: var(--text); }
.checkin.done .small { color: var(--muted); }
.checkin.done > svg { width: 26px; height: 26px; color: var(--thread); flex: none; }
.checkin .btn svg { width: 18px; height: 18px; }
.rings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.ring-box { display: flex; gap: 12px; align-items: center; min-width: 0; }
.ring { --p: 0; width: 64px; height: 64px; flex: none; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--ink) calc(var(--p) * 1%), var(--line-2) 0); }
.ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--ink); }
.next-lesson { display: block; text-decoration: none; color: inherit; background: var(--tape-soft); border: 1px solid #EBD58A; border-radius: var(--radius); padding: 14px; }
.next-lesson .t { font-family: var(--display); font-size: 18px; font-weight: 700; color: var(--ink); }
.lessons { margin: 0; padding-left: 22px; }
.lessons li { padding: 10px 0; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.lessons li a { text-decoration: none; color: inherit; flex: 1; }
.lessons li .t { font-weight: 600; }
.lessons li.completed .t { color: var(--muted); }
.result { border-left: 4px solid var(--thread); }
.result.returned { border-left-color: var(--pin); }

/* ================= Customer portal ================= */
body.portal { background: var(--chalk); }
.p-shell { min-height: 100vh; display: flex; flex-direction: column; }
.p-top { display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: var(--nav-bg); color: var(--nav-fg); position: sticky; top: 0; z-index: 20; }
.p-top .net { background: rgba(255,255,255,.1); color: #D7DCF0; }
.p-top .bell { color: #fff; }
.p-top .bell:hover { background: rgba(255,255,255,.1); }
.p-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.p-logo { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: #fff; }
.p-mono { width: 38px; height: 38px; border-radius: 8px; background: var(--tape); color: var(--ink); display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 20px; }
.p-biz { font-family: var(--display); font-weight: 700; font-size: 17px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-out { color: #D7DCF0; font-size: 14px; }
.tape-strip { height: 10px; background: repeating-linear-gradient(90deg, rgba(30,42,90,.55) 0 1px, transparent 1px 8px) bottom / 100% 5px no-repeat, repeating-linear-gradient(90deg, rgba(30,42,90,.75) 0 1px, transparent 1px 40px) bottom / 100% 9px no-repeat, var(--tape); }
.p-nav { display: flex; gap: 4px; padding: 0 24px; background: var(--paper); border-bottom: 1px solid var(--line); overflow-x: auto; }
.p-nav a { display: flex; align-items: center; gap: 6px; padding: 12px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.p-nav a svg { width: 18px; height: 18px; }
.p-nav a.on { color: var(--ink); border-bottom-color: var(--tape); }
.p-content { max-width: 1080px; margin: 0 auto; }
.p-orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.p-order { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: inherit; }
.p-order:hover { border-color: var(--ink-2); }
.p-order-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.p-order-head .t { font-family: var(--display); font-weight: 700; font-size: 17px; color: var(--ink); }
.p-order .tape { height: 26px; }
.p-order .tape-stages { display: none; }
.p-order-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 14px; }
.owed { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--tape); border-radius: var(--radius); padding: 14px 18px; }
.owed .big { font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--ink); }
.rate { display: flex; gap: 4px; margin: 4px 0 10px; }
.star { font-size: 30px; line-height: 1; background: none; border: 0; color: var(--line); cursor: pointer; padding: 2px; }
.star.on { color: var(--tape); }
.join { min-height: 100vh; display: flex; flex-direction: column; }
.join-top { background: var(--nav-bg); color: var(--nav-fg); padding: 48px 20px 28px; text-align: center; }
.join-top h1 { color: var(--nav-fg); font-size: 28px; }
.join-top p { color: #C9D0EA; margin: 8px auto 0; max-width: 460px; }
.join-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(460px, calc(100% - 32px)); margin: 24px auto; }
.join-card h2 { margin-bottom: 8px; }
.join-card .code-input { font-size: 20px; letter-spacing: .06em; text-align: center; }
.check.field { flex-direction: row; }

@media (max-width: 820px) {
  .search { flex: 1 1 auto; }
  .topbar strong { display: none; }
  .rings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .p-top { padding: 10px 16px; }
  .p-top .p-out, .p-top .net { display: none; }
  .p-nav { padding: 0 8px; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; border-top: 1px solid var(--line); border-bottom: 0; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom); }
  .p-nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 8px 6px; border-bottom: 0; border-top: 2px solid transparent; }
  .p-nav a.on { border-top-color: var(--tape); }
  .p-nav a svg { width: 22px; height: 22px; }
  .p-content { padding-bottom: 100px; }
  .p-orders { grid-template-columns: 1fr; }
  .seg-b { padding: 7px 8px; }
  .bubble { max-width: 92%; }
}

/* ---------- Branding settings ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.swatch { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border: 1px solid var(--line); border-radius: 99px; background: var(--paper); cursor: pointer; font-size: 13px; }
.swatch i { width: 22px; height: 22px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.swatch:hover { border-color: var(--ink); }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); flex: none; }
.color-field input[type=text] { flex: 1; text-transform: uppercase; }
.img-pick { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.img-pick img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--chalk); }
.img-pick img.wide { width: 140px; }
.brand-preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: grid; grid-template-columns: 150px 1fr; min-height: 190px; }
.brand-preview .pv-nav { padding: 14px 10px; background: var(--nav-bg); color: var(--nav-fg); font-size: 12px; }
.brand-preview .pv-nav .pv-item { padding: 6px 8px; border-radius: 6px; color: var(--nav-muted); }
.brand-preview .pv-nav .pv-item.on { background: var(--nav-on); color: var(--nav-fg); box-shadow: inset 3px 0 0 var(--tape); }
.brand-preview .pv-main { background: var(--chalk); padding: 14px; }
.brand-preview .pv-card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.login-preview { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); display: grid; grid-template-columns: 1.2fr 1fr; min-height: 210px; font-size: 13px; }
.login-preview .lp-hero { padding: 18px; color: #fff; background-size: cover; background-position: center; display: flex; flex-direction: column; justify-content: flex-end; }
.login-preview .lp-form { padding: 18px; background: #F5F6FA; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.login-preview .lp-form i { display: block; height: 26px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.login-preview .lp-form b { display: block; height: 30px; border-radius: 6px; }
@media (max-width: 640px) { .brand-preview, .login-preview { grid-template-columns: 1fr; } }

.license-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 9px 24px; background: var(--tape-soft); border-bottom: 1px solid var(--line); font-size: 14px; }
.license-bar.bad { background: var(--pin-soft); color: #7A2416; }
.lic-code { font: 600 22px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .06em; color: var(--ink); background: var(--chalk); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 14px; display: inline-block; }

/* Online shop (products) */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.prod-card { background: var(--card, #fff); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.prod-card:hover { border-color: var(--ink); }
.prod-ph { aspect-ratio: 4 / 5; background: var(--line-2, #EEF0F4); display: grid; place-items: center; overflow: hidden; }
.prod-ph img { width: 100%; height: 100%; object-fit: cover; }
.prod-b { padding: 10px 12px 12px; display: grid; gap: 4px; }
.prod-b .t { font-weight: 600; line-height: 1.3; }
.prod-b .pill { justify-self: start; }
.prod-edit { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .prod-edit { grid-template-columns: 1fr; } }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.share-row .share-wa { background: #1FA855; color: #fff; }
.share-row .share-fb { background: #1877F2; color: #fff; }
.share-row .share-x { background: #111; color: #fff; }
.linkbox { background: var(--line-2, #EEF0F4); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; }
@media (max-width: 640px) { .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
