/* CRAFTFITI OFFICE - shop CI. Tokens copied 1:1 from CraftfitiWeb/public/staff/staff.css (:root + :root[data-theme="light"]). */
:root {
  --ink: #15110D;
  --ink-2: #1E1812;
  --ink-3: #0E0B08;
  --paper: #EDE8DD;
  --cream: #F6F2EA;
  --yellow: #F5D547;
  --accent: #F5D547;          /* yellow used as TEXT / outline (a darker gold on the light theme) */
  --on-yellow: #15110D;       /* text on a yellow fill, in both themes */
  --red: #A3232B;
  --red-soft: #E5646B;
  --green: #2F6B3A;
  --green-soft: #7FD08F;
  --muted: #CFC6B6;
  --line: #3A3128;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --ink: #F6F2EA;
  --ink-2: #FFFFFF;
  --ink-3: #ECE6D8;
  --cream: #15110D;
  --accent: #7A5D00;
  --red-soft: #A3232B;
  --green-soft: #2F6B3A;
  --muted: #5B5347;
  --line: #CFC6B6;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ink-3); -webkit-text-size-adjust: 100%; font-variant-numeric: lining-nums; }
body { margin: 0; background: var(--ink-3); color: var(--cream); font-family: 'Poppins', 'Prompt', system-ui, sans-serif; font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hide { display: none !important; }
.mut { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1 1 140px; min-width: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- shell ---- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 14px 56px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(12px + var(--safe-t)) 0 12px; }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand img { height: 30px; width: auto; display: block; flex: none; }
.brand img.logo-light { display: none; }
:root[data-theme="light"] .brand img.logo-dark { display: none; }
:root[data-theme="light"] .brand img.logo-light { display: block; }
.brand__t { min-width: 0; flex: 1 1 auto; }

.brand__sub { overflow-wrap: anywhere; }
.brand__name { font-weight: 800; letter-spacing: .06em; font-size: 14px; line-height: 1.2; }
.brand__sub { font-size: 12px; color: var(--muted); }
.iconbtn { min-width: 44px; height: 44px; padding: 0 12px; flex: none; border-radius: 22px; border: 1px solid var(--line); background: var(--ink-2); color: var(--cream); font-size: 14px; font-weight: 600; cursor: pointer; }
.iconbtn.round { width: 44px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1; }

.monthbar { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; margin: 4px 0 12px; }
.mbtn { height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink-2); font-size: 22px; font-weight: 700; cursor: pointer; }
.mlabel { display: flex; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--line); background: var(--ink-2); font-size: 20px; font-weight: 700; letter-spacing: .04em; color: var(--accent); }

.tabs { position: sticky; top: 0; z-index: 20; display: flex; background: var(--ink-3); border-bottom: 1px solid var(--line); margin: 0 -14px 16px; padding: 0 14px; overflow-x: auto; }
.tab { flex: 1 0 auto; min-height: 50px; padding: 0 18px; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; }
.tab.is-active { color: var(--accent); border-bottom-color: var(--yellow); }

