/* ==========================================================================
   Client portal — resources/views/client/*
   Same tokens as the website (assets/web/css/web.css), quieter: the portal is a tool.
   ========================================================================== */

:root {
  --board:     #F5F6F4;
  --paper:     #FFFFFF;
  --graphite:  #212D36;
  --steel:     #5B6A75;
  --rule:      #D5DBDF;
  --press:     #1D4E89;
  --press-dk:  #163C6A;
  --press-lt:  #E4ECF5;
  --kraft:     #A8773D;
  --danger:    #B42318;
  --danger-lt: #FDECEA;
  --success:   #18794E;

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 4px;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--board); color: var(--graphite);
  font-family: var(--font); font-size: 1rem; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--press); }
:focus-visible { outline: 3px solid var(--press); outline-offset: 2px; border-radius: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--steel); }

/* ---------- form controls ---------- */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .4rem; }
.control {
  display: flex; align-items: stretch;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
}
.control:focus-within { border-color: var(--press); box-shadow: 0 0 0 3px var(--press-lt); }
.control > i { display: grid; place-items: center; width: 44px; color: var(--steel); }
.control input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  min-height: 46px; padding: 0 .85rem 0 0;
  font: 400 1rem var(--font); color: var(--graphite);
}
.control input:focus { outline: none; }
.control .control-btn { border: 0; background: transparent; width: 44px; color: var(--steel); cursor: pointer; font-size: 1.05rem; }
.control .control-btn:hover { color: var(--press); }
.field.has-error .control { border-color: var(--danger); }
.field .error { display: block; color: var(--danger); font-size: .88rem; margin-top: .35rem; }
.field .error:empty { display: none; }

