/* ============================================================
   PP Designers — professional studio dashboard
   Light + dark themes. Smooth, modern, calm.
   ============================================================ */

/* ---------- LIGHT THEME (default) ---------- */
:root {
  --bg:        #f5f6f9;
  --bg-2:      #ffffff;
  --surface:   #ffffff;
  --surface-2: #ffffff;
  --elev:      #ffffff;
  --line:      #e9eaf0;
  --line-2:    #e1e3ec;

  --ink:       #14161c;
  --ink-2:     #353a45;
  --muted:     #6b7280;
  --faint:     #99a0ad;

  --accent-1:  #6e56cf;
  --accent-2:  #8b6cf0;
  --accent:    linear-gradient(135deg, #7c66e6, #6549c9);
  --accent-ink:#ffffff;
  --accent-soft: color-mix(in srgb, var(--accent-1) 10%, transparent);
  --accent-border: color-mix(in srgb, var(--accent-1) 24%, transparent);

  --free:    #16a34a;
  --working: #2563eb;
  --paused:  #d97706;
  --danger:  #dc2626;
  --gray:    #94a0b8;

  /* legacy aliases (used by app.js inline styles) */
  --gold-1:  var(--accent-1);
  --gold-soft: var(--accent-soft);

  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --shadow:    0 14px 34px -18px rgba(22,28,45,.30);
  --shadow-lg: 0 30px 70px -28px rgba(22,28,45,.40);

  --r:   12px;
  --r-l: 18px;
  --font:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif; /* display font */
}

/* ---------- DARK THEME ---------- */
[data-theme="dark"] {
  --bg:        #0b0c10;
  --bg-2:      #101218;
  --surface:   #15171e;
  --surface-2: #171923;
  --elev:      #1c1f29;
  --line:      rgba(255,255,255,.08);
  --line-2:    rgba(255,255,255,.13);

  --ink:       #e9eaf1;
  --ink-2:     #c5c9d4;
  --muted:     #939aac;
  --faint:     #69707f;

  --accent-1:  #9b86f8;
  --accent-2:  #b29cff;
  --accent:    linear-gradient(135deg, #8f78f3, #6f57d8);
  --accent-soft: color-mix(in srgb, var(--accent-1) 18%, transparent);
  --accent-border: color-mix(in srgb, var(--accent-1) 32%, transparent);

  --free:    #34d39a;
  --working: #6f9bff;
  --paused:  #f0b24a;
  --danger:  #f47171;
  --gray:    #6b7280;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 18px 44px -22px rgba(0,0,0,.7);
  --shadow-lg: 0 30px 70px -26px rgba(0,0,0,.75);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
  line-height: 1.5;
  transition: background-color .35s ease, color .35s ease;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; }

.serif { font-family: var(--serif); letter-spacing: -.01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tnum  { font-variant-numeric: tabular-nums; }
.gold-text {
  background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* =====================================================================
   CONTROLS: language + theme toggles
   ===================================================================== */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line-2); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; transition: .18s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--accent-1); box-shadow: var(--shadow-sm); font-weight: 600; }
[data-theme="dark"] .seg button.on { background: var(--elev); }
.langseg { padding: 3px; gap: 2px; }
.langseg button { padding: 6px 9px; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; }
.langseg.block { display: flex; width: 100%; }
.langseg.block button { flex: 1; }
.iconbtn { display: inline-grid; place-items: center; width: 38px; height: 36px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); transition: .18s; }
.iconbtn:hover { color: var(--accent-1); border-color: var(--accent-border); }