/* ---- cards ---- */
.card { background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.card.warnc { border-color: var(--yellow); }
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.card p + p, .card p + .tscroll, .card .tscroll + p { margin-top: 10px; }
.sub { color: var(--muted); font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.warnlist { margin: 6px 0 0; padding-left: 20px; }
.warnlist li { margin: 4px 0; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-width: 0; }
.stat__l { font-size: 12px; color: var(--muted); }
.stat__v { font-size: 24px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chip { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; border: 1px solid var(--line); }
.chip.ok { background: var(--green); color: #fff; border-color: var(--green); }
.chip.open { background: var(--yellow); color: var(--on-yellow); border-color: var(--yellow); }
.chip.bad { background: var(--red); color: #fff; border-color: var(--red); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; border: 1px solid var(--line); }
.tag.ok { color: var(--green-soft); border-color: var(--green-soft); }
.tag.man { color: var(--accent); border-color: var(--accent); }
.ok { color: var(--green-soft); }
.bad { color: var(--red-soft); }

/* ---- collapsible sections ---- */
details.sec { background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; }
details.sec > summary { list-style: none; cursor: pointer; padding: 16px; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; min-height: 52px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: "+"; margin-left: auto; color: var(--accent); font-size: 22px; line-height: 1; }
details.sec[open] > summary::after { content: "\2212"; }
details.sec > .body { padding: 0 16px 16px; }

/* ---- tables ---- */
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; background: var(--ink-3); }
th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tr.top1 td { color: var(--accent); font-weight: 700; }
tr.miss td { color: var(--red-soft); }
tr.zero td { color: var(--muted); }
tr.fixrow td { background: var(--ink-3); }
.trail { white-space: pre-wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.big { font-size: 17px; font-weight: 700; }
.opt { display: none; }
@media (min-width: 700px) { .opt { display: table-cell; } }

/* ---- buttons + inputs ---- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 2px solid var(--line); background: transparent; color: var(--cream); font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-align: center; line-height: 1.2; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.pri { background: var(--yellow); border-color: var(--yellow); color: var(--on-yellow); }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red-soft); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
input, select { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink-3); width: 100%; }
.row input, .row select { width: auto; max-width: 100%; min-width: 0; }
select { max-width: 100%; text-overflow: ellipsis; }
.row input.grow, .row select.grow { width: auto; flex: 1 1 140px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; margin-top: 6px; }

/* ---- messages, toasts, busy ---- */
.msg { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink-2); margin-bottom: 12px; }
.msg.bad { border-color: var(--red-soft); color: var(--cream); }
.msg.warn { border-color: var(--yellow); }
.msg.ok { border-color: var(--green-soft); }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 14px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 560px; width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink-2); box-shadow: 0 6px 18px rgba(0,0,0,.45); display: flex; align-items: center; gap: 10px; }
.toast.ok { border-color: var(--green-soft); }
.toast.bad { border-color: var(--red-soft); }
.toast.warn { border-color: var(--yellow); }
.toast span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.busy { position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 70; overflow: hidden; background: rgba(245,213,71,.25); }
.busy::before { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--yellow); animation: slide 1.1s ease-in-out infinite; }
.busy.bg { opacity: .4; }
@keyframes slide { from { left: -40%; } to { left: 100%; } }
.busy .spin { display: none; }
@keyframes pulse { from { opacity: .25; } to { opacity: 1; } }

.login { max-width: 420px; margin: 0 auto; }
.src { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.src:last-child { border-bottom: 0; }

@media (min-width: 700px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .wrap { padding: 0 24px 64px; }
  .tabs { margin: 0 -24px 18px; padding: 0 24px; }
}
td input, td select { min-width: 110px; }

/* ---- OFF-2 payroll: month table, edit panel, save bar, confirm dialog ---- */
.tag.bad { color: var(--red-soft); border-color: var(--red-soft); }
.msg.ok { color: var(--cream); }
.pt { font-size: 13px; min-width: 100%; }
.pt th, .pt td { padding: 9px 10px; white-space: nowrap; }
.pt th.s1, .pt td.s1 { position: sticky; left: 0; z-index: 2; width: 58px; min-width: 58px; max-width: 58px; background: var(--ink-2); }
.pt th.s2, .pt td.s2 { position: sticky; left: 58px; z-index: 2; min-width: 120px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; background: var(--ink-2); box-shadow: 2px 0 0 var(--line); }
.pt th.s1, .pt th.s2 { background: var(--ink-3); z-index: 3; }
.pt tr.prow { cursor: pointer; }
.pt tr.prow:hover td, .pt tr.prow:focus td { background: var(--ink-3); }
.pt tr.prow.sel td { background: var(--ink-3); box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
.pt tr.prow.off td { color: var(--muted); }
.pt td.zero { color: var(--muted); }
.pt td.calc { font-weight: 700; }
.pt td.man { color: var(--accent); }
.pt tr.ptotal td { font-weight: 800; border-top: 2px solid var(--line); background: var(--ink-3); }
.pt tr.ptotal td.s1, .pt tr.ptotal td.s2 { background: var(--ink-3); }
.pt .tag { margin-right: 4px; }

.savebar { position: sticky; bottom: 0; z-index: 25; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px calc(12px + var(--safe-b)); margin: 0 -14px; background: var(--ink-3); border-top: 1px solid var(--line); }
.savebar__t { flex: 1 1 200px; min-width: 0; font-weight: 600; }

.pback { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); }
.ppanel { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--ink-2); border: 1px solid var(--line); border-radius: 16px 16px 0 0; padding: 16px 14px calc(24px + var(--safe-b)); box-shadow: 0 -8px 28px rgba(0,0,0,.5); }
.phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; position: sticky; top: -16px; background: var(--ink-2); padding: 6px 0; z-index: 1; }
.pgroup { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.pgroup h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--accent); }
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.pfield { min-width: 0; }
.pfield.wide { grid-column: 1 / -1; }
.pfield label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.pfield input, .pfield select { width: 100%; }
.ptags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 22px; margin-top: 4px; }
.pcalc { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--ink-3); }
.pcalc .kv .num { font-weight: 700; }
.trows { display: grid; gap: 8px; margin: 8px 0; }
.trow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.trow select { grid-column: 1 / -1; }
.trow .btn { grid-column: 1 / -1; }
.ppanel select { min-height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink-3); width: 100%; }

.mback { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; background: var(--ink-2); border: 1px solid var(--yellow); border-radius: 14px; padding: 18px; }
.modal h2 { font-size: 17px; margin-bottom: 10px; }

