/* ==========================================================================
   JPMK Factory Ops — design system
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg:        #f1f3f6;
  --surface:   #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef2;
  --line:      #dfe3e9;
  --line-soft: #e9ecf1;

  --text:      #16202e;
  --text-2:    #5a6779;
  --text-3:    #8b96a6;

  --accent:      #d97706;
  --accent-hi:   #b45309;
  --accent-soft: #fef3e2;

  --ok:      #15803d;
  --ok-soft: #e7f6ec;
  --warn:      #b45309;
  --warn-soft: #fdf1de;
  --bad:      #b91c1c;
  --bad-soft: #fdeaea;
  --info:      #1d4ed8;
  --info-soft: #e8eefc;

  --nav-bg:     #131a24;
  --nav-bg-2:   #1b2431;
  --nav-text:   #a6b1c2;
  --nav-text-hi:#ffffff;
  --nav-line:   #253040;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  --sh-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --sh-2: 0 4px 12px rgba(16, 24, 40, .08);
  --sh-3: 0 18px 48px rgba(16, 24, 40, .18);

  --nav-w: 236px;
  --top-h: 60px;
  --tabbar-h: 60px;
}

[data-theme="dark"] {
  --bg:        #0d1218;
  --surface:   #151d26;
  --surface-2: #1b2430;
  --surface-3: #222d3b;
  --line:      #2a3644;
  --line-soft: #222d3a;

  --text:   #e8edf4;
  --text-2: #a1adbd;
  --text-3: #74808f;

  --accent:      #f59e0b;
  --accent-hi:   #fbbf24;
  --accent-soft: #33260f;

  --ok: #4ade80;        --ok-soft: #12291b;
  --warn: #fbbf24;      --warn-soft: #33270f;
  --bad: #f87171;       --bad-soft: #331617;
  --info: #7aa5ff;      --info-soft: #16213c;

  --nav-bg:   #0a0e13;
  --nav-bg-2: #131b24;
  --nav-line: #1e2733;

  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 4px 14px rgba(0,0,0,.45);
  --sh-3: 0 18px 48px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
p { margin: 0; }
a { color: var(--accent-hi); }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; border: 3px solid transparent; }

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

.nav {
  width: var(--nav-w); flex: 0 0 var(--nav-w);
  background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--nav-line);
  z-index: 40;
}
.nav__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: var(--top-h);
  border-bottom: 1px solid var(--nav-line); flex: 0 0 auto;
}
.nav__logo {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(145deg, var(--accent), #92400e);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .02em;
}
.nav__brandtext { min-width: 0; }
.nav__title { color: #fff; font-size: 13.5px; font-weight: 700; letter-spacing: .01em; }
.nav__sub { font-size: 10.5px; color: var(--nav-text); text-transform: uppercase; letter-spacing: .1em; }

.nav__scroll { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.nav__group { margin-top: 14px; }
.nav__group:first-child { margin-top: 2px; }
.nav__grouplabel {
  font-size: 10px; text-transform: uppercase; letter-spacing: .12em;
  color: #5d6b7e; padding: 0 8px 6px; font-weight: 700;
}
.nav__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; margin-bottom: 1px;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--nav-text); font-size: 13px; text-align: left; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav__item:hover { background: var(--nav-bg-2); color: var(--nav-text-hi); }
.nav__item.is-active { background: var(--nav-bg-2); color: var(--nav-text-hi); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.nav__icon { width: 17px; flex: 0 0 17px; text-align: center; font-size: 14px; opacity: .95; }
.nav__count {
  margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 6px;
  border-radius: 20px; background: var(--bad); color: #fff; min-width: 18px; text-align: center;
}
.nav__count--muted { background: #33404f; color: #c3ccd8; }
.nav__foot { padding: 10px; border-top: 1px solid var(--nav-line); font-size: 11px; color: #5d6b7e; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.top {
  height: var(--top-h); flex: 0 0 var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.top__menu { display: none; }
.top__title { font-size: 16px; font-weight: 650; }
.top__crumb { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }
.top__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top__date { font-size: 12px; color: var(--text-2); padding-right: 4px; white-space: nowrap; }

.view { padding: 20px; max-width: 1500px; width: 100%; }
.view__head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.view__head h2 { font-size: 19px; }
.view__head p { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.view__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; min-height: 40px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn--danger { color: var(--bad); border-color: var(--line); }
.btn--danger:hover { background: var(--bad-soft); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--sm { padding: 5px 10px; min-height: 32px; font-size: 12.5px; }
.btn--icon { padding: 6px; width: 38px; height: 38px; min-height: 0; }
.btn--big { padding: 13px 20px; min-height: 52px; font-size: 15px; border-radius: var(--r); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh-1);
}
.card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px; border-bottom: 1px solid var(--line-soft);
}
.card__head h3 { font-size: 14px; }
.card__head .sub { font-size: 12px; color: var(--text-3); }
.card__head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card__body { padding: 15px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sb { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid--bs { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }

/* ---------- Stat tiles ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px; box-shadow: var(--sh-1); position: relative; overflow: hidden;
}
.stat__label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 650; }
.stat__value { font-size: 23px; font-weight: 700; margin-top: 5px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat__meta { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.stat__bar { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.stat--ok   .stat__bar { background: var(--ok); }
.stat--bad  .stat__bar { background: var(--bad); }
.stat--warn .stat__bar { background: var(--warn); }
.stat--info .stat__bar { background: var(--info); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 700; padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .act { text-align: right; white-space: nowrap; width: 1%; }
.tbl tfoot td { padding: 10px 12px; border-top: 2px solid var(--line); font-weight: 700; background: var(--surface-2); }
.tbl--sm td, .tbl--sm th { padding: 6px 10px; }
.rowbtn {
  background: none; border: 0; cursor: pointer; color: var(--text-3);
  padding: 4px 6px; border-radius: var(--r-sm); font-size: 13px;
}
.rowbtn:hover { background: var(--surface-3); color: var(--text); }
.rowbtn--del:hover { background: var(--bad-soft); color: var(--bad); }

.empty { padding: 40px 20px; text-align: center; color: var(--text-3); }
.empty__icon { font-size: 26px; opacity: .5; }
.empty__title { font-weight: 600; color: var(--text-2); margin-top: 8px; font-size: 13.5px; }
.empty__text { font-size: 12.5px; margin-top: 3px; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 650;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge--ok   { background: var(--ok-soft);   color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad  { background: var(--bad-soft);  color: var(--bad); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent-hi); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 7px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field__label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field__label .req { color: var(--bad); }
.field__hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.inp {
  width: 100%; padding: 9px 11px; min-height: 42px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s; font-size: 14px;
}
.inp:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp[readonly] { background: var(--surface-2); color: var(--text-2); }
textarea.inp { resize: vertical; min-height: 66px; }
select.inp { appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.inp--num { text-align: right; font-variant-numeric: tabular-nums; }
/* Padded to a ~44px touch target — the label, not just the 15px box, is
   clickable, so this passes on a phone even if the tap lands a few px off. */