.check { display: flex; align-items: center; gap: .55rem; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--press); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: 0 1.25rem; border-radius: var(--radius); border: 2px solid transparent;
  font: 600 1rem/1 var(--font); text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn-press { background: var(--press); color: #fff; }
.btn-press:hover { background: var(--press-dk); color: #fff; }
.btn-block { width: 100%; }

.alert { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1.25rem; display: flex; gap: .6rem; align-items: flex-start; }
.alert-danger { background: var(--danger-lt); color: var(--danger); }
.alert-success { background: #E7F5EE; color: var(--success); }

/* ---------- sign-in page ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side {
  background: var(--graphite); color: #E6EBEE;
  padding: clamp(2rem, 5vw, 3.5rem);
  display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  position: relative; overflow: hidden;
}
.auth-side .brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; font-weight: 800; font-variation-settings: "wdth" 78; font-size: 1.2rem; }
.auth-side .brand img { max-height: 42px; max-width: 200px; object-fit: contain; background: #fff; border-radius: var(--radius); padding: 4px 8px; }
.brand-mark { width: 38px; height: 38px; border-radius: var(--radius); background: #fff; color: var(--graphite); display: grid; place-items: center; font-weight: 800; font-variation-settings: "wdth" 72; }
.auth-side h2 { font-size: clamp(2rem, 3.6vw, 2.9rem); font-weight: 800; font-variation-settings: "wdth" 72; line-height: 1.04; margin: 0; color: #fff; max-width: 13em; }
.auth-side p { color: #B9C4CC; max-width: 30em; margin: 1rem 0 0; }
.auth-side .back { color: #B9C4CC; text-decoration: none; display: inline-flex; gap: .4rem; align-items: center; }
.auth-side .back:hover { color: #fff; }
/* reel end, the website's motif, sitting behind the text */
.auth-side::after {
  content: ""; position: absolute; right: -18%; bottom: -22%;
  width: 70%; aspect-ratio: 1; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 9%, rgba(255,255,255,.08) 9% 11%, transparent 11%),
    repeating-radial-gradient(circle, rgba(255,255,255,.07) 0 2px, transparent 2px 7px);
  pointer-events: none;
}

.auth-main { display: grid; place-items: center; padding: clamp(2rem, 5vw, 3rem) clamp(16px, 4vw, 40px); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.9rem; font-weight: 800; font-variation-settings: "wdth" 78; margin: 0 0 .4rem; }
.auth-card .intro { color: var(--steel); margin: 0 0 1.75rem; }
.auth-card .help { color: var(--steel); font-size: .92rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { min-height: auto; }
  .auth-side .pitch { display: none; }
}

/* ---------- portal shell ---------- */
.topbar { background: var(--paper); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 20; }
.topbar .inner { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); min-height: 64px; display: flex; align-items: center; gap: 1.5rem; }
.topbar .brand { display: flex; align-items: center; gap: .6rem; color: var(--graphite); text-decoration: none; font-weight: 800; font-variation-settings: "wdth" 78; }
.topbar .brand img { max-height: 36px; max-width: 170px; object-fit: contain; }
.topbar .brand .brand-mark { background: var(--graphite); color: #fff; width: 34px; height: 34px; }
.topnav { display: flex; gap: .25rem; }
.topnav a { color: var(--steel); text-decoration: none; font-weight: 500; padding: .5rem .8rem; border-radius: var(--radius); }
.topnav a:hover { color: var(--graphite); background: var(--board); }
.topnav a.active { color: var(--press); background: var(--press-lt); }

.account { margin-left: auto; position: relative; }
.account-btn { display: flex; align-items: center; gap: .6rem; border: 0; background: transparent; cursor: pointer; padding: .3rem; border-radius: var(--radius); font: inherit; color: inherit; text-align: left; }
.account-btn:hover { background: var(--board); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--press-lt); color: var(--press); display: grid; place-items: center; font-weight: 700; font-size: .85rem; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-btn strong { display: block; line-height: 1.2; }
.account-btn small { color: var(--steel); }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(33, 45, 54, .12); padding: .35rem; display: none;
}
.account.is-open .account-menu { display: block; }
.account-menu a { display: flex; gap: .55rem; align-items: center; padding: .6rem .75rem; border-radius: var(--radius); color: var(--graphite); text-decoration: none; }
.account-menu a:hover { background: var(--board); }
.account-menu a.danger { color: var(--danger); }
@media (max-width: 640px) { .account-btn .who { display: none; } .topnav { display: none; } }

.page { max-width: 1180px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 2.5rem) clamp(16px, 4vw, 32px) 3rem; }
.page-head { margin-bottom: 1.75rem; }
.page-head h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 800; font-variation-settings: "wdth" 78; margin: 0; line-height: 1.1; }
.page-head p { color: var(--steel); margin: .4rem 0 0; }

.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); }
.panel-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule); font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.panel-body { padding: 1.25rem; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem 1.5rem; margin: 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--steel); font-size: .88rem; margin-bottom: .2rem; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .facts { grid-template-columns: 1fr 1fr; } }

.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; gap: .75rem; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.people li:first-child { padding-top: 0; }
.people li:last-child { border-bottom: 0; padding-bottom: 0; }
.people strong { display: block; }
.people small { color: var(--steel); overflow-wrap: anywhere; }

.empty { color: var(--steel); text-align: center; padding: 1.5rem 1rem; }
.empty i { font-size: 1.6rem; display: block; margin-bottom: .4rem; }

.foot { max-width: 1180px; margin: 0 auto; padding: 1.25rem clamp(16px, 4vw, 32px); color: var(--steel); font-size: .9rem; border-top: 1px solid var(--rule); }

/* flash message (client.js) */
.flash {
  position: fixed; right: 16px; top: 16px; z-index: 100; max-width: min(380px, calc(100vw - 32px));
  padding: .8rem 1rem; border-radius: var(--radius); color: #fff; background: var(--graphite);
  box-shadow: 0 8px 24px rgba(33, 45, 54, .2); display: flex; gap: .6rem; align-items: flex-start;
  transition: opacity .25s, transform .25s;
}
.flash.success { background: var(--success); }
.flash.error { background: var(--danger); }
.flash.is-hiding { opacity: 0; transform: translateY(-6px); }
@media (prefers-reduced-motion: reduce) { .flash { transition: none; } }