@media (min-width: 1000px) {
  .pback { display: none; }
  .ppanel { left: auto; top: 0; right: 0; bottom: 0; width: 440px; max-height: none; border-radius: 0; border-width: 0 0 0 1px; padding-top: 18px; box-shadow: -8px 0 28px rgba(0,0,0,.35); }
  .phead { top: -18px; }
  .paypage.has-panel { margin-right: 452px; }
  .paypage.has-panel .savebar { margin-right: 0; }
  .trow { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
  .trow select, .trow .btn { grid-column: auto; }
}
@media (min-width: 700px) { .savebar { margin: 0 -24px; padding-left: 24px; padding-right: 24px; } }

/* ---- OFF-3 documents tab ---- */
.prog { margin-top: 12px; display: grid; gap: 4px; }
.prog:empty { display: none; }
.prog .msg { margin: 6px 0 0; }
.src > span:first-child { flex: none; }
.src.chk { flex-wrap: nowrap; align-items: flex-start; }
.src.chk > span:nth-child(2) { flex: 1 1 0; min-width: 0; }

/* ---- FIX 1: "updated at" chip ---- */
.upd { display: inline-block; margin: -6px 0 10px; padding: 2px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); }
.upd.busy { color: var(--accent); border-color: var(--accent); }
.upd.warn { color: var(--cream); border-color: var(--yellow); }

/* ---- FIX 2: instant feedback ---- */
.bspin { display: inline-block; width: 14px; height: 14px; margin-right: 8px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-busy { opacity: .85; cursor: progress; }
.btn.is-busy:disabled { opacity: .85; }
.btn.is-ok { background: var(--green); border-color: var(--green); color: #fff; opacity: 1 !important; }
.skel { display: grid; gap: 12px; }
.skel i { display: block; height: 16px; border-radius: 8px; background: linear-gradient(90deg, var(--line) 25%, var(--ink-3) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.runpill { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--safe-b)); z-index: 65; padding: 10px 18px; border-radius: 999px; border: 2px solid var(--yellow); background: var(--ink-2); color: var(--accent); font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.45); }
.runcard { border: 2px solid var(--yellow); }
.runcard.done { border-color: var(--green-soft); }
.runcard.stop { border-color: var(--red-soft); }
.pbar { position: relative; height: 22px; border-radius: 11px; background: var(--ink-3); border: 1px solid var(--line); overflow: hidden; margin: 10px 0; }
.pbar__fill { height: 100%; background: var(--yellow); transition: width .4s ease; }
.runcard.done .pbar__fill { background: var(--green-soft); }
.runcard.stop .pbar__fill { background: var(--red-soft); }
.pbar__t { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--on-yellow); mix-blend-mode: normal; }
.runcard .steps { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0; }
.card.realc { border-color: var(--red-soft); }
.card.trialc { border-color: var(--green-soft); }
a.btn { text-decoration: none; }

/* Incentive: sales target card */
.card.gate--no { border-color: var(--red-soft); }
.card.gate--ok { border-color: var(--green-soft); }
.gate__v { font-size: 26px; font-weight: 800; margin: 2px 0 10px; }
.gate__bar { height: 12px; border-radius: 999px; background: var(--ink-3); border: 1px solid var(--line); overflow: hidden; margin-bottom: 10px; }
.gate__fill { height: 100%; background: var(--red-soft); }
.gate--ok .gate__fill { background: var(--green-soft); }

/* Settings: API key shown once */
.keybox { display: block; margin: 10px 0; padding: 10px 12px; border-radius: 8px; background: var(--ink-3); border: 1px solid var(--line); font-size: 13px; word-break: break-all; user-select: all; }

/* label under the activity bar: says what is loading */
.busy-label { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 71; max-width: calc(100% - 24px);
  padding: 7px 14px; border-radius: 999px; background: var(--yellow); color: var(--on-yellow); font-size: 14px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.busy-label.bg { background: var(--ink-2); color: var(--cream); border: 1px solid var(--line); font-weight: 500; }

/* Incentive: past months look different from the current one */
.card.gate--ended { border-style: dashed; border-color: var(--muted); }
.card.gate--closed { border-color: var(--line); background: var(--ink-3); }
.gate--ended .gate__fill, .gate--closed .gate__fill { background: var(--muted); }
.gate--ended.gate--ok .gate__fill, .gate--closed.gate--ok .gate__fill { background: var(--green-soft); }
.gate__warn { margin-top: 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--yellow); color: var(--accent); font-weight: 700; }
.chip.past { background: transparent; color: var(--cream); border: 1px dashed var(--muted); }

/* late-close flags */
.gate__late { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--ink-3); border: 1px solid var(--line); display: grid; gap: 6px; font-size: 14px; }
.gate__edge { color: var(--accent); font-weight: 700; }
.tag.late { color: var(--accent); border-color: var(--accent); white-space: nowrap; }

.gate__split { font-size: 16px; font-weight: 700; }
.gate__split--late { color: var(--accent); }