.check {
  display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer;
  padding: 11px 4px; margin: -11px -4px; border-radius: var(--r-sm);
}
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 17px; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.formgrid .col-2 { grid-column: span 2; }
.inputgroup { display: flex; }
.inputgroup .inp { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.inputgroup__suffix {
  display: grid; place-items: center; padding: 0 10px; font-size: 12px; color: var(--text-3);
  border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface-2); white-space: nowrap;
}

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .inp { width: auto; min-width: 150px; }
.search { position: relative; flex: 1 1 200px; max-width: 300px; }
.search .inp { padding-left: 30px; }
.search__icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 12px; pointer-events: none; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: none; padding: 5px 12px; border-radius: 5px;
  font-size: 12.5px; font-weight: 550; color: var(--text-2); cursor: pointer;
}
.seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(11, 17, 24, .55);
  backdrop-filter: blur(3px); display: grid; place-items: center;
  padding: 20px; z-index: 100; animation: fade .14s ease;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
  border: 1px solid var(--line); animation: pop .16s cubic-bezier(.2,.9,.3,1.1);
}
.modal--wide { max-width: 860px; }
.modal__head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); }
.modal__head h3 { font-size: 15px; }
.modal__head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.modal__body { padding: 18px; overflow-y: auto; }
.modal__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 13px 18px; border-top: 1px solid var(--line-soft); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop  { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--nav-bg); color: #fff; padding: 10px 15px; border-radius: var(--r);
  box-shadow: var(--sh-3); font-size: 13px; display: flex; align-items: center; gap: 9px;
  animation: slidein .2s ease; max-width: 330px;
}
.toast--ok  { border-left: 3px solid #4ade80; }
.toast--bad { border-left: 3px solid #f87171; }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.kcol__head { display: flex; align-items: center; gap: 8px; padding: 10px 13px; border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 700; }
.kcol__count { margin-left: auto; font-size: 11px; color: var(--text-3); background: var(--surface-3); padding: 1px 7px; border-radius: 10px; }
.kcol__body { padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 70px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 12px; box-shadow: var(--sh-1); }
.kcard__title { font-size: 13px; font-weight: 600; line-height: 1.35; }
.kcard__meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 11.5px; color: var(--text-3); }
.kcard__foot { display: flex; gap: 5px; margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line); }

