/* ConstractAI — site-office visual system
   Concrete surfaces, graphite ink, hi-vis yellow for the one thing you should do next. */

@font-face {
  font-family: 'Archivo'; font-style: normal; font-display: swap;
  font-weight: 100 900; font-stretch: 62% 125%;
  src: url('vendor/archivo-wdth.woff2') format('woff2-variations'), url('vendor/archivo-wdth.woff2') format('woff2');
}

:root {
  --concrete:   #E8EBE9;
  --concrete-2: #DDE1DF;
  --panel:      #FFFFFF;
  --graphite:   #1E2731;
  --graphite-2: #2A3541;
  --steel:      #5B6772;
  --steel-2:    #8A949C;
  --rule:       #D3D8D6;
  --rule-soft:  #E6E9E8;
  --hivis:      #FFC21A;
  --hivis-ink:  #3B2C00;

  --series-1: #257de0;   /* orders */
  --series-2: #f47230;   /* petty cash */
  --series-3: #00b894;

  --good:     #0a8f1f;
  --good-bg:  #E3F4E5;
  --warn:     #B87400;
  --warn-bg:  #FFF3D6;
  --bad:      #C9302F;
  --bad-bg:   #FBE5E4;
  --info:     #1B64BE;
  --info-bg:  #E2EEFC;

  --r-sm: 4px;
  --r-md: 8px;
  --shadow: 0 1px 0 rgba(30, 39, 49, .06), 0 2px 8px -4px rgba(30, 39, 49, .18);
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --side: 236px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  color: var(--graphite); background: var(--concrete);
  font-variant-numeric: tabular-nums; font-variation-settings: 'wdth' 100;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-variation-settings: 'wdth' 118; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
code { font-size: 12.5px; background: var(--concrete); padding: 1px 5px; border-radius: 3px; }
small, .muted { color: var(--steel); }
:focus-visible { outline: 3px solid var(--hivis); outline-offset: 2px; border-radius: 3px; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  background: var(--graphite); color: #C9D1D8; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 12px;
  /* faint blueprint grid */
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 24px 24px;
}
.brandmark { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800;
  font-variation-settings: 'wdth' 125; font-size: 17px; letter-spacing: -.01em; padding: 4px 8px 18px; }
.brandmark-glyph {
  width: 26px; height: 26px; border-radius: 5px; background: var(--hivis); position: relative; flex: none;
  /* a tiny I-beam */
  background-image: linear-gradient(var(--graphite), var(--graphite)), linear-gradient(var(--graphite), var(--graphite)), linear-gradient(var(--graphite), var(--graphite));
  background-size: 14px 3px, 3px 12px, 14px 3px; background-position: 6px 5px, 11.5px 7px, 6px 18px; background-repeat: no-repeat;
}
.brandmark--lg { color: var(--graphite); font-size: 20px; padding: 0 0 18px; }
.side-company { font-size: 12px; color: var(--steel-2); padding: 0 8px 14px; margin-top: -12px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { font-size: 11.5px; color: var(--steel-2); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; color: #C9D1D8; padding: 8px 10px; border-radius: 6px;
  font-weight: 500; position: relative;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(255,255,255,.09); color: #fff; }
.nav a.on::before { content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 4px; border-radius: 0 3px 3px 0; background: var(--hivis); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .count { margin-left: auto; background: var(--hivis); color: var(--hivis-ink); font-size: 11.5px; font-weight: 700; border-radius: 10px; padding: 0 7px; line-height: 19px; }
.nav .count--quiet { background: rgba(255,255,255,.14); color: #fff; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot a { color: var(--steel-2); }
.wa-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 8px; border-radius: 12px; margin: 8px 0; }
.wa-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.wa-pill--live { background: rgba(10,172,35,.16); color: #5fd46f; }
.wa-pill--dry  { background: rgba(255,194,26,.14); color: var(--hivis); }

.main { min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 26px 32px 18px; flex-wrap: wrap; }
.topbar p { margin: 4px 0 0; color: var(--steel); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.content { padding: 0 32px 48px; }
.btn.menu-btn { display: none; margin-bottom: 8px; }
.panel-head > a { white-space: nowrap; }

/* ── Panels & grids ───────────────────────────────────────────────────── */
.panel { background: var(--panel); border-radius: var(--r-md); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 18px 6px; }
.panel-head p { margin: 2px 0 0; font-size: 13px; color: var(--steel); }
.panel-body { padding: 8px 18px 18px; }
.panel-flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt { margin-top: 16px; }

/* ── Figure strip (top of dashboard) ──────────────────────────────────── */
.figures { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); }
.figure { padding: 16px 18px 18px; border-left: 1px solid var(--rule-soft); }
.figure:first-child { border-left: 0; }
.figure-label { font-size: 13px; color: var(--steel); }
.figure-value { font-size: 30px; font-weight: 750; font-variation-settings: 'wdth' 112; letter-spacing: -.02em; line-height: 1.1; margin-top: 6px; }
.figure-sub { font-size: 12.5px; margin-top: 4px; color: var(--steel); }
.figure--alert .figure-value { color: var(--bad); }
.delta-up { color: var(--bad); } .delta-down { color: var(--good); }

/* ── Buttons & forms ──────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13.5px;
  border: 1px solid var(--rule); background: var(--panel); color: var(--graphite); padding: 7px 13px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--steel-2); text-decoration: none; }
.btn--primary { background: var(--hivis); border-color: #E6AC00; color: var(--hivis-ink); }
.btn--primary:hover { background: #FFCB3D; border-color: #C99600; }
.btn--dark { background: var(--graphite); border-color: var(--graphite); color: #fff; }
.btn--good { background: var(--good); border-color: var(--good); color: #fff; }
.btn--bad  { color: var(--bad); border-color: #EBC1C0; }
.btn--bad:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn--sm { padding: 4px 9px; font-size: 12.5px; }
.btn--block { width: 100%; padding: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--graphite); box-shadow: 0 0 0 3px rgba(255,194,26,.45); }
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--graphite-2); }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
label small { display: block; font-weight: 400; margin-top: 4px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
label.check input { margin-top: 3px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 140px; padding: 6px 9px; font-size: 13.5px; }
.seg { display: inline-flex; background: var(--concrete-2); border-radius: 7px; padding: 3px; gap: 2px; }
.seg a { padding: 4px 11px; border-radius: 5px; color: var(--steel); font-size: 13px; font-weight: 600; }
.seg a:hover { text-decoration: none; color: var(--graphite); }
.seg a.on { background: #fff; color: var(--graphite); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: left; font-weight: 600; color: var(--steel); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.t td { padding: 10px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: #FAFBFA; }
.t .num { text-align: right; white-space: nowrap; }
.t a.rowlink { color: var(--graphite); font-weight: 600; }
.ref { font-weight: 700; font-variation-settings: 'wdth' 110; letter-spacing: .01em; }

/* ── Status tags (always icon + label) ────────────────────────────────── */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; background: var(--concrete); color: var(--graphite-2); }
.tag::before { font-size: 11px; }
.tag--good { background: var(--good-bg); color: var(--good); }   .tag--good::before { content: '✓'; }
.tag--warn { background: var(--warn-bg); color: var(--warn); }   .tag--warn::before { content: '◷'; }
.tag--bad  { background: var(--bad-bg);  color: var(--bad); }    .tag--bad::before  { content: '!'; font-weight: 800; }
.tag--info { background: var(--info-bg); color: var(--info); }   .tag--info::before { content: '●'; font-size: 8px; }
.tag--plain::before { content: none; }
.type-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.type-dot--order { background: var(--series-1); }
.type-dot--petty_cash { background: var(--series-2); }
.var-up { color: var(--bad); font-weight: 700; }
.var-ok { color: var(--steel); }
.var-down { color: var(--good); }

/* ── The docket: one purchase waiting for the owner's decision ────────── */
.docket {
  position: relative; background: #fff; border-radius: 6px; padding: 14px 16px 14px 26px; box-shadow: var(--shadow);
  /* perforated tear-off edge */
  background-image: radial-gradient(circle at 0 8px, var(--concrete) 4.5px, transparent 5px);
  background-size: 12px 16px; background-repeat: repeat-y; background-position: 0 0;
}
.docket::after { content: ''; position: absolute; left: 14px; top: 10px; bottom: 10px; border-left: 1.5px dashed var(--rule); }
.panel .docket { box-shadow: none; border: 1px solid var(--rule-soft); }
.panel .docket { background-image: radial-gradient(circle at 0 8px, #fff 4.5px, transparent 5px), linear-gradient(var(--rule-soft), var(--rule-soft)); background-size: 12px 16px, 1px 100%; background-repeat: repeat-y, no-repeat; }
.docket-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.docket-who { font-size: 12.5px; color: var(--steel); margin-top: 2px; }
.docket-stamp {
  font-variation-settings: 'wdth' 125; font-weight: 800; font-size: 22px; line-height: 1; color: var(--bad);
  border: 2px solid currentColor; border-radius: 4px; padding: 3px 7px 4px; transform: rotate(-4deg); white-space: nowrap;
}
.docket-stamp--limit { color: var(--warn); font-size: 14px; padding: 4px 7px; }
.docket-lines { margin: 10px 0 8px; font-size: 13px; }
.pricebar { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; margin: 6px 0; }
.pricebar-name { font-weight: 600; font-size: 13px; }
.pricebar-nums { font-size: 12.5px; color: var(--steel); text-align: right; }
.pricebar-track { grid-column: 1 / -1; position: relative; height: 8px; background: var(--concrete); border-radius: 4px; }
.pricebar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--steel-2); }
.pricebar-fill.over { background: var(--bad); }
.pricebar-ref { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--graphite); border-radius: 1px; }
.docket-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.docket-total { font-size: 18px; font-weight: 750; font-variation-settings: 'wdth' 112; }
.docket-actions { display: flex; gap: 6px; }
.dockets { display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: var(--steel); padding: 28px 16px; }
.empty strong { display: block; color: var(--graphite); font-size: 15px; margin-bottom: 4px; }

/* ── Charts ───────────────────────────────────────────────────────────── */
.chart { position: relative; height: 260px; }
.chart--sm { height: 200px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--steel); flex-wrap: wrap; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--c); }

/* ── Feed ─────────────────────────────────────────────────────────────── */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; padding: 10px 18px; border-top: 1px solid var(--rule-soft); align-items: start; }
.feed li:first-child { border-top: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--concrete-2); color: var(--graphite-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.avatar--bot { background: var(--graphite); color: var(--hivis); }
.feed-body { font-size: 13px; min-width: 0; }
.feed-body .txt { color: var(--graphite-2); white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed-time { font-size: 12px; color: var(--steel-2); white-space: nowrap; }

/* ── Kanban ───────────────────────────────────────────────────────────── */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--concrete-2); border-radius: var(--r-md); padding: 10px; min-height: 200px; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 10px; font-weight: 700; font-size: 13.5px; }
.col-head .n { color: var(--steel); font-weight: 600; }
.col.drop { outline: 2px dashed var(--steel-2); outline-offset: -4px; }
.card { background: #fff; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; border-left: 3px solid transparent; }
.card[draggable=true] { cursor: grab; }
.card.pri-urgent { border-left-color: var(--bad); }
.card.pri-high { border-left-color: var(--series-2); }
.card-title { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.card-meta { display: flex; justify-content: space-between; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--steel); }
.card-meta .late { color: var(--bad); font-weight: 700; }
.card .avatar { width: 24px; height: 24px; font-size: 10.5px; }

/* ── Drawer / modal ───────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(30,39,49,.42); display: none; z-index: 40; }
.overlay.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: #fff; z-index: 41; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.15); }
.drawer.open { transform: none; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--rule-soft); display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--steel); padding: 2px 6px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--rule-soft); }
.timeline li { position: relative; padding: 0 0 14px 12px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: -23px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--steel-2); }
.timeline li.done::before { border-color: var(--good); background: var(--good); }
.timeline li.blocked::before { border-color: var(--bad); }
.timeline .when { color: var(--steel-2); font-size: 12px; }
.timeline img { max-width: 180px; border-radius: 6px; margin-top: 6px; display: block; }
dl.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--steel); }
dl.kv dd { margin: 0; }

/* ── Notices ──────────────────────────────────────────────────────────── */
.notice { padding: 10px 14px; border-radius: 6px; font-size: 13.5px; margin-bottom: 14px; background: var(--info-bg); color: #0F3E78; }
.notice--ok  { background: var(--good-bg); color: #0B5D18; }
.notice--bad { background: var(--bad-bg); color: #8C1F1E; }
.notice--warn{ background: var(--warn-bg); color: #6B4500; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--graphite); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* ── Purchase detail ──────────────────────────────────────────────────── */
.receipt-view { background: var(--concrete); border-radius: 6px; min-height: 240px; display: grid; place-items: center; overflow: hidden; }
.receipt-view img { width: 100%; display: block; }
.receipt-view iframe { width: 100%; height: 520px; border: 0; }
.issue-list { margin: 8px 0 0; padding-left: 18px; color: #8C1F1E; font-size: 13.5px; }
.issue-list li { margin-bottom: 4px; }

/* ── Simulator (phone) ────────────────────────────────────────────────── */
.phone { background: #EFE7DD; border-radius: 14px; display: flex; flex-direction: column; height: 640px; overflow: hidden; border: 8px solid var(--graphite); }
.phone-top { background: #075E54; color: #fff; padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.phone-top select { background: rgba(255,255,255,.12); color: #fff; border: 0; width: auto; padding: 4px 8px; }
.phone-top select option { color: var(--graphite); }
.chat { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.bub { max-width: 82%; padding: 7px 10px 5px; border-radius: 8px; font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px .5px rgba(0,0,0,.13); }
.bub.in  { align-self: flex-end; background: #D9FDD3; }
.bub.out { align-self: flex-start; background: #fff; }
.bub .t { display: block; text-align: right; font-size: 10.5px; color: #667781; margin-top: 2px; }
.bub img { max-width: 220px; border-radius: 6px; display: block; }
.bub-btns { display: flex; flex-direction: column; gap: 1px; margin-top: 6px; border-top: 1px solid #E9EDEF; }
.bub-btns button { border: 0; background: none; color: #027EB5; font: inherit; font-weight: 600; padding: 7px; cursor: pointer; }
.bub-btns button:hover { background: #F5F6F6; }
.composer { display: flex; gap: 6px; padding: 8px; background: #F0F2F5; align-items: center; }
.composer input[type=text] { border-radius: 20px; border: 0; padding: 9px 14px; }
.composer .btn { border-radius: 20px; }
.typing { align-self: flex-start; background: #fff; border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--steel); }

/* ── Auth ─────────────────────────────────────────────────────────────── */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background-color: var(--graphite);
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 28px 28px; }
.auth-card { background: #fff; border-radius: 10px; padding: 30px; width: min(440px, 100%); box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card .muted { margin: 0 0 18px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .figures { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .figure:nth-child(4) { border-left: 0; }
  .figure:nth-child(n+4) { border-top: 1px solid var(--rule-soft); }
  .g-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; width: var(--side); transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .g-main, .g-2, .g-3 { grid-template-columns: 1fr; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .figures { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .figure { border-left: 0 !important; border-top: 1px solid var(--rule-soft); }
  .figure:nth-child(-n+2) { border-top: 0; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