/* ==========================================================================
   Stock, booking, orders, job cards
   ========================================================================== */
.btn-sm { min-height: 36px; padding: 0 .85rem; font-size: .92rem; }
.btn-line { background: var(--paper); border-color: var(--rule); color: var(--graphite); }
.btn-line:hover { border-color: var(--press); color: var(--press); }
.btn-danger-line { background: var(--paper); border-color: #F3C7C2; color: var(--danger); }
.btn-danger-line:hover { background: var(--danger-lt); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.page-head.with-actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.tile { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.15rem; text-decoration: none; color: inherit; display: block; }
a.tile:hover { border-color: var(--press); }
.tile strong { display: block; font-size: 1.9rem; font-weight: 800; font-variation-settings: "wdth" 80; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { color: var(--steel); font-size: .9rem; }
.tile.accent { border-left: 4px solid var(--press); }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* status pill */
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; background: var(--board); color: var(--steel); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.press { background: var(--press-lt); color: var(--press); }
.pill.success { background: #E7F5EE; color: var(--success); }
.pill.danger { background: var(--danger-lt); color: var(--danger); }
.pill.warn { background: #FEF3E2; color: #9A5B13; }
.pill.info { background: #E6F4F7; color: #0E6A7D; }

/* tables */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .94rem; }
table.list th { text-align: left; font-weight: 600; color: var(--steel); font-size: .82rem; padding: .65rem .75rem; border-bottom: 1px solid var(--rule); white-space: nowrap; background: #FAFBFA; }
table.list td { padding: .7rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.r, table.list th.r { text-align: right; }
table.list tbody tr.picked { background: var(--press-lt); }
table.list a { text-decoration: none; font-weight: 600; }
table.list small { color: var(--steel); display: block; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; }

/* filters */
.filters { display: grid; grid-template-columns: 1.4fr repeat(5, minmax(0, 1fr)); gap: .6rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule); align-items: end; }
.filters label { font-size: .8rem; color: var(--steel); display: block; margin-bottom: .2rem; }
.inp, select.inp { width: 100%; min-height: 40px; border: 1px solid var(--rule); border-radius: var(--radius); padding: 0 .65rem; font: 400 .95rem var(--font); color: var(--graphite); background: var(--paper); }
.inp:focus { outline: none; border-color: var(--press); box-shadow: 0 0 0 3px var(--press-lt); }
textarea.inp { padding: .55rem .65rem; min-height: 72px; resize: vertical; }
@media (max-width: 1000px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .filters { grid-template-columns: 1fr 1fr; } }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .45rem .8rem; border-radius: 999px; text-decoration: none; color: var(--steel); background: var(--paper); border: 1px solid var(--rule); font-weight: 500; font-size: .92rem; }
.tabs a.active { background: var(--graphite); color: #fff; border-color: var(--graphite); }
.tabs a b { font-variant-numeric: tabular-nums; margin-left: .2rem; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1.25rem; border-top: 1px solid var(--rule); color: var(--steel); font-size: .92rem; flex-wrap: wrap; }
.pager .btns { display: flex; gap: .4rem; }
nav[role="navigation"] { padding: .85rem 1.25rem; border-top: 1px solid var(--rule); }

/* booking: stock list + basket */
.book { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.25rem; align-items: start; }
.basket { position: sticky; top: 80px; }
.basket .panel-body { max-height: calc(100vh - 260px); overflow: auto; padding: 0; }
.basket-empty { padding: 1.5rem 1.25rem; color: var(--steel); text-align: center; }
.line { padding: .9rem 1.1rem; border-bottom: 1px solid var(--rule); }
.line-top { display: flex; justify-content: space-between; gap: .5rem; align-items: start; }
.line-top b { display: block; }
.line-top small { color: var(--steel); }
.line-x { border: 0; background: none; color: var(--steel); cursor: pointer; font-size: 1.1rem; padding: 0 .2rem; }
.line-x:hover { color: var(--danger); }
.line-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .45rem; margin-top: .6rem; }
.line-grid label { font-size: .75rem; color: var(--steel); display: block; margin-bottom: .15rem; }
.line-grid .inp { min-height: 34px; font-size: .9rem; padding: 0 .45rem; }
.calc { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; margin-top: .6rem; background: var(--board); border-radius: var(--radius); padding: .45rem .55rem; }
.calc span { font-size: .72rem; color: var(--steel); display: block; }
.calc b { font-size: .92rem; font-variant-numeric: tabular-nums; }
.line .error { color: var(--danger); font-size: .82rem; margin-top: .35rem; }
.basket-foot { padding: 1rem 1.1rem; border-top: 1px solid var(--rule); }
.basket-sum { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: .75rem; font-variant-numeric: tabular-nums; }
.apply-all { display: flex; gap: .4rem; align-items: end; padding: .75rem 1.1rem; background: #FAFBFA; border-bottom: 1px solid var(--rule); }
.apply-all label { font-size: .75rem; color: var(--steel); display: block; }
.apply-all .inp { min-height: 34px; font-size: .9rem; }
@media (max-width: 1000px) { .book { grid-template-columns: 1fr; } .basket { position: static; } .basket .panel-body { max-height: none; } }

/* job card progress: the production line */
.track { display: flex; align-items: flex-start; gap: 0; margin: .25rem 0; overflow-x: auto; padding-bottom: .25rem; }
.track .st { flex: 1 1 0; min-width: 64px; text-align: center; position: relative; font-size: .74rem; color: var(--steel); }
.track .st::before { content: ""; position: absolute; top: 7px; left: -50%; right: 50%; height: 2px; background: var(--rule); }
.track .st:first-child::before { display: none; }
.track .st i { display: block; width: 16px; height: 16px; border-radius: 50%; margin: 0 auto .3rem; background: var(--paper); border: 2px solid var(--rule); position: relative; z-index: 1; }
.track .st.done { color: var(--graphite); }
.track .st.done i { background: var(--success); border-color: var(--success); }
.track .st.done::before, .track .st.now::before { background: var(--success); }
.track .st.now { color: var(--press); font-weight: 700; }
.track .st.now i { border-color: var(--press); background: var(--press); box-shadow: 0 0 0 4px var(--press-lt); }
.track .st small { display: block; font-size: .68rem; color: var(--steel); font-weight: 400; }
.track.compact .st { min-width: 44px; font-size: 0; }
.track.compact .st i { width: 12px; height: 12px; }
.track.compact .st::before { top: 5px; }

.jc-row { padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 1rem; align-items: center; }
.jc-row:last-child { border-bottom: 0; }
.jc-row a.no { font-weight: 700; text-decoration: none; }
.jc-row small { color: var(--steel); display: block; }
@media (max-width: 800px) { .jc-row { grid-template-columns: 1fr; } }

.note-box { border-left: 4px solid var(--rule); background: var(--board); padding: .75rem 1rem; border-radius: var(--radius); margin: 0; }
.note-box.danger { border-color: var(--danger); background: var(--danger-lt); }
.note-box.success { border-color: var(--success); background: #E7F5EE; }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem 1.25rem; margin: 0; }
.kv dt { color: var(--steel); font-size: .82rem; }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .kv { grid-template-columns: 1fr 1fr; } }
.stack { display: grid; gap: 1.25rem; }
.account-menu .only-sm { display: none; }
@media (max-width: 640px) { .account-menu .only-sm { display: flex; } .account-btn .who { display: none; } }
@media (max-width: 1000px) and (min-width: 641px) { .topnav a { padding: .5rem .55rem; font-size: .92rem; } }