/* ---------- Misc ---------- */
.chart { display: flex; align-items: stretch; gap: 7px; height: 172px; padding-top: 18px; }
.chart__col { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
/* flex:1 in a column flex box of definite height gives the track a definite
   height, so the bar's percentage height below actually resolves. */
.chart__track { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.chart__bar {
  width: 100%; max-width: 42px; background: var(--accent);
  border-radius: 4px 4px 0 0; min-height: 2px; position: relative; transition: opacity .12s;
}
.chart__col:hover .chart__bar { opacity: .75; }
.chart__lbl { font-size: 10.5px; color: var(--text-3); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart__val {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  margin-bottom: 3px; font-size: 10.5px; font-weight: 650; color: var(--text-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chart--dense .chart__val { display: none; }
.chart--dense .chart__col:hover .chart__val { display: block; }
.chart--dense .chart__lbl { font-size: 9.5px; }

.breakup { display: flex; flex-direction: column; gap: 8px; }
.breakup__row { display: grid; grid-template-columns: 130px 1fr 92px; gap: 10px; align-items: center; font-size: 12.5px; }
.breakup__track { height: 7px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.breakup__fill { height: 100%; background: var(--accent); border-radius: 4px; }
.breakup__amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--text-2); }
.kv__v { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.kv--total { border-top: 2px solid var(--line); border-bottom: 0; margin-top: 5px; padding-top: 10px; font-size: 15px; }
.kv--total .kv__v { color: var(--accent-hi); font-size: 17px; }

.mono { font-family: var(--font-mono); font-size: 12px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.strong { font-weight: 650; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.flexrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }
.sectitle { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3); font-weight: 700; margin: 18px 0 9px; }
.sectitle:first-child { margin-top: 0; }
.hint-box { background: var(--info-soft); color: var(--info); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.warn-box { background: var(--warn-soft); color: var(--warn); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12.5px; }

.print-only { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--sb, .grid--bs { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .nav { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--sh-3); z-index: 60; }
  .nav.is-open { transform: none; }
  .top__menu { display: inline-flex; }
  .grid--3, .kanban { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 15px; }
  .nav-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
}
@media (max-width: 620px) {
  .grid--2, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .formgrid { grid-template-columns: minmax(0, 1fr); }
  .formgrid .col-2 { grid-column: span 1; }
  .breakup__row { grid-template-columns: 96px 1fr 78px; }
  .top { padding: 0 10px; gap: 6px; }
  .top__crumb { display: none; }
  .top__right { gap: 5px; }
  .top__date { display: none; }
  .top__clock { font-size: 11.5px; padding: 3px 7px; }
  .userpill { padding: 3px; }
  .userpill__name { display: none; }
  #addBtn { padding-left: 10px; padding-right: 10px; }
  /* Phone: the bottom tab bar is the primary nav, so the hamburger + drawer step aside. */
  .top__menu { display: none; }
  .main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  /* .tabbar's own display:flip lives with the rest of the v3 component
     block further down the file — a rule set there would win the cascade
     over this one by source order alone, so the switch is kept there. */
}

/* ==========================================================================
   v2 — shop-floor components
   ========================================================================== */

/* ---- Larger text mode (Settings -> Text size) ---- */
[data-size="large"] { font-size: 16.5px; }
[data-size="large"] .inp { min-height: 48px; font-size: 15.5px; }
[data-size="large"] .btn { min-height: 46px; font-size: 15px; }
[data-size="large"] .tbl { font-size: 14.5px; }
[data-size="large"] .stat__value { font-size: 26px; }
[data-size="large"] .nav__item { font-size: 14.5px; padding: 11px 10px; }

/* ---- Plain-language help strip ---- */
.pagehelp {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r); padding: 11px 14px; margin-bottom: 14px; font-size: 13.5px; color: var(--text-2);
}
.pagehelp b { color: var(--text); }
.pagehelp__icon { font-size: 17px; line-height: 1.3; }

/* ---- Big action tiles (quick entry) ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 14px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; text-align: left;
  transition: border-color .12s, transform .07s, box-shadow .12s;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--sh-2); }
.tile:active { transform: translateY(1px); }
.tile__icon { font-size: 22px; }
.tile__label { font-weight: 650; font-size: 14px; color: var(--text); }
.tile__sub { font-size: 12px; color: var(--text-3); }

/* ---- Calculator ---- */
.calc {
  background: var(--nav-bg); border-radius: 18px; padding: 16px;
  box-shadow: var(--sh-3); border: 1px solid var(--nav-line);
}
.calc__lcd {
  background: #10241f; border-radius: 12px; padding: 14px 16px;
  border: 1px solid #1d3b34; box-shadow: inset 0 2px 12px rgba(0,0,0,.5);
}
.calc__lcdlabel {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: #4f9e86; font-weight: 700;
}
.calc__lcdvalue {
  font-family: var(--font-mono); font-size: 38px; font-weight: 700; color: #7df5cd;
  line-height: 1.1; margin-top: 2px; text-shadow: 0 0 18px rgba(125,245,205,.35);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.calc__lcdunit { font-size: 17px; color: #4f9e86; margin-left: 6px; }
.calc__lcdrow { display: flex; gap: 14px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed #1d3b34; flex-wrap: wrap; }
.calc__mini { min-width: 0; }
.calc__minilabel { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: #3f8471; font-weight: 700; }
.calc__minivalue { font-family: var(--font-mono); font-size: 14.5px; color: #9ff7d8; white-space: nowrap; }

.calc__chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 14px; }
.chip {
  display: flex; flex-direction: column; gap: 1px; padding: 8px 11px;
  background: var(--nav-bg-2); border: 1px solid var(--nav-line); border-radius: 9px;
  cursor: pointer; text-align: left; transition: border-color .12s, background .12s;
}
.chip:hover { background: #232f3e; }
.chip.is-active { border-color: var(--accent); background: #2a2114; box-shadow: 0 0 0 1px var(--accent); }
.chip__label { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: #7b8798; font-weight: 700; }
.chip.is-active .chip__label { color: #f0b563; }
.chip__value { font-family: var(--font-mono); font-size: 15px; color: #fff; font-weight: 600; }
.chip__unit { font-size: 11px; color: #7b8798; font-weight: 400; }

.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 12px; }
.key {
  height: 52px; border-radius: 10px; border: 1px solid var(--nav-line);
  background: var(--nav-bg-2); color: #fff; font-size: 19px; font-weight: 600;
  cursor: pointer; transition: background .1s, transform .05s;
  display: grid; place-items: center;
}
.key:hover { background: #2a3646; }
.key:active { transform: translateY(2px); background: #35435a; }
.key--fn { background: #202c3a; color: #a6b1c2; font-size: 15px; }
.key--accent { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 15px; }
.key--accent:hover { background: var(--accent-hi); }
.key--wide { grid-column: span 2; }

/* ---- Kanban drag & drop ---- */
.kcard { cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard.is-dragging { opacity: .4; transform: rotate(1.5deg); }
.kcol.is-over { background: var(--accent-soft); }
.kcol.is-over .kcol__body { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: var(--r); }
.kdrag { font-size: 13px; color: var(--text-3); cursor: grab; user-select: none; }

/* ---- Goal / target meters ---- */
.goal { padding: 4px 0; }
.goal__top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 9px; }
.goal__value { font-size: 27px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.goal__of { color: var(--text-3); font-size: 14px; }
.goal__pct { margin-left: auto; font-size: 18px; font-weight: 750; }
.goalbar {
  position: relative; height: 15px; background: var(--surface-3);
  border-radius: 10px; overflow: hidden;
}
.goalbar__fill {
  height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--accent), #f0a93c);
  transition: width .4s cubic-bezier(.2,.8,.3,1);
}
.goalbar__fill--ok { background: linear-gradient(90deg, #15803d, #4ade80); }
.goalbar__fill--bad { background: linear-gradient(90deg, #b91c1c, #f87171); }
.goalbar__pace {
  position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text);
  opacity: .55;
}
.goal__legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 9px; font-size: 12.5px; color: var(--text-2); }
.goal__legend b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- Ledger / balance colouring ---- */
.amt-due { color: var(--bad); font-weight: 700; }
.amt-clear { color: var(--ok); font-weight: 650; }
.amt-adv { color: var(--info); font-weight: 650; }

/* ---- Month calendar ---- */
.cal__nav { display: flex; align-items: center; gap: 8px; margin-bottom: 11px; }
.cal__title { font-weight: 700; font-size: 14.5px; }
.cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal__wd {
  text-align: center; font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); font-weight: 700; padding-bottom: 3px;
}
.cal__day {
  min-height: 56px; border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 5px 6px; background: var(--surface); text-align: left;
  display: flex; flex-direction: column; gap: 3px; overflow: hidden;
  font: inherit; color: inherit;
}
.cal__day--out { border-color: transparent; background: transparent; }
.cal__day--has { cursor: pointer; border-color: var(--line); }
.cal__day--has:hover { border-color: var(--accent); background: var(--surface-2); }
.cal__day--today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal__day--today .cal__num { color: var(--accent-hi); font-weight: 800; }
.cal__day--sun .cal__num { color: var(--bad); }
.cal__num { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal__dots { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; line-height: 1; }
.cal__dot { font-size: 10.5px; }
.cal__more { font-size: 9.5px; color: var(--text-3); font-weight: 600; }
.cal__legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 11px; font-size: 11.5px; color: var(--text-2); }
.cal__legend span { display: inline-flex; align-items: center; gap: 4px; }

/* ---- Month-on-month growth ---- */
.mom { font-size: 12px; font-weight: 700; white-space: nowrap; }
.mom--up { color: var(--ok); }
.mom--down { color: var(--bad); }
.mom--flat { color: var(--text-3); }

/* ---- Import/export drop area ---- */
.drop {
  border: 2px dashed var(--line); border-radius: var(--r); padding: 24px;
  text-align: center; color: var(--text-2); background: var(--surface-2);
  transition: border-color .12s, background .12s;
}
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop__icon { font-size: 26px; }

@media (max-width: 620px) {
  .calc__lcdvalue { font-size: 30px; }
  .key { height: 48px; }
  .cal__day { min-height: 44px; padding: 3px 4px; }
  .cal__grid { gap: 3px; }
}

/* ==========================================================================
   v3 — team login, header identity, phone navigation
   ========================================================================== */

/* ---- Header clock ---- */
.top__clock {
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text); padding: 3px 9px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap;
}

/* ---- Sync status dot ---- */
.syncdot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px;
  background: var(--text-3); box-shadow: 0 0 0 3px transparent; transition: background .2s;
}
.syncdot--ok   { background: var(--ok); }
.syncdot--busy { background: var(--info); animation: syncpulse 1s ease-in-out infinite; }
.syncdot--off  { background: var(--warn); }
.syncdot--err  { background: var(--bad); }
@keyframes syncpulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---- User pill + dropdown ---- */
.userpill {
  display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px 4px;
  border-radius: 20px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font: inherit; color: var(--text);
}
.userpill:hover { background: var(--surface-3); }
.userpill__name { font-size: 12.5px; font-weight: 650; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.acct__avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px;
  letter-spacing: .02em;
}
.acct__avatar--sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 10.5px; }
.acct__id { display: flex; align-items: center; gap: 12px; }
.acct__name { font-size: 15.5px; font-weight: 700; }

.usermenu {
  position: fixed; top: calc(var(--top-h) + 8px); right: 16px; z-index: 90;
  width: 240px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh-3); padding: 6px; animation: pop .14s ease;
}
.usermenu__who { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; }
.usermenu__sync { font-size: 11px; color: var(--text-3); padding: 0 8px 8px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.usermenu__item {
  display: block; width: 100%; text-align: left; padding: 9px 8px; border-radius: var(--r-sm);
  border: 0; background: none; font-size: 13.5px; color: var(--text); cursor: pointer;
}
.usermenu__item:hover { background: var(--surface-3); }
.usermenu__item--danger { color: var(--bad); }

/* ---- Phone bottom tab bar ---- */
.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--nav-bg); border-top: 1px solid var(--nav-line);
  z-index: 45; align-items: stretch;
}
.tabbar__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: 0; background: none; color: var(--nav-text); position: relative;
  font: inherit; padding: 4px 2px;
}
.tabbar__item.is-active { color: var(--nav-text-hi); }
.tabbar__item.is-active .tabbar__icon { transform: translateY(-1px); }
.tabbar__icon { font-size: 19px; line-height: 1; transition: transform .12s; }
.tabbar__label { font-size: 9.5px; font-weight: 650; letter-spacing: .01em; }
.tabbar .nav__count {
  position: absolute; top: 2px; right: 22%; min-width: 15px; height: 15px; line-height: 15px;
  padding: 0 3px; font-size: 9px;
}
@media (max-width: 620px) {
  .tabbar { display: flex; }
}

/* ---- Office entrance: door + login/setup card ---- */
#authRoot { position: fixed; inset: 0; z-index: 200; }
.doorstage {
  position: relative; width: 100%; height: 100%; overflow: hidden;
  perspective: 1600px; background: var(--nav-bg);
}
.doorstage__backdrop {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(217, 119, 6, .16), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.035) 0 1px, transparent 1px 64px),
    linear-gradient(180deg, #0d141d 0%, #0a0e13 100%);
}
.doorstage__office {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px;
  transform: scale(.94); filter: blur(6px); opacity: 0; transition: transform .7s ease, filter .7s ease, opacity .7s ease;
  transition-delay: .15s;
}
.doorstage.is-open .doorstage__office { transform: scale(1); filter: blur(0); opacity: 1; }

.officecard {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); padding: 26px 24px 22px; border: 1px solid var(--line);
}
.officecard__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.officecard__logo {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(145deg, var(--accent), #92400e); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.officecard__title { font-size: 15px; font-weight: 750; color: var(--text); }
.officecard__sub { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }

.authform h2 { font-size: 18px; margin-bottom: 6px; }
.authform__hint { font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin-bottom: 16px; }
.authform .field { margin-bottom: 12px; }
.authform__err {
  background: var(--bad-soft); color: var(--bad); border-radius: var(--r-sm);
  padding: 8px 11px; font-size: 12.5px; margin-bottom: 12px; line-height: 1.4;
}
.authform__foot { font-size: 11.5px; color: var(--text-3); text-align: center; margin-top: 12px; line-height: 1.5; }

/* The door itself — a hinged panel over the office, in perspective. */
.door { position: absolute; inset: 0; pointer-events: none; }
.door__frame {
  position: absolute; inset: 6% 8%; border-radius: 18px;
  border: 10px solid #1c2531; box-shadow: 0 0 0 2px rgba(255,255,255,.04);
}
.door__panel {
  position: absolute; inset: 6% 8%; border-radius: 12px;
  background:
    linear-gradient(155deg, #2a3646 0%, #1a2330 55%, #141c27 100%);
  border: 1px solid rgba(255,255,255,.06);
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform 1s cubic-bezier(.5, 0, .2, 1), box-shadow 1s ease;
  box-shadow: 12px 0 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  pointer-events: auto;
}
.doorstage.is-open .door__panel { transform: rotateY(-100deg); box-shadow: 40px 0 70px rgba(0,0,0,.65); }
.doorstage.is-open .door { transition: opacity .45s ease .55s; opacity: 0; pointer-events: none; }
.doorstage.is-instant .door { transition: none; opacity: 0; pointer-events: none; }
.doorstage.is-instant .doorstage__office { transition: none; transform: none; filter: none; opacity: 1; }

.door__plaque { text-align: center; }
.door__plaque-line1 { font-size: 15px; font-weight: 800; letter-spacing: .12em; color: #f2c98a; }
.door__plaque-line2 { font-size: 10.5px; font-weight: 650; letter-spacing: .22em; color: #8a97a8; margin-top: 3px; }
.door__handle {
  width: 9px; height: 46px; border-radius: 5px; position: absolute; right: 9%; top: 50%;
  transform: translateY(-50%); background: linear-gradient(180deg, #d4af6a, #8a6a2e);
  box-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.door__enter {
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06); color: #fff;
  padding: 11px 20px; border-radius: 30px; font-size: 13.5px; font-weight: 650; cursor: pointer;
  transition: background .15s, transform .1s;
}
.door__enter:hover { background: rgba(255,255,255,.13); }
.door__enter:active { transform: scale(.97); }

@media (max-width: 460px) {
  .door__frame, .door__panel { inset: 4% 4%; }
  .door__plaque-line1 { font-size: 13px; }
  .officecard { padding: 22px 18px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .door__panel, .doorstage__office, .door { transition-duration: .01ms !important; }
}

@media print {
  .nav, .top, .view__actions, .toolbar, .toasts, .rowbtn, .btn { display: none !important; }
  body { background: #fff; }
  .view { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .print-only { display: block; }
}