/* period / date filter bar */
.periodbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 13px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-sm); }
.periodinput { width: auto; padding: 8px 11px; font-size: 13px; color-scheme: light; }
[data-theme="dark"] .periodinput { color-scheme: dark; }
.report-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 15px 18px; border-radius: var(--r-l); border: 1px solid var(--gold-line, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, var(--accent-1) 9%, var(--surface)), var(--surface) 70%); box-shadow: var(--shadow-sm); }
.report-bar__title { font-family: var(--serif); font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.report-bar__txt { display: flex; flex-direction: column; gap: 3px; }
.report-bar input[type="month"] { color-scheme: light; }
[data-theme="dark"] .report-bar input[type="month"] { color-scheme: dark; }
/* Receipt photos */
.rcpt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.rcpt { position: relative; border: 1px solid var(--line); border-radius: var(--r-m, 12px); overflow: hidden; background: var(--surface-2, var(--surface)); }
.rcpt img { width: 100%; height: 120px; object-fit: cover; display: block; cursor: zoom-in; }
.rcpt__m { font-size: 10.5px; color: var(--muted); padding: 5px 7px; text-align: center; }
.rcpt__del { position: absolute; top: 6px; right: 6px; border: none; background: rgba(20,22,28,.62); color: #fff; width: 26px; height: 26px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.rcpt__del:hover { background: var(--danger, #c0392b); }
.rcpt-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.rcpt-card { position: relative; border: 1px solid var(--line); border-radius: var(--r-m, 12px); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.rcpt-card img { width: 100%; height: 150px; object-fit: cover; display: block; cursor: zoom-in; }
/* The photo arrives only when the tile is scrolled near, so the slot is drawn
   immediately and fills in — rather than the whole board waiting on 30 MB. */
.rcpt-lazy {
  width: 100%; height: 150px; display: block; cursor: zoom-in;
  background: var(--bg) center/cover no-repeat;
  border-bottom: 1px solid var(--line);
  transition: opacity .25s ease; opacity: .55;
}
.rcpt-lazy.is-loaded { opacity: 1; }
.rcpt-lazy.is-failed { opacity: 1; background: var(--bg); }
.rcpt-lazy:not(.is-loaded)::after {
  content: ""; display: block; width: 22px; height: 22px; margin: 64px auto 0;
  border: 2px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-top-color: var(--accent-1); border-radius: 50%;
  animation: rcptspin .7s linear infinite;
}
.rcpt-lazy.is-failed::after { content: "—"; border: 0; animation: none; color: var(--faint); font-size: 18px; }
@keyframes rcptspin { to { transform: rotate(360deg); } }
.rcpt-card__b { padding: 8px 10px; font-size: 12.5px; }
.paste-zone { margin-top: 14px; border: 2px dashed var(--gold-line, var(--line)); border-radius: var(--r-m, 12px); padding: 22px 14px; text-align: center; cursor: pointer; color: var(--accent-1); display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; transition: background .15s, border-color .15s; }
.paste-zone:hover { background: color-mix(in srgb, var(--accent-1) 7%, var(--surface)); border-color: var(--accent-1); }
.rcpt-preview { margin-top: 14px; }
.rcpt-preview img { width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--r-m, 12px); border: 1px solid var(--line); background: var(--surface-2, var(--surface)); display: block; }
/* Date groups in the orders table */
.daygroup td { background: var(--surface-2, color-mix(in srgb, var(--accent-1) 5%, var(--surface))); font-weight: 700; font-size: 12.5px; letter-spacing: .01em; padding: 9px 14px !important; border-top: 1px solid var(--line); position: sticky; top: 0; }

/* ── Inventory photos ── */
.inv-thumb { width: 38px; height: 38px; flex: none; border-radius: 7px; object-fit: cover; border: 1px solid var(--line); cursor: zoom-in; transition: border-color .15s, transform .15s; }
.inv-thumb:hover { border-color: var(--accent-1); transform: scale(1.06); }
.inv-photo-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inv-photo-prev { width: 84px; height: 84px; flex: none; border-radius: 9px; object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); }

/* Equipment picture cards (designer profile + admin designer profile) */
.invgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 13px; }
.invcard { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--surface); }
.invcard__pic { aspect-ratio: 4/3; background: var(--surface-2, rgba(127,127,127,.08)); display: grid; place-items: center; overflow: hidden; }
.invcard__pic[data-action] { cursor: zoom-in; }
.invcard__pic img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .18s; }
.invcard__pic[data-action]:hover img { transform: scale(1.05); }
.invcard__ph { opacity: .3; transform: scale(1.6); }
.invcard__b { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.invcard__b b { font-size: 13px; line-height: 1.3; }
.invcard__b .chip { margin-top: 4px; font-size: 11px; padding: 2px 8px; }
.linkish { cursor: pointer; }
.linkish:hover { color: var(--accent-1); text-decoration: underline; }
.daygroup__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.daygroup__n { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.daygroup__agg { margin-left: auto; display: inline-flex; align-items: center; gap: 14px; }
.daygroup__sum { font-size: 12px; font-weight: 500; color: var(--muted); }
.daygroup__sum b { color: var(--accent-1); font-weight: 800; font-size: 13px; margin-left: 3px; }
.daygroup__w { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-size: 12px; }
.daygroup__w svg { width: 13px; height: 13px; opacity: .8; }
@media (max-width: 600px) { .daygroup__agg { margin-left: 0; width: 100%; gap: 12px; } }
.lightbox { position: fixed; inset: 0; background: rgba(8,9,12,.82); display: flex; align-items: center; justify-content: center; z-index: 2000; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; box-shadow: 0 18px 60px rgba(0,0,0,.5); }
/* Presence (online/offline) */
.av { position: relative; }
.pres { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); box-sizing: border-box; }
.pres.on { background: var(--free, #21c07a); box-shadow: 0 0 0 2px color-mix(in srgb, var(--free, #21c07a) 30%, transparent); }
.pres.off { background: var(--muted, #9aa0ab); }
.dcard.is-offline { opacity: .62; }
.dcard.is-offline:hover { opacity: 1; }
.periodrange { display: inline-flex; align-items: center; gap: 8px; }
.periodlabel { margin-left: auto; font-size: 13px; color: var(--muted); }
.periodlabel b { color: var(--ink); }
@media (max-width: 720px) { .periodlabel { margin-left: 0; width: 100%; } }

/* =====================================================================
   LOGIN
   ===================================================================== */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 0.95fr; background: var(--bg-2); }
.login__art {
  position: relative; overflow: hidden; color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(135deg, #6e56cf 0%, #5a3fc0 38%, #3f2d8f 70%, #4a37a8 100%);
  background-size: 220% 220%;
  animation: bgShift 22s ease infinite;
}
.login__art > * { position: relative; z-index: 1; }

/* animated hero background — drifting brand-colour orbs, light sweep, dot grid */
.login-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.login-bg .orb { position: absolute; border-radius: 50%; filter: blur(64px); opacity: .55; mix-blend-mode: screen; will-change: transform; }
.orb.o1 { width: 440px; height: 440px; left: -90px; top: -70px; background: radial-gradient(circle, #8a6cf6, transparent 70%); animation: drift1 26s ease-in-out infinite; }
.orb.o2 { width: 360px; height: 360px; right: -70px; top: 28%; background: radial-gradient(circle, #5b8dff, transparent 70%); animation: drift2 31s ease-in-out infinite; }
.orb.o3 { width: 320px; height: 320px; left: 18%; bottom: -90px; background: radial-gradient(circle, #ef5a7a, transparent 70%); opacity: .42; animation: drift3 35s ease-in-out infinite; }
.orb.o4 { width: 280px; height: 280px; right: 16%; bottom: 8%; background: radial-gradient(circle, #b29cff, transparent 70%); animation: drift1 23s ease-in-out infinite reverse; }
.login-bg .beam { position: absolute; top: -40%; left: -20%; width: 55%; height: 180%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); transform: rotate(18deg); animation: sweep 13s linear infinite; }
.login-bg .grid { position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px); background-size: 26px 26px; opacity: .55; animation: gridmove 26s linear infinite; }
@keyframes bgShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(60px,44px) scale(1.12); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-54px,-32px) scale(1.1); } }
@keyframes drift3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(44px,-52px) scale(1.16); } }
@keyframes sweep { 0% { transform: translateX(-40%) rotate(18deg); } 100% { transform: translateX(260%) rotate(18deg); } }
@keyframes gridmove { from { background-position: 0 0; } to { background-position: 26px 26px; } }
.login__hero h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(32px, 3.6vw, 50px); line-height: 1.08; letter-spacing: -.02em; }
.login__hero p { color: rgba(255,255,255,.82); margin-top: 18px; max-width: 34ch; font-size: 15.5px; }
.login__points { display: flex; flex-direction: column; gap: 14px; }
.login__points div { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.92); font-size: 14.5px; }
.login__points .dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: rgba(255,255,255,.18); flex: none; }
.login__points .dot::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(0,-1px); }

.brand { display: flex; align-items: center; gap: 13px; }
.brand .mono {
  width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 800; font-size: 19px; color: #fff;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25);
}
.brand .mono svg { width: 54%; height: 54%; }
.mono.logo { background: #fff; border: 0; padding: 5px; overflow: hidden; box-shadow: 0 2px 10px rgba(10, 12, 30, .18); }
.mono.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand .name { font-family: var(--serif); font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.brand .name small { display: block; font-family: var(--font); font-size: 10px; letter-spacing: .26em; opacity: .7; text-transform: uppercase; margin-top: 3px; font-weight: 600; }

.login__form { display: grid; place-items: center; padding: 40px; background: var(--bg-2); }
.login__card { width: min(380px, 100%); }
.login__card .mono.logo { background: #fff; }
.login__card h2 { font-family: var(--serif); font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.login__card .sub { color: var(--muted); margin: 7px 0 26px; font-size: 14.5px; }
.demo-hint { margin-top: 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); font-size: 12.5px; color: var(--muted); background: var(--bg); line-height: 1.7; }
.demo-hint b { color: var(--ink); }

/* Standing notice on a designer’s equipment page: the kit is company property.
   Amber rather than red — it is a reminder they see every visit, not an error. */
.warnbox {
  border: 1px solid color-mix(in srgb, var(--paused) 42%, transparent);
  background: color-mix(in srgb, var(--paused) 9%, var(--surface));
  border-left: 4px solid var(--paused);
  border-radius: var(--r); padding: 15px 18px;
}
.warnbox__t { font-weight: 800; font-size: 13.5px; letter-spacing: .02em; color: var(--paused); margin-bottom: 6px; }
.warnbox p { font-size: 13.5px; line-height: 1.75; color: var(--ink); margin: 0; }

/* =====================================================================
   FORMS
   ===================================================================== */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 500; margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 14px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r); font-size: 14.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
[data-theme="dark"] .input { background: var(--bg); }
.input::placeholder { color: var(--faint); }
.input:focus, textarea.input:focus, select.input:focus {
  border-color: var(--accent-1); box-shadow: 0 0 0 3.5px var(--accent-soft);
}
textarea.input { resize: vertical; min-height: 80px; }
/* Text the user typed: keep the line breaks they put in. */
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
/* A note box that starts one line tall and grows as you type, so it reads like
   the single-line field it replaced until a second line is actually needed. */
textarea.ml--grow {
  min-height: 0; resize: none; overflow-y: auto; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap;
  transition: transform .12s ease, box-shadow .2s, background .2s, border-color .2s, color .2s, opacity .2s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn--gold { background: var(--accent); color: #fff; box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent-1) 80%, transparent); }
.btn--gold:hover { box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--accent-1) 90%, transparent); transform: translateY(-1px); }
.btn--ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink-2); }
.btn--ghost:hover { border-color: var(--accent-border); color: var(--accent-1); }
.btn--start  { background: color-mix(in srgb, var(--free) 13%, transparent); border-color: color-mix(in srgb, var(--free) 32%, transparent); color: var(--free); }
.btn--start:hover  { background: color-mix(in srgb, var(--free) 20%, transparent); }
.btn--pause  { background: color-mix(in srgb, var(--paused) 14%, transparent); border-color: color-mix(in srgb, var(--paused) 34%, transparent); color: var(--paused); }
.btn--pause:hover  { background: color-mix(in srgb, var(--paused) 22%, transparent); }
.btn--finish { background: color-mix(in srgb, var(--working) 13%, transparent); border-color: color-mix(in srgb, var(--working) 34%, transparent); color: var(--working); }
.btn--finish:hover { background: color-mix(in srgb, var(--working) 21%, transparent); }
.btn--danger { background: color-mix(in srgb, var(--danger) 11%, transparent); border-color: color-mix(in srgb, var(--danger) 32%, transparent); color: var(--danger); }
.btn[disabled] { opacity: .42; cursor: not-allowed; box-shadow: none; transform: none; }
.btn--sm { padding: 8px 13px; font-size: 13px; }
.btn--block { width: 100%; }

/* =====================================================================
   APP SHELL
   ===================================================================== */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid var(--line); background: var(--bg-2);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand { padding: 6px 8px 16px; }
.side .brand .mono { width: 40px; height: 40px; font-size: 16px; border-radius: 11px; }
.side .brand .name { font-size: 18px; color: var(--ink); }
.side .brand .name small { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 13px; border-radius: 10px;
  color: var(--muted); font-size: 14px; font-weight: 500; transition: .15s; position: relative;
}
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.nav a.active { color: var(--accent-1); background: var(--accent-soft); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 4px; background: var(--accent-1); }
.nav a .ic { width: 18px; display: grid; place-items: center; opacity: .92; }
.side__foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.who { display: flex; align-items: center; gap: 11px; padding: 6px 6px 2px; }
.who .av { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.who .meta { line-height: 1.3; min-width: 0; }
.who .meta b { font-size: 13.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.who .meta span { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 30px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(14px); z-index: 20;
}
.topbar h1 { font-family: var(--serif); font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar .right { display: flex; align-items: center; gap: 10px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; font-weight: 500; padding: 8px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.content { padding: 26px 30px 56px; animation: contentfade .3s ease both; }
@keyframes fadeup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes contentfade { from { opacity: 0; } to { opacity: 1; } }

/* =====================================================================
   PANELS / CARDS / KPI
   ===================================================================== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-sm); }
.panel__h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel__h h3 { font-family: var(--serif); font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; }
.panel__b { padding: 18px 20px; }
/* Wide tables scroll inside their panel instead of overflowing the page. */
.panel__b:has(> .table) { overflow-x: auto; }
.grid { display: grid; gap: 16px; }
.section-title { font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 10px; }
.section-title small { font-family: var(--font); font-size: 12.5px; color: var(--muted); font-weight: 500; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 15px; }
.kpi { position: relative; overflow: hidden; padding: 18px 19px; border-radius: var(--r-l); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi .label::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--accent-1); }
.kpi.good .label::before { background: var(--free); }
.kpi.alt  .label::before { background: var(--working); }
.kpi.warn .label::before { background: var(--paused); }
.kpi .val { font-size: 25px; font-weight: 700; margin-top: 12px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--ink); }
.kpi .val.serif { font-family: var(--serif); }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* designer profile header */
.profilehead { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.profile-av { width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; font-weight: 700; font-size: 22px; background: var(--accent); color: #fff; font-family: var(--serif); flex: none; box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--accent-1) 80%, transparent); }
.profile__name { font-family: var(--serif); font-size: 22px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }

/* =====================================================================
   STATUS CHIPS
   ===================================================================== */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 7px; color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); }
.chip .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.free    { color: var(--free);    background: color-mix(in srgb, var(--free) 13%, transparent); }
.chip.working { color: var(--working); background: color-mix(in srgb, var(--working) 13%, transparent); }
.chip.paused  { color: var(--paused);  background: color-mix(in srgb, var(--paused) 14%, transparent); }
.chip.created { color: var(--muted);   background: color-mix(in srgb, var(--muted) 13%, transparent); }
.chip.finished{ color: var(--free);    background: color-mix(in srgb, var(--free) 12%, transparent); }
.chip.active  { color: var(--free);    background: color-mix(in srgb, var(--free) 13%, transparent); }
.chip.archived { color: var(--gray); background: color-mix(in srgb, var(--gray) 16%, transparent); }
.chip.cancelled { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.chip.online  { color: var(--working); background: color-mix(in srgb, var(--working) 12%, transparent); }
.chip.offline { color: var(--accent-1); background: var(--accent-soft); }
.pulse .d { animation: pulse 1.7s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 currentColor} 70%{box-shadow:0 0 0 6px transparent} 100%{box-shadow:0 0 0 0 transparent} }

/* =====================================================================
   FLOOR BOARD
   ===================================================================== */
.floor { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px; }

/* designer work card (flexible) */
.worka__body { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.worka__cust { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.worka__cust b { font-size: 14px; color: var(--ink); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.worka__rows { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 14px; margin-top: 12px; }
.worka__rows > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.worka__rows .muted { font-size: 11px; }
.worka__rows > div > :last-child { font-size: 13.5px; font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
.worka__actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.worka__actions .btn { flex: 1 1 80px; }

/* tier / monthly-salary panel */
.tierhead { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.tierpct__num { font-size: 42px; font-weight: 700; line-height: 1; }
.tierfigs { display: flex; gap: 28px; flex-wrap: wrap; }
.tierfigs > div { display: flex; flex-direction: column; gap: 3px; }
.tierfigs .muted { font-size: 12px; }
.tierfigs b { font-size: 17px; }
.tierprog { margin-top: 18px; }
.dcard { position: relative; padding: 17px; border-radius: var(--r-l); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s, border-color .2s; overflow: hidden; }
.dcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gray); opacity: .5; }
.dcard.is-free::before { background: var(--free); opacity: 1; }
.dcard.is-working::before { background: var(--working); opacity: 1; }
.dcard.is-paused::before { background: var(--paused); opacity: 1; }
.dcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.dcard__top { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.dcard .av { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 15px; background: var(--accent-soft); color: var(--accent-1); }
.dcard__name { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.dcard__sub { font-size: 12px; margin-top: 3px; }
.dcard__orders { display: flex; flex-direction: column; gap: 8px; }
.ordline { padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); }
.ordline__t { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ordline__t b { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.ordline__m { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; font-size: 12px; color: var(--muted); }
.ordline__m.costrow { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line-2); }
.costnow { color: var(--accent-1); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.timer.run { color: var(--working); }
.empty-free { font-size: 13px; color: var(--free); padding: 12px 0 2px; display: flex; align-items: center; gap: 9px; font-weight: 500; }
.floor-ctl { display: flex; gap: 6px; margin-top: 10px; }
.floor-ctl .btn { flex: 1; padding: 7px 6px; }
.floor-ctl .btn svg { width: 15px; height: 15px; }

/* autocomplete dropdown */
.ac { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 10; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden auto; display: none; max-height: 220px; }
.ac.show { display: block; }
.ac-item { padding: 10px 13px; font-size: 13.5px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover { background: var(--accent-soft); color: var(--accent-1); }

/* =====================================================================
   TABLES
   ===================================================================== */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; white-space: nowrap; }
.table thead th:hover { color: var(--text); }
.table thead th.sorted-asc::after { content: " \25B2"; font-size: 8px; color: var(--accent-1); }
.table thead th.sorted-desc::after { content: " \25BC"; font-size: 8px; color: var(--accent-1); }
/* Clickable order rows/cards → open the order detail */
tr.rowlink { cursor: pointer; }
tbody tr.rowlink:hover td { background: color-mix(in srgb, var(--accent-1) 6%, var(--surface)); }
.ordline.rowlink, .dcard.rowlink { cursor: pointer; }
.ordline.rowlink:hover { background: color-mix(in srgb, var(--accent-1) 6%, var(--surface)); border-radius: 8px; }
/* Order detail modal */
.od-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.od-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
.od-f .muted { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.od-f .od-v { font-size: 13.5px; }
.od-note { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 14px; padding: 10px 12px; background: var(--surface-2, color-mix(in srgb, var(--accent-1) 4%, var(--surface))); border-radius: 10px; font-size: 13px; }
.od-sec { margin-top: 16px; }
.od-sec__h { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
/* Clickable KPI + advance list */
.kpi--link { cursor: pointer; transition: border-color .15s, transform .1s; }
.kpi--link:hover { border-color: var(--accent-1); transform: translateY(-1px); }
.adv-list { display: flex; flex-direction: column; gap: 10px; }
.adv-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.adv-row__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.adv-row__note { display: flex; gap: 7px; margin-top: 9px; }
.adv-row__note .input { flex: 1; }
.adv-comment { white-space: pre-wrap; align-items: flex-start; margin-top: 7px; font-size: 12.5px; display: flex; align-items: center; gap: 6px; color: var(--text); }
.adv-comment svg { color: var(--accent-1); flex: 0 0 auto; }
/* Advances grouped by the month they were taken */
.adv-months { display: flex; flex-direction: column; gap: 18px; }
.adv-month__h {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 0 2px 7px; margin-bottom: 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.adv-month__name { font-weight: 700; font-size: 13.5px; text-transform: capitalize; }
.adv-month__sum { font-size: 13px; white-space: nowrap; }
.adv-month__sum b { color: var(--accent-1); }
.adv-month__sum .muted { font-size: 12px; }
.od-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; align-items: center; }
.od-actions .btn { white-space: nowrap; flex: 0 0 auto; }
/* Floating always-on-top orders window (Document Picture-in-Picture) */
.pip-root { padding: 10px; background: var(--bg); color: var(--text); font-family: var(--font, system-ui, sans-serif); min-height: 100vh; box-sizing: border-box; }
.pip-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.pip-list { display: flex; flex-direction: column; gap: 9px; }
.pip-card { border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 10px; padding: 9px 11px; background: var(--surface); }
.pip-card.is-working { border-left-color: var(--free, #21c07a); }
.pip-card.is-paused { border-left-color: var(--paused, #e0a82e); }
.pip-card__t { font-weight: 600; font-size: 13.5px; }
.pip-card__sub { font-size: 11.5px; color: var(--muted); margin: 2px 0 7px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pip-card__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pip-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.pip-btns { display: flex; gap: 5px; }
.pip-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); overflow-wrap: anywhere; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .14s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table b { color: var(--ink); }
.rank { width: 25px; height: 25px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--muted); }
.rank.r1 { background: var(--accent-soft); color: var(--accent-1); }
.is-arch td:not(:last-child) { opacity: .5; }

/* analytics chart */
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-x { fill: var(--faint); font-size: 11px; text-anchor: middle; font-family: var(--font); }
.chart-max { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-dot { fill: var(--accent-1); }

.bar { height: 7px; border-radius: 8px; background: color-mix(in srgb, var(--ink) 7%, transparent); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 8px; background: var(--accent); }
.bar.alt > i { background: linear-gradient(90deg, var(--working), color-mix(in srgb, var(--working) 60%, #fff)); }

/* =====================================================================
   MODAL
   ===================================================================== */
.modal-bg { position: fixed; inset: 0; background: color-mix(in srgb, var(--ink) 38%, transparent); backdrop-filter: blur(5px); display: grid; place-items: center; z-index: 60; padding: 20px; animation: fade .18s; }
.modal { width: min(540px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
.modal .panel__h h3 { font-size: 19px; }
.x { background: transparent; border: 1px solid var(--line-2); color: var(--muted); width: 34px; height: 34px; border-radius: 9px; font-size: 15px; transition: .15s; }
.x:hover { color: var(--ink); border-color: var(--line-2); background: var(--bg); }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; }

/* =====================================================================
   TOASTS
   ===================================================================== */
.toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast { padding: 13px 16px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--elev); box-shadow: var(--shadow); font-size: 13.5px; min-width: 240px; animation: slidein .25s; color: var(--ink); }
.toast.ok  { border-left: 3px solid var(--free); }
.toast.err { border-left: 3px solid var(--danger); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }

/* skeleton loader */
.loader { display: grid; place-items: center; min-height: 50vh; color: var(--muted); }
.loader::after { content: ""; width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent-1); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* misc */
.stack { display: flex; flex-direction: column; gap: 16px; }
.flex { display: flex; align-items: center; gap: 12px; }
/* Toolbars use class="flex wrap" in 13 places but the rule was never written, so
   they could only ever sit on one line and pushed the page sideways once a panel
   header carried a few controls. */
.wrap { flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; }
.spread { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.empty { text-align: center; color: var(--muted); padding: 38px 20px; font-size: 14px; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Responsive: laptop / tablet / mobile ───────────────────── */
@media (max-width: 1080px) { .spread { grid-template-columns: 1fr; } }

@media (max-width: 1024px) {
  .login { grid-template-columns: 1fr; }
  .login__art { display: none; }
  .login__form { padding: 28px 18px; }

  .shell { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto; flex-direction: column; align-items: stretch;
    gap: 10px; padding: 12px 14px;
  }
  .side .brand { padding: 4px; }
  .nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; margin: 0; gap: 6px; padding-bottom: 2px; }
  .nav a { white-space: nowrap; padding: 9px 13px; }
  .nav a.active::before { display: none; }
  .side__foot { margin: 0; border: 0; padding: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .side__foot > .flex { margin: 0 !important; }
  .side__foot .langseg.block { width: auto; }
  .side__foot .langseg.block button { flex: none; }
  .side__foot .who { display: none; }
  .side__foot .btn--block { width: auto; margin: 0 !important; }

  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 19px; }
  .content { padding: 18px 14px 48px; }
  .panel__b { overflow-x: auto; }
  .panel__b .table { min-width: 560px; }
}

@media (max-width: 600px) {
  .row { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(46%, 1fr)); gap: 12px; }
  .kpi { padding: 15px 16px; }
  .kpi .val { font-size: 21px; }
  .kpi .val.serif { font-size: 24px; }
  .floor { grid-template-columns: 1fr; }
  .topbar .clock { display: none; }
  .topbar { padding: 12px 14px; }
  .profilehead { gap: 12px; }
  .tierhead { gap: 14px; }
  .tierpct__num { font-size: 34px; }
  .periodbar { padding: 11px 12px; }
  .periodlabel { margin-left: 0; width: 100%; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .toasts { left: 14px; right: 14px; }
  .toast { min-width: 0; }
}

/* =====================================================================
   MOTION — staggered entrances, micro-interactions, profile delight
   ===================================================================== */
/* A background refresh re-creates the same nodes, and every one of them replaying
   its entrance was the flicker: on a busy page that is hundreds of rows fading in
   at once, several times a minute. Real navigation still animates. */
body.no-anim .content,
body.no-anim .kpis > .kpi,
body.no-anim .floor > .dcard,
body.no-anim .stack > .panel,
body.no-anim .table tbody tr,
body.no-anim .invgrid > .invcard,
body.no-anim .ai-msg { animation: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .kpis > .kpi { animation: fadeup .5s cubic-bezier(.2,.7,.3,1) both; }
  .kpis > .kpi:nth-child(2) { animation-delay: .06s; }
  .kpis > .kpi:nth-child(3) { animation-delay: .12s; }
  .kpis > .kpi:nth-child(4) { animation-delay: .18s; }
  .kpis > .kpi:nth-child(5) { animation-delay: .24s; }
  .kpis > .kpi:nth-child(6) { animation-delay: .30s; }
  .floor > .dcard { animation: fadeup .5s cubic-bezier(.2,.7,.3,1) both; }
  .floor > .dcard:nth-child(2) { animation-delay: .05s; }
  .floor > .dcard:nth-child(3) { animation-delay: .10s; }
  .floor > .dcard:nth-child(4) { animation-delay: .15s; }
  .floor > .dcard:nth-child(5) { animation-delay: .20s; }
  .floor > .dcard:nth-child(6) { animation-delay: .25s; }
  .floor > .dcard:nth-child(n+7) { animation-delay: .30s; }
  .stack > .panel { animation: fadeup .45s cubic-bezier(.2,.7,.3,1) both; }
  .table tbody tr { animation: rowin .4s ease both; }
}
@keyframes rowin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* button shine sweep on the primary buttons */
.btn--gold { position: relative; overflow: hidden; }
.btn--gold::after { content: ""; position: absolute; top: 0; left: -130%; width: 60%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent); transform: skewX(-20deg); transition: left .6s ease; pointer-events: none; }
.btn--gold:hover::after { left: 150%; }

/* nav active indicator grows in */
.nav a.active::before { animation: navin .25s ease; }
@keyframes navin { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* card hover gets a touch springier */
.dcard, .kpi { transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s; }

/* ---------- designer profile delight ---------- */
.greeting { font-family: var(--serif); font-size: 15px; color: var(--muted); animation: slideinL .5s ease both; }
.greeting b { color: var(--ink); }
.greeting .wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.6s ease-in-out infinite; }
@keyframes wave { 0%,60%,100% { transform: rotate(0); } 10% { transform: rotate(16deg); } 20% { transform: rotate(-8deg); } 30% { transform: rotate(16deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } }
@keyframes slideinL { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }

.tierring { position: relative; width: 128px; height: 128px; flex: none; }
.tierring svg { display: block; width: 128px; height: 128px; transform: rotate(-90deg); overflow: visible; }
.tierring .ring-track { fill: none; stroke: color-mix(in srgb, var(--accent-1) 13%, transparent); stroke-width: 10; }
[data-theme="dark"] .tierring .ring-track { stroke: color-mix(in srgb, #ffffff 10%, transparent); }
.tierring.is-max .ring-track { stroke: color-mix(in srgb, #d9a93a 18%, transparent); }
.tierring .ring-fill { fill: none; stroke: url(#ringgrad); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: var(--off, 327); filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent-2) 55%, transparent)); animation: ringfill 1.4s cubic-bezier(.22, 1, .36, 1) forwards; }
.tierring.is-max .ring-fill { stroke: url(#ringgradgold); animation: ringfill 1.4s cubic-bezier(.22, 1, .36, 1) forwards, goldpulse 2.6s ease-in-out 1.4s infinite backwards; }
@keyframes ringfill { from { stroke-dashoffset: 327; } to { stroke-dashoffset: var(--off, 327); } }
@keyframes goldpulse { 0%, 100% { filter: drop-shadow(0 0 4px color-mix(in srgb, #e9b949 50%, transparent)); } 50% { filter: drop-shadow(0 0 9px color-mix(in srgb, #f0c95a 70%, transparent)); } }
.tierring__num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; pointer-events: none; }
.tierring__val { display: flex; align-items: baseline; font-family: var(--serif); color: var(--ink); font-size: 35px; font-weight: 700; letter-spacing: -.5px; }
.tierring__pct { font-size: 16px; font-weight: 600; color: var(--ink-2); margin-left: 1px; }
.tierring__label { margin-top: 6px; font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.tierring.is-max .tierring__val { background: linear-gradient(135deg, #e9b949, #f0c95a); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.tierring.is-max .tierring__label { color: color-mix(in srgb, #d9a93a 70%, var(--muted)); }
.tierprog .bar > i { animation: barfill 1s cubic-bezier(.3,.8,.3,1) both; }
@keyframes barfill { from { width: 0 !important; } }

/* ---------- designer analyse: activity calendar heatmap ---------- */
.heatwrap { overflow-x: auto; padding-bottom: 4px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 4px; width: max-content; }
.heat-c { width: 14px; height: 14px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 7%, transparent); }
.heat-c.l1 { background: color-mix(in srgb, var(--accent-1) 28%, transparent); }
.heat-c.l2 { background: color-mix(in srgb, var(--accent-1) 50%, transparent); }
.heat-c.l3 { background: color-mix(in srgb, var(--accent-1) 74%, transparent); }
.heat-c.l4 { background: var(--accent-1); }
.heat-legend { display: flex; align-items: center; gap: 5px; margin-top: 12px; font-size: 11px; }
.heat-legend .heat-c { width: 12px; height: 12px; }

/* ---------- table pagination ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 12px 16px; border-top: 1px solid var(--line); }
.pager-info { font-size: 12.5px; color: var(--muted); min-width: 120px; text-align: center; }
.pager button[disabled] { opacity: .4; cursor: default; }

/* ---------- hide salary (privacy from onlookers) ---------- */
.priv { transition: filter .18s; }
body.money-hidden .priv { filter: blur(9px); user-select: none; }

/* ---------- profile photo ---------- */
.av-photo { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.profile-av { position: relative; overflow: hidden; }
.photo-btn { position: absolute; right: -3px; bottom: -3px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--accent-1); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-sm); }
.photo-btn svg { width: 13px; height: 13px; }

/* respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* =====================================================================
   CHAT
   ===================================================================== */
.chat { display: grid; grid-template-columns: clamp(258px, 30%, 340px) 1fr; gap: 14px; height: calc(100dvh - 184px); min-height: 440px; }
.chat-list, .chat-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-list__h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-list__h b { font-size: 15px; }
.chat-convos { flex: 1; overflow-y: auto; padding: 6px; }
.chat-convo { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; border: 0; background: transparent; cursor: pointer; text-align: left; color: inherit; }
.chat-convo:hover { background: var(--elev); }
.chat-convo.is-active { background: var(--accent-soft); }
.chat-convo__b { flex: 1; min-width: 0; }
.chat-convo__t { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-convo__p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-convo__r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.chat-convo__m { font-size: 11px; color: var(--faint); white-space: nowrap; }
.chat-convo .star { color: var(--paused); }
.chat-unread { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--accent-1); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
/* unread count next to the "Chat" nav item */
#nav a { position: relative; }
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
/* delivered / read ticks on your own messages */
.ticks { display: inline-flex; align-items: center; margin-left: 4px; vertical-align: middle; }
.tick { width: 15px; height: 10px; color: var(--faint); }
.msg.me .tick { color: color-mix(in srgb, var(--accent-1) 55%, var(--muted)); }
.tick--read { width: 17px; color: var(--working); }
.cav { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden; background: var(--elev); color: var(--muted); font-weight: 700; font-size: 14px; }
.cav.sm { width: 30px; height: 30px; font-size: 12px; }
.cav .av-photo { width: 100%; height: 100%; object-fit: cover; }
.cav--all { background: linear-gradient(135deg, #7c66e6, #6549c9); color: #fff; }
.cav--group { background: var(--accent-soft); color: var(--accent-1); }
.cav svg { width: 20px; height: 20px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-head__b { flex: 1; min-width: 0; }
.chat-head__t { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head__s { font-size: 12px; color: var(--muted); }
.chat-back { display: none; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 2px; background: var(--bg); }
.chat-day { align-self: center; margin: 10px 0; font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 2px 10px; border-radius: 20px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 80%; margin: 1px 0; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.grp { align-self: flex-start; }
.msg:not(.grp):not(.me) { align-self: flex-start; }
.msg-av { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; flex: none; display: grid; place-items: center; background: var(--elev); color: var(--muted); font-size: 11px; font-weight: 700; }
.msg-av:empty { background: transparent; }
.msg-av .av-photo { width: 100%; height: 100%; object-fit: cover; }
.msg-wrap { position: relative; display: flex; align-items: center; gap: 4px; min-width: 0; }
.msg.me .msg-wrap { flex-direction: row-reverse; }
.bub { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 7px 11px 5px; font-size: 14px; line-height: 1.4; max-width: 100%; }
.msg.me .bub { background: var(--accent-soft); border-color: var(--accent-border); }
.bub-name { font-size: 11.5px; font-weight: 700; color: var(--accent-1); margin-bottom: 2px; }
.bub-text { white-space: pre-wrap; word-break: break-word; }
.bub-meta { display: block; text-align: right; font-size: 10px; color: var(--faint); margin-top: 2px; }
.bub--photo { padding: 4px 4px 5px; }
.bub-photo { max-width: min(240px, 60vw); max-height: 280px; border-radius: 10px; display: block; cursor: zoom-in; }
.bub--stk { background: transparent !important; border: 0 !important; padding: 0; }
.stk-big { font-size: 52px; line-height: 1; }
.bub--del { color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 6px; }
.bub--del svg { width: 15px; height: 15px; }
.msg-menu { opacity: 0; border: 0; background: transparent; color: var(--faint); cursor: pointer; padding: 2px; border-radius: 6px; flex: none; }
.msg-menu svg { width: 16px; height: 16px; }
.msg:hover .msg-menu { opacity: .75; }
.msg-menu:hover { background: var(--elev); opacity: 1; }
.chat-stickers { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px; border-top: 1px solid var(--line); max-height: 148px; overflow-y: auto; }
.chat-stickers.hide { display: none; }
.stk { border: 0; background: transparent; font-size: 24px; line-height: 1; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.stk:hover { background: var(--elev); }
.chat-composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-input { flex: 1; resize: none; min-height: 40px; max-height: 140px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); padding: 9px 12px; font: inherit; font-size: 14px; line-height: 1.4; }
.chat-input:focus { outline: none; border-color: var(--accent-border); }
.btn--icn { width: 40px; height: 40px; padding: 0; flex: none; display: grid; place-items: center; border-radius: 12px; }
.btn--icn svg { width: 18px; height: 18px; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); text-align: center; padding: 30px; }
.chat-empty svg { width: 40px; height: 40px; opacity: .5; }
.chat-empty.sm { padding: 20px; font-size: 13px; margin: auto; }
.pick-list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left; color: inherit; font-size: 14px; }
.pick:hover { background: var(--elev); }
.pick-n { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-r { font-size: 11px; text-transform: capitalize; }
.pick-cb { width: 17px; height: 17px; flex: none; accent-color: var(--accent-1); }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; margin-left: 6px; vertical-align: middle; }
.flex.col { flex-direction: column; align-items: stretch; }

@media (max-width: 1024px) {
  .chat { height: calc(100dvh - 214px); }
  .msg-menu { opacity: .55; }
}
@media (max-width: 820px) {
  .chat { grid-template-columns: 1fr; height: calc(100dvh - 196px); }
  .chat-main { display: none; }
  .chat.has-active .chat-list { display: none; }
  .chat.has-active .chat-main { display: flex; }
  .chat-back { display: grid; }
  .msg { max-width: 88%; }
}

/* ── Chat: reactions, reply, forward, pin, select, context menu ── */
.msg-col { display: flex; flex-direction: column; min-width: 0; }
.msg.me .msg-col { align-items: flex-end; }
.bub-reply { border-left: 3px solid var(--accent-1); background: color-mix(in srgb, var(--accent-1) 8%, transparent); border-radius: 6px; padding: 3px 8px; margin-bottom: 4px; font-size: 12px; cursor: pointer; max-width: 100%; overflow: hidden; }
.bub-reply b { display: block; color: var(--accent-1); font-size: 11.5px; }
.bub-reply span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.bub-fwd { font-size: 11px; color: var(--faint); font-style: italic; display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.bub-fwd svg { width: 12px; height: 12px; }
.bub-pin { display: inline-flex; margin-right: 3px; color: var(--paused); }
.bub-pin svg { width: 11px; height: 11px; }
.bub-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 2px 1px; }
.react { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 1px 7px; font-size: 12px; cursor: pointer; color: var(--ink); }
.react span { font-size: 11px; color: var(--muted); font-weight: 600; }
.react.mine { background: var(--accent-soft); border-color: var(--accent-border); }
.react.mine span { color: var(--accent-1); }

.msg-menu-pop { position: fixed; z-index: 1400; background: var(--elev); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; animation: popIn .12s ease; }
.mm-react { display: flex; gap: 2px; padding: 3px; margin-bottom: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mm-emoji { border: 0; background: transparent; font-size: 21px; line-height: 1; padding: 5px; border-radius: 8px; cursor: pointer; }
.mm-emoji:hover { background: var(--surface); transform: scale(1.15); }
.mm-emoji.mm-more { color: var(--muted); display: inline-flex; align-items: center; }
.mm-emoji.mm-more svg { width: 18px; height: 18px; }
.mm-items { display: flex; flex-direction: column; }
.mm-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: transparent; color: var(--ink); font-size: 13.5px; cursor: pointer; border-radius: 8px; text-align: left; width: 100%; }
.mm-item:hover { background: var(--surface); }
.mm-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.mm-item.danger { color: var(--danger); }
.mm-item.danger svg { color: var(--danger); }

.chat-pinned { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paused) 8%, var(--surface)); cursor: pointer; }
.chat-pinned__ic { color: var(--paused); display: inline-flex; }
.chat-pinned__ic svg { width: 15px; height: 15px; }
.chat-pinned__b { flex: 1; min-width: 0; }
.chat-pinned__t { font-size: 11.5px; font-weight: 700; color: var(--paused); }
.chat-pinned__p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-reply-bar__b { flex: 1; min-width: 0; border-left: 3px solid var(--accent-1); padding-left: 8px; }
.chat-reply-bar__n { font-size: 12px; font-weight: 700; color: var(--accent-1); display: flex; align-items: center; gap: 4px; }
.chat-reply-bar__n svg { width: 12px; height: 12px; }
.chat-reply-bar__p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-selectbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-selectbar__n { font-weight: 600; font-size: 14px; }

.msg.selmode { cursor: pointer; }
.msg.selmode .msg-menu { display: none; }
.msg.sel .bub { outline: 2px solid var(--accent-1); }
.msg-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; align-self: center; }
.msg-check.on { background: var(--accent-1); border-color: var(--accent-1); color: #fff; }
.msg-check svg { width: 13px; height: 13px; }

.chat-unreadline { display: flex; align-items: center; justify-content: center; margin: 10px 0; }
.chat-unreadline span { background: color-mix(in srgb, var(--accent-1) 14%, var(--surface)); color: var(--accent-1); font-size: 11px; font-weight: 700; padding: 3px 12px; border-radius: 20px; text-transform: uppercase; letter-spacing: .03em; }

.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; max-height: 320px; overflow-y: auto; }
.emoji-grid .stk { font-size: 24px; }

.grp-photo-head { text-align: center; }
.grp-photo { width: 92px; height: 92px; border-radius: 50%; margin: 0 auto; position: relative; overflow: visible; }
.grp-photo .av-photo { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; }
.grp-photo__edit { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); background: var(--accent-1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.grp-photo__edit svg { width: 15px; height: 15px; }

.msg.flash .bub { animation: flashBub 1.2s ease; }
@keyframes flashBub { 0%, 100% { background: var(--surface); } 30% { background: var(--accent-soft); } }
.msg.me.flash .bub { animation: flashBubMe 1.2s ease; }
@keyframes flashBubMe { 0%, 100% { background: var(--accent-soft); } 30% { background: color-mix(in srgb, var(--accent-1) 30%, var(--surface)); } }
@keyframes popIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }

/* required-field marker */
.req { color: var(--danger); font-weight: 700; }

/* =====================================================================
   MOBILE — phone layout (<=820px)
   The sidebar gives way to a fixed bottom tab bar, wide tables restack as
   cards, and dialogs rise from the bottom like a native sheet.
   ===================================================================== */

/* Nothing may force the page wider than the screen. Grid and flex children
   default to min-width:auto, so one wide table used to stretch the whole
   shell and the page scrolled sideways on every screen. */
.shell > *, .main, .content, .panel, .panel__b, .nav, .stack > * { min-width: 0; }
.content { max-width: 100%; }

/* The bottom bar and the More sheet exist only on phones. */
.tabbar, .sheet { display: none; }

@media (max-width: 820px) {
  .shell { min-height: 100dvh; }
  .side { display: none; }                     /* replaced by the tab bar */

  /* Compact sticky header: logo, page name, actions. */
  .topbar {
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 10px;
  }
  .topbar::before {
    content: ""; width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px;
    background: #fff center/22px no-repeat url("/logo.png");
    border: 1px solid var(--line);
  }
  .topbar__t { min-width: 0; flex: 1; }
  .topbar h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .sub { display: none; }
  .topbar .right { gap: 6px; flex: 0 0 auto; }

  .content { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .section-title { font-size: 15px; }

  /* Bottom tab bar */
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 24px -18px rgba(0, 0, 0, .5);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 7px 2px 5px; border-radius: 12px; min-height: 50px;
    color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: -.01em;
    text-align: center; position: relative; transition: color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a .ic { display: grid; place-items: center; }
  .tabbar a .ic svg { width: 21px; height: 21px; }
  .tabbar a .lb { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a.active { color: var(--accent-1); }
  .tabbar a.active::after {
    content: ""; position: absolute; top: 2px; width: 18px; height: 3px;
    border-radius: 0 0 4px 4px; background: var(--accent-1);
  }
  .tabbar a:active { background: var(--accent-soft); }

  /* More sheet */
  .sheet { display: block; position: fixed; inset: 0; z-index: 70; }
  .sheet[hidden] { display: none; }
  .sheet__bg {
    position: absolute; inset: 0; background: color-mix(in srgb, var(--ink) 45%, transparent);
    backdrop-filter: blur(3px); animation: fade .2s ease;
  }
  .sheet__p {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow: auto;
    background: var(--surface); border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--line); box-shadow: var(--shadow-lg);
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
    animation: sheetup .28s cubic-bezier(.2, .8, .25, 1);
  }
  .sheet__grab {
    width: 40px; height: 4px; border-radius: 3px; margin: 0 auto 12px;
    background: color-mix(in srgb, var(--ink) 18%, transparent);
  }
  .sheet__h {
    display: flex; align-items: center; justify-content: space-between;
    font-family: var(--serif); font-size: 17px; font-weight: 700; margin-bottom: 14px;
  }
  .sheet__h .x {
    background: none; border: 0; color: var(--muted); font-size: 17px;
    width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  }
  .sheet__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
  .sheet__grid a {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    padding: 15px 6px; border-radius: 14px; border: 1px solid var(--line);
    background: var(--bg); color: var(--ink); font-size: 11.5px; font-weight: 600;
    text-align: center; line-height: 1.25;
  }
  .sheet__grid a .ic { color: var(--accent-1); display: grid; place-items: center; }
  .sheet__grid a .ic svg { width: 21px; height: 21px; }
  .sheet__grid a:active { background: var(--accent-soft); border-color: var(--accent-1); }
  .sheet__foot {
    margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 11px;
  }
  .sheet__foot .who { padding: 0; }
  .sheet__foot .who .meta b { white-space: normal; }

  /* Tables become cards */
  .panel__b:has(> .table), .tablewrap { overflow-x: visible; }
  .panel__b .table, .table { min-width: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: auto; }
  .table tbody tr {
    border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
    margin: 10px; padding: 4px 2px; box-shadow: var(--shadow-sm);
  }
  .table tbody tr:hover { background: var(--surface); }
  .table td {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
    padding: 9px 13px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
    text-align: left; font-size: 13.5px;
  }
  .table td:last-child { border-bottom: 0; }
  .table td::before {
    content: attr(data-label); flex: 0 0 40%; color: var(--faint);
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding-top: 2px;
  }
  .table td:not([data-label])::before { content: none; }
  .table td.num { text-align: right; }
  .table td > * { min-width: 0; }
  /* Cells holding only buttons stretch across the card foot. */
  .table td.cell-actions { padding: 10px 11px; }
  .table td.cell-actions > .flex { width: 100%; justify-content: stretch !important; flex-wrap: wrap; }
  .table td.cell-actions .btn { flex: 1 1 auto; }
  /* Group headings (day / designer) stay full-width bars between the cards. */
  .table tr.rowfull, .table tr.daygroup {
    display: block; border: 0; background: none; box-shadow: none;
    margin: 16px 4px 2px; padding: 0;
  }
  .table tr.rowfull td, .table tr.daygroup td { display: block; border: 0; padding: 0; }
  .table tr.rowfull td::before, .table tr.daygroup td::before { content: none; }
  .daygroup__row { flex-wrap: wrap; gap: 6px 12px; }
  .pager { padding: 4px 10px 2px; }

  /* Everything you tap should be comfortable */
  .btn { min-height: 42px; padding: 10px 15px; }
  .btn--sm { min-height: 38px; }
  .input, select.input, textarea.input { font-size: 16px; min-height: 44px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .panel__h { padding: 14px; }
  .panel__b { padding: 14px; }
  .panel__h h3 { font-size: 15.5px; }

  /* Dialogs rise from the bottom */
  .modal-bg { padding: 0; place-items: end stretch; }
  .modal {
    width: 100%; max-height: 92dvh; border-radius: 20px 20px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    animation: sheetup .26s cubic-bezier(.2, .8, .25, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal .panel__h { position: sticky; top: 0; background: var(--surface); z-index: 2; border-radius: 20px 20px 0 0; }
  .modal .panel__h h3 { font-size: 16.5px; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); padding-bottom: 4px; }

  .toasts { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .lightbox img { max-width: 96vw; }
  .floor { grid-template-columns: 1fr; }
  .invgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rcpt-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .periodbar { gap: 8px; }
  .periodbar .seg { width: 100%; }
  .periodbar .seg button { flex: 1; min-width: 0; }
  /* The month picker and the from/to dates must share the row, not overrun it.
     A date input keeps its own intrinsic width unless told to shrink. */
  .periodbar > .periodinput { width: 100%; }
  .periodrange { display: flex; width: 100%; min-width: 0; }
  .periodrange .periodinput { flex: 1 1 0; min-width: 0; width: auto; }
  .periodlabel { width: 100%; margin-left: 0; }
  .chat { height: calc(100dvh - 190px); }
}

body.sheet-open { overflow: hidden; }
@keyframes sheetup { from { transform: translateY(100%); } to { transform: none; } }

/* Very narrow phones */
@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr; }
  .sheet__grid { grid-template-columns: repeat(2, 1fr); }
  .tabbar a { font-size: 9.5px; }
  .table td::before { flex-basis: 44%; }
}

/* Receipt source buttons (camera / gallery) */
.rcpt-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }

/* =====================================================================
   AI DIRECTOR
   ===================================================================== */
.ai-hero {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 18px; border-radius: var(--r-l); border: 1px solid var(--line);
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 65%);
}
.ai-hero__i {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: #fff; flex: 0 0 auto;
}
.ai-hero__i svg { width: 21px; height: 21px; }
.ai-hero b { font-family: var(--serif); font-size: 16.5px; }

.ai-delta { font-weight: 700; font-size: 11.5px; margin-left: 6px; }
.ai-delta.up { color: var(--free); }
.ai-delta.down { color: var(--danger); }

/* The Director page holds nothing but the conversation, so let it fill the
   screen: the thread takes the leftover height and scrolls inside itself,
   keeping the question box always in view at the bottom. */
/* A fixed height, not a minimum: only then can the thread take the leftover
   space and scroll inside itself instead of pushing the question box off the
   bottom of the screen as the conversation grows. */
.ai-page { height: calc(100vh - 180px); }
.ai-panel { flex: 1; display: flex; min-height: 0; }
.ai-panel__b { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ai-thread {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  min-height: 260px; overflow-y: auto; padding-right: 4px; margin-bottom: 14px;
}
/* Empty state: the module introduces itself instead of showing a bare box. */
.ai-blank {
  margin: auto; display: flex; flex-direction: column; align-items: center; gap: 7px;
  text-align: center; padding: 26px 18px; max-width: 380px;
}
.ai-blank__i {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-1); margin-bottom: 3px;
}
.ai-blank__i svg { width: 23px; height: 23px; }
.ai-blank b { font-family: var(--serif); font-size: 16px; }
.ai-blank .muted { font-size: 13px; line-height: 1.6; }
.ai-msg { max-width: 92%; }
.ai-msg.you { align-self: flex-end; text-align: right; }
.ai-msg__who { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.ai-msg__b {
  display: inline-block; text-align: left; padding: 12px 15px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.65; border: 1px solid var(--line); background: var(--bg);
  overflow-wrap: anywhere;
}
.ai-msg.you .ai-msg__b { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent-1) 30%, transparent); color: var(--ink); }
.ai-msg__b p { margin: 0 0 9px; }
.ai-msg__b p:last-child { margin-bottom: 0; }
.ai-msg__b b { color: var(--ink); }

.ai-dots { display: inline-flex; gap: 5px; padding: 3px 0; }
.ai-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-1); opacity: .35; animation: aidot 1.1s infinite; }
.ai-dots i:nth-child(2) { animation-delay: .18s; }
.ai-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes aidot { 0%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 13px; }
.ai-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 8px 14px; font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: .15s;
}
.ai-chip:hover { color: var(--accent-1); border-color: var(--accent-1); background: var(--accent-soft); }

.ai-form { display: flex; gap: 9px; }
.ai-form .input { flex: 1; min-width: 0; }
.ai-form .btn { white-space: nowrap; flex: 0 0 auto; }

@media (max-width: 820px) {
  .ai-page { height: calc(100dvh - 160px); }
  .ai-thread { min-height: 120px; }
  .ai-msg { max-width: 100%; }
  /* Keep the ask box on one line so it cannot eat the thread's height. */
  .ai-form { flex-wrap: nowrap; }
  .ai-form .btn { width: auto; padding: 10px 14px; }
  /* A compact hero: the blurb and the status chip belong on a wide screen, but
     on a phone they stacked into 245px and pushed the ask box off the bottom. */
  .ai-hero { padding: 12px 14px; gap: 11px; }
  .ai-hero__i { width: 34px; height: 34px; }
  .ai-hero .muted { display: none; }
  .ai-hero > span.flex { width: auto; gap: 6px; }
  /* Suggestions scroll sideways in one row rather than wrapping into a wall. */
  .ai-chips {
    flex-wrap: nowrap; overflow-x: auto; margin-bottom: 11px;
    padding-bottom: 3px; scrollbar-width: none;
  }
  .ai-chips::-webkit-scrollbar { display: none; }
  .ai-chip { flex: 0 0 auto; }
}

/* AI Director — connection notes, watch list and movers */
.ai-note {
  border-radius: 10px; padding: 10px 13px; font-size: 12.5px; line-height: 1.6;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
}
.ai-note.ok { border-color: color-mix(in srgb, var(--free) 45%, transparent); background: color-mix(in srgb, var(--free) 10%, var(--surface)); color: var(--ink); }
.ai-note.bad { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); color: var(--ink); }
.ai-note.bad b { color: var(--danger); display: block; margin-bottom: 3px; }
/* A draft order the Director wants to create, waiting for the admin's tap. */
.ai-prop {
  margin-top: 11px; border: 1px solid color-mix(in srgb, var(--accent-1) 40%, transparent);
  background: color-mix(in srgb, var(--accent-1) 6%, var(--surface));
  border-radius: 12px; padding: 12px 14px;
}
.ai-prop__h {
  display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12.5px;
  color: var(--accent-1); margin-bottom: 9px; text-transform: uppercase; letter-spacing: .03em;
}
.ai-prop__h svg { width: 15px; height: 15px; }
.ai-prop__r {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 4px 0; font-size: 13px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.ai-prop__r:last-of-type { border-bottom: 0; }
.ai-prop__r span { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.ai-prop__r b { text-align: right; overflow-wrap: anywhere; }
.ai-prop__f { display: flex; gap: 8px; justify-content: flex-end; margin-top: 11px; }
.ai-prop.done {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
  border-color: color-mix(in srgb, var(--free) 45%, transparent);
  background: color-mix(in srgb, var(--free) 10%, var(--surface)); color: var(--ink);
}
.ai-prop.done svg { color: var(--free); }

/* Busy model: temporary, so amber rather than red. */
.ai-note.warn { border-color: color-mix(in srgb, var(--paused) 45%, transparent); background: color-mix(in srgb, var(--paused) 9%, var(--surface)); color: var(--ink); }
.ai-note.warn b { color: var(--paused); display: block; margin-bottom: 3px; }
.ai-note__d { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

.ai-watch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.ai-watch b { font-family: var(--serif); font-size: 16px; }
.ai-watch b.ai-warn { color: var(--paused); }

.ai-mover { display: flex; align-items: center; gap: 11px; }
.ai-mover__n { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.ai-mover .ai-delta { font-size: 13px; }

/* =====================================================================
   TRAINING — course cards, the builder, and the lesson player
   ===================================================================== */
.lms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.lms-card {
  border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface);
  padding: 15px 16px; cursor: pointer; transition: border-color .15s, transform .1s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm);
}
.lms-card:hover { border-color: var(--accent-1); transform: translateY(-1px); box-shadow: var(--shadow-md, var(--shadow-sm)); }
.lms-card__top { display: flex; align-items: flex-start; gap: 11px; }
.lms-card__i {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-1);
}
.lms-card__top b { font-size: 14.5px; line-height: 1.35; display: block; overflow-wrap: anywhere; }
.lms-card__d {
  font-size: 12.5px; color: var(--muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lms-card__f { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; flex-wrap: wrap; }
.lms-overdue { color: var(--paused); font-weight: 600; }

.lms-prog { height: 6px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; flex: 1; }
.lms-prog > i { display: block; height: 100%; background: var(--accent-1); border-radius: 4px; transition: width .35s ease; }

/* ── builder ─────────────────────────────────────────────────────────── */
.lms-session { border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; margin-bottom: 12px; background: var(--bg); }
.lms-session__h { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.lms-session__h b { font-size: 13.5px; overflow-wrap: anywhere; }

.lms-lesson {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--line); margin-bottom: 6px;
}
.lms-lesson__i { color: var(--accent-1); display: grid; place-items: center; flex: 0 0 auto; }
.lms-lesson b { font-size: 13px; overflow-wrap: anywhere; }

.lms-bar { height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 10%, transparent); overflow: hidden; margin-top: 7px; }
.lms-bar > i { display: block; height: 100%; width: 0; background: var(--accent-1); transition: width .2s ease; }

.lms-people { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.lms-person {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.lms-person:hover { border-color: var(--accent-1); }
.lms-person b { font-size: 13px; }

/* ── the player ──────────────────────────────────────────────────────── */
.lms-player { display: flex; flex-direction: column; gap: 12px; }
.lms-player__bar { display: flex; align-items: center; gap: 10px; }
.lms-player__main { display: grid; grid-template-columns: 1fr 240px; gap: 16px; align-items: start; }
.lms-player__body { min-width: 0; }
.lms-lesson-title { font-family: var(--serif); font-size: 18px; margin: 3px 0 12px; }
.lms-body { font-size: 13.5px; line-height: 1.75; color: var(--ink-2); margin-top: 12px; }

.lms-video { width: 100%; max-height: 46vh; border-radius: 12px; background: #000; display: block; }
.lms-pdf { width: 100%; height: 46vh; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); display: block; }
.lms-image { width: 100%; border-radius: 12px; display: block; }

.lms-player__list {
  max-height: 52vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px;
  padding: 8px; background: var(--bg); min-width: 0;
}
.lms-plist__s {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint);
  font-weight: 700; padding: 9px 8px 5px;
}
.lms-plist__l {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 9px; border-radius: 8px; border: 0; background: transparent; cursor: pointer;
  font-size: 12.5px; color: var(--ink-2); line-height: 1.35;
}
.lms-plist__l:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.lms-plist__l.is-active { background: var(--accent-soft); color: var(--accent-1); font-weight: 600; }
.lms-plist__c { width: 16px; flex: 0 0 auto; color: var(--free); display: grid; place-items: center; }
.lms-plist__c svg { width: 14px; height: 14px; }
.lms-plist__l.is-done { color: var(--muted); }

.lms-player__foot { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.lms-player__foot .btn { flex: 0 0 auto; }

.lms-blank {
  display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center;
  padding: 46px 20px; max-width: 420px; margin: 0 auto;
}
.lms-blank__i {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-1); margin-bottom: 4px;
}
.lms-blank__i svg { width: 24px; height: 24px; }
.lms-blank b { font-family: var(--serif); font-size: 16px; }
.lms-blank .muted { font-size: 13px; line-height: 1.6; }

@media (max-width: 820px) {
  .lms-grid { grid-template-columns: 1fr; }
  /* The lesson list goes under the lesson on a phone, not beside it. */
  .lms-player__main { grid-template-columns: 1fr; }
  .lms-player__list { max-height: 240px; }
  .lms-video, .lms-pdf { max-height: 38vh; height: auto; }
  .lms-pdf { height: 38vh; }
  .lms-player__foot .btn { flex: 1 1 auto; }
  .lms-people { max-height: 46vh; }
}
