/* Aydins Construction — one stylesheet for the whole app.

   The look comes off a building site: slate ink, a paper-white working
   surface, and hi-vis yellow as the one loud colour — spent on the thing to
   press next and on work in progress. Barlow is the face of road and site
   signage; its semi-condensed cut carries headings and figures. */

:root {
  --ink: #17202b;
  --ink-2: #3c4856;
  --ink-3: #6b7683;
  --paper: #f3f4f2;
  --surface: #ffffff;
  --line: #dfe2e0;
  --line-strong: #c5cac8;
  --hivis: #ffd21f;
  --hivis-deep: #e9b900;
  --hivis-wash: #fff6cf;
  --brick: #b93a26;
  --brick-wash: #fbeae6;
  --moss: #23744f;
  --moss-wash: #e3f2ea;
  --steel: #2f5f96;
  --steel-wash: #e6eef8;

  --radius: 10px;
  --radius-small: 6px;
  --display: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --side: 232px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, ol, ul, figure, fieldset { margin: 0; padding: 0; }
ol, ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; }
img, video { max-width: 100%; display: block; }
body { overflow-x: clip; }
.main, .gate__card { overflow-wrap: break-word; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--steel); outline-offset: 2px; border-radius: 4px; }

.icon { width: 1.15em; height: 1.15em; flex: none; }
.muted { color: var(--ink-3); font-size: 0.92rem; }
.late { color: var(--brick); font-weight: 600; }
.ref { font-family: var(--display); font-weight: 600; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.note { margin: 0 0 1rem; color: var(--ink-2); }
.note a, .muted a, .head__sub a, .panel__aside a, .prose a { color: var(--steel); text-underline-offset: 3px; }
code {
  font: 500 0.86em ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 0.1em 0.35em;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ shell */

.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.25rem 0.75rem 1rem;
  background: var(--ink); color: #c9d1da;
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0 0.5rem; text-decoration: none; color: #fff; }
.mark { width: 36px; height: 36px; flex: none; }
.brand__name { font: 700 1.35rem/1 var(--display); letter-spacing: 0.01em; display: flex; flex-direction: column; gap: 3px; }
.brand__name small { font: 500 0.72rem/1 var(--body); color: #8f9bab; letter-spacing: 0.04em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__link {
  display: flex; align-items: center; gap: 0.7rem; width: 100%;
  padding: 0.6rem 0.65rem; border: 0; border-radius: var(--radius-small);
  background: none; color: inherit; text-decoration: none; text-align: left;
  font-weight: 500; cursor: pointer;
}
.nav__link:hover { background: #232f3d; color: #fff; }
.nav__link.is-active { background: #2a3746; color: #fff; box-shadow: inset 3px 0 0 var(--hivis); }
.nav__link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__count {
  font: 600 0.8rem/1 var(--display); padding: 0.25rem 0.45rem; border-radius: 99px;
  background: #33414f; color: #dfe5ec; font-variant-numeric: tabular-nums;
}
.nav__count--loud { background: var(--hivis); color: var(--ink); }
.side__foot { margin-top: auto; border-top: 1px solid #2a3746; padding-top: 0.75rem; display: flex; flex-direction: column; gap: 2px; }

.main { padding: 2rem clamp(1rem, 3.5vw, 2.75rem) 4rem; max-width: 1280px; width: 100%; }

/* ------------------------------------------------------------------- head */

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.head h1 { font: 700 clamp(1.6rem, 3.4vw, 2.15rem)/1.12 var(--display); letter-spacing: -0.005em; text-wrap: balance; }
.head__sub { margin-top: 0.35rem; color: var(--ink-2); }
.head__back {
  display: inline-flex; align-items: center; gap: 0.15rem; margin: 0 0 0.5rem -0.3rem;
  color: var(--ink-3); text-decoration: none; font-weight: 500; font-size: 0.92rem;
}
.head__back:hover { color: var(--ink); }
.head__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 2.6rem; padding: 0.45rem 0.95rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-small);
  background: var(--surface); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn--primary { background: var(--hivis); border-color: var(--hivis-deep); }
.btn--primary:hover { background: #ffdb4a; border-color: var(--hivis-deep); }
.btn--done { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn--done:hover { background: #1c6343; border-color: #1c6343; }
.btn--quiet { border-color: transparent; background: none; color: var(--ink-2); }
.btn--small { min-height: 2rem; padding: 0.2rem 0.65rem; font-size: 0.88rem; }
.btn--block { width: 100%; }
.btn--link { border: 0; background: none; padding: 0; min-height: 0; color: var(--steel); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.btn--danger { color: var(--brick); }
form.inline { display: inline-flex; }

/* ------------------------------------------------------------------ flash */

.flash {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin-bottom: 1.25rem; padding: 0.7rem 0.9rem;
  border-radius: var(--radius-small); background: var(--moss-wash); color: #154a32; font-weight: 500;
}
.flash > span { flex: 1; min-width: 12rem; }
.flash--error { background: var(--brick-wash); color: #7d2416; }
.flash a { color: inherit; }
.flash--notice { background: var(--hivis-wash); color: #5c4700; }
.received { display: flex; flex-direction: column; gap: 0.4rem; }
.received > span { color: var(--ink-3); font-size: 0.86rem; }

/* ----------------------------------------------------------------- layout */

.stack { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.cols { display: grid; gap: 1.25rem; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.cols--wide { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.cols--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel--attention { border-color: var(--hivis-deep); box-shadow: inset 0 3px 0 var(--hivis); }
.panel__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.95rem 1.15rem 0;
}
.panel__head h2 { font: 700 1.2rem/1.2 var(--display); }
.panel__aside { color: var(--ink-3); font-size: 0.9rem; }
.panel__body { padding: 1rem 1.15rem 1.15rem; display: flex; flex-direction: column; gap: 0.9rem; }
.panel__body--flush { padding: 0.5rem 0 0; gap: 0; }
.panel > .panel__body--flush:first-child { padding-top: 0; }

.empty { padding: 2.25rem 1.25rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.empty strong { font: 700 1.15rem var(--display); }
.empty p { color: var(--ink-3); max-width: 44ch; }
.empty .btn { margin-top: 0.4rem; }
.main > .empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ------------------------------------------------------------------ tiles */

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.tile {
  display: flex; flex-direction: column; gap: 0.15rem; padding: 0.95rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  border-top: 4px solid var(--line-strong); text-decoration: none;
}
.tile:hover { border-color: var(--ink-3); border-top-color: currentColor; }
.tile b { font: 700 2.3rem/1 var(--display); font-variant-numeric: tabular-nums; }
.tile span { color: var(--ink-2); font-weight: 500; line-height: 1.25; }
.tile--progress { border-top-color: var(--hivis); }
.tile--action { border-top-color: var(--brick); }
.tile--done { border-top-color: var(--moss); }

.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; }
.figures dt { color: var(--ink-3); font-size: 0.88rem; }
.figures dd { font: 700 1.5rem/1.15 var(--display); font-variant-numeric: tabular-nums; }
.figures dd small { display: block; font: 400 0.85rem var(--body); color: var(--ink-3); }
.figures--row {
  grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1.25rem; padding: 1rem 1.15rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}

/* ------------------------------------------------------------------- rows */

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; flex-wrap: wrap;
  padding: 0.8rem 1.15rem; border-top: 1px solid var(--line); text-decoration: none;
}
.row:first-child { border-top: 0; }
a.row:hover { background: #fafbfa; }
.row__main { flex: 1 1 14rem; min-width: 0; display: flex; flex-direction: column; }
.row__main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__main span { color: var(--ink-3); font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; color: var(--ink-3); font-size: 0.9rem; }
.row.is-done .row__main strong { font-weight: 500; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 0.2rem; }

/* ------------------------------------------------------------------ pills */

.pill {
  display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 99px;
  font: 600 0.82rem/1.3 var(--body); white-space: nowrap;
  background: #eceeed; color: var(--ink-2);
}
.pill--new { background: var(--steel-wash); color: #1f4675; }
.pill--in_progress { background: var(--hivis); color: var(--ink); }
.subhead { font: 600 0.85rem var(--body); color: var(--ink-3); padding: 0.8rem 1.15rem 0.3rem; border-top: 1px solid var(--line); }
.subhead:first-child { border-top: 0; padding-top: 0.5rem; }
.subhead + .row { border-top: 0; }
a.row__main { text-decoration: none; }
a.row__main:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.tile b { overflow-wrap: anywhere; }
.pill--completed, .pill--inv-paid { background: var(--moss-wash); color: #17573b; }
.pill--inv-sent { background: var(--steel-wash); color: #1f4675; }
.pill--inv-draft { background: var(--hivis-wash); color: #6b5200; }

/* ---------------------------------------------------------------- toolbar */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs { display: flex; gap: 0.25rem; overflow-x: auto; max-width: 100%; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.8rem; border-radius: 99px;
  text-decoration: none; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.tab b { font: 600 0.8rem var(--display); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tab:hover { background: #e7e9e7; }
.tab.is-active { background: var(--ink); color: #fff; }
.tab.is-active b { color: var(--hivis); }
.search input {
  width: min(22rem, 100%); min-height: 2.6rem; padding: 0.4rem 0.85rem;
  border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface);
}
.search { flex: 0 1 22rem; }

/* ------------------------------------------------------------------ table */

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 0.7rem 1rem; font: 600 0.85rem var(--body); color: var(--ink-3);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table th.num { text-align: right; }
.table td { padding: 0.75rem 1rem; border-top: 1px solid var(--line); vertical-align: top; }
.table tbody tr:first-child td { border-top: 0; }
.table td small { display: block; color: var(--ink-3); font-size: 0.86rem; }
.table__link { display: flex; flex-direction: column; text-decoration: none; max-width: 34rem; }
.table__link strong { font-weight: 600; }
.table__link span { color: var(--ink-3); font-size: 0.92rem; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.table__link:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.table__tool { text-align: right; white-space: nowrap; }
.table--tight td { padding: 0.5rem 0; }
.table--tight td:first-child { padding-right: 0.75rem; }

/* ------------------------------------------------------------------ forms */

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 1rem; }
.form--single { grid-template-columns: minmax(0, 1fr); }
.form__group { display: contents; }
.form__group legend {
  grid-column: 1 / -1; float: left; width: 100%; padding: 0.6rem 0 0;
  font: 700 1.05rem var(--display); border-top: 1px solid var(--line); margin-top: 0.3rem;
}
.form__group:first-child legend { border-top: 0; padding-top: 0; margin-top: 0; }
.form__actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.6rem 1rem; flex-wrap: wrap; }
.form > small { grid-column: 1 / -1; }
.stack > .field + .btn { margin-top: 0.4rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field > span { font-weight: 600; font-size: 0.92rem; }
.field small { color: var(--ink-3); font-size: 0.86rem; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 2.75rem; padding: 0.5rem 0.7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-small); background: var(--surface);
}
.field textarea { resize: vertical; line-height: 1.45; }
/* Safari draws its own select — ignoring the height, padding and border above —
   unless the native look is switched off; the arrow is then ours to draw. */
.field select {
  -webkit-appearance: none; appearance: none;
  padding-right: 2.4rem; line-height: 1.3; text-overflow: ellipsis; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2317202b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1.1rem;
}
.field input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus {
  outline: 3px solid color-mix(in srgb, var(--steel) 35%, transparent); border-color: var(--steel);
}
.checks { gap: 0.45rem; }
.checks label { display: flex; align-items: center; gap: 0.5rem; }
.checks input { width: 1.1rem; height: 1.1rem; min-height: 0; accent-color: var(--ink); }

.disclose { border-top: 1px solid var(--line); padding-top: 0.75rem; }
.disclose > summary { cursor: pointer; font-weight: 600; color: var(--steel); width: fit-content; }
.disclose[open] > summary { margin-bottom: 0.9rem; }

.drop {
  display: flex; align-items: center; gap: 0.8rem; padding: 1.1rem;
  border: 2px dashed var(--line-strong); border-radius: var(--radius-small); cursor: pointer; color: var(--ink-2);
}
.drop:hover, .drop:focus-within { border-color: var(--ink); background: var(--hivis-wash); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop .icon { width: 1.8rem; height: 1.8rem; }
.drop.is-busy { opacity: 0.6; pointer-events: none; }

/* -------------------------------------------------------------- job page */

.action { display: flex; flex-direction: column; gap: 0.9rem; }
.action__set { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.action__btn {
  min-height: 3.4rem; padding: 0.5rem 0.6rem; border: 2px solid var(--line-strong); border-radius: var(--radius-small);
  background: var(--surface); font: 600 1.02rem/1.15 var(--display); cursor: pointer;
}
.action__btn:hover { border-color: var(--ink); }
.action__btn.is-on { background: var(--hivis); border-color: var(--ink); }
.action__btn--done.is-on { background: var(--moss); border-color: var(--moss); color: #fff; }

.prose { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; }
.prose--source { color: var(--ink-2); font-size: 0.95rem; max-height: 26rem; overflow: auto; }

.facts { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; }
.facts dt { color: var(--ink-3); font-size: 0.86rem; }
.facts dd { font-weight: 600; }

.docs { display: flex; flex-direction: column; gap: 0.4rem; }
.docs li { display: flex; align-items: center; gap: 0.6rem; }
.docs a { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--steel); font-weight: 500; overflow-wrap: anywhere; }
.docs small { color: var(--ink-3); }
.pdf { width: 100%; height: 30rem; border: 1px solid var(--line); border-radius: var(--radius-small); }

.keybox {
  display: flex; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap; padding: 0.9rem 1rem;
  background: var(--ink); color: #fff; border-radius: var(--radius-small);
}
.keybox span { color: #a9b4c1; font-weight: 500; }
.keybox output { font: 700 2rem/1 var(--display); letter-spacing: 0.14em; color: var(--hivis); flex: 1; }
.contact { display: flex; align-items: center; gap: 0.6rem 1rem; flex-wrap: wrap; }
.contact > div { flex: 1 1 10rem; display: flex; flex-direction: column; }
.contact > div span { color: var(--ink-3); font-size: 0.86rem; }

.evidence { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.evidence__col { display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.evidence__head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 2px solid var(--ink); padding-bottom: 0.3rem; }
.evidence__head h3 { font: 700 1.1rem var(--display); }
.evidence__head span { color: var(--ink-3); font-size: 0.88rem; }
.media { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 0.4rem; }
.media__item { position: relative; aspect-ratio: 1; border-radius: var(--radius-small); overflow: hidden; background: var(--paper); }
.media__item a { display: block; width: 100%; height: 100%; }
.media__item img, .media__item video { width: 100%; height: 100%; object-fit: cover; }
.media__play {
  position: absolute; inset: 0; margin: auto; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: rgba(23, 32, 43, 0.78); pointer-events: none;
}
.media__play::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0; translate: 2px 0;
  border: 0.42rem solid transparent; border-left: 0.7rem solid #fff; border-right: 0;
}
.media__delete {
  position: absolute; top: 4px; right: 4px; width: 1.6rem; height: 1.6rem; border: 0; border-radius: 50%;
  background: rgba(23, 32, 43, 0.78); color: #fff; font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.uploader__progress { height: 1.6rem; border-radius: 99px; background: var(--paper); position: relative; overflow: hidden; margin-top: 0.5rem; }
.uploader__progress div { height: 100%; width: 0; background: var(--hivis); transition: width 0.2s; }
.uploader__progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.82rem; font-weight: 600; }
.uploader.is-uploading .btn { opacity: 0.5; pointer-events: none; }

.price { display: flex; align-items: flex-end; gap: 0.6rem; }
.price .field { flex: 1; }
.sums { display: flex; flex-direction: column; gap: 0.25rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.sums div { display: flex; justify-content: space-between; color: var(--ink-2); }
.sums dd { font-variant-numeric: tabular-nums; }
.sums__total { font: 700 1.25rem var(--display); color: var(--ink) !important; padding-top: 0.25rem; }
.sums__total.is-negative dd { color: var(--brick); }

.invoice-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 1rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-small); text-decoration: none;
}
.invoice-card div { display: flex; flex-direction: column; }
.invoice-card strong { font: 700 1.5rem/1.1 var(--display); }
.paid { display: flex; align-items: flex-end; gap: 0.6rem; }
.paid .field { flex: 1; }

.timeline { display: flex; flex-direction: column; gap: 0.8rem; }
.timeline li { display: flex; flex-direction: column; padding-left: 0.9rem; border-left: 2px solid var(--line-strong); }
.timeline li span, .timeline small { color: var(--ink-3); font-size: 0.88rem; }
.timeline li.is-failed { border-left-color: var(--brick); }
.timeline summary { cursor: pointer; color: var(--steel); font-size: 0.9rem; width: fit-content; }
.timeline--small strong { font-weight: 500; font-size: 0.94rem; }

/* A job's conversation: received on the left rule, sent on the yellow one. */
.thread { display: flex; flex-direction: column; gap: 0.9rem; }
.msg { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius-small); border-left: 4px solid var(--line-strong); min-width: 0; }
.msg--out { border-left-color: var(--hivis); background: #fffdf3; margin-left: clamp(0rem, 4vw, 2rem); }
.msg.is-unread { border-left-color: var(--steel); background: var(--steel-wash); }
.msg.is-failed { border-left-color: var(--brick); }
.msg__head { display: flex; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; }
.msg__head span { color: var(--ink-3); font-size: 0.88rem; }
.msg__subject { font-weight: 500; overflow-wrap: anywhere; }
.msg__subject small { display: block; color: var(--ink-3); font-weight: 400; font-size: 0.88rem; }
.msg summary { cursor: pointer; color: var(--steel); font-size: 0.92rem; width: fit-content; font-weight: 600; }
.msg details[open] > summary { margin-bottom: 0.5rem; }
.msg .reply { border-top: 1px solid var(--line); padding-top: 0.6rem; margin-top: 0.2rem; }
.newmail { display: inline-flex !important; align-items: center; gap: 0.25rem; margin-top: 0.3rem; color: var(--steel) !important; font-weight: 600; }

.steps { display: flex; flex-direction: column; }
.steps li { position: relative; padding: 0 0 0.9rem 1.7rem; display: flex; flex-direction: column; }
.steps li::before {
  content: ""; position: absolute; left: 0; top: 0.25rem; width: 0.95rem; height: 0.95rem; border-radius: 50%;
  border: 2px solid var(--line-strong); background: var(--surface);
}
.steps li::after { content: ""; position: absolute; left: 0.42rem; top: 1.3rem; bottom: 0; width: 2px; background: var(--line); }
.steps li:last-child::after { display: none; }
.steps li.is-done::before { background: var(--moss); border-color: var(--moss); }
.steps span { color: var(--ink-3); font-size: 0.9rem; }

.ok { display: flex; align-items: center; gap: 0.5rem; color: #17573b; font-weight: 500; }
.ok .icon { color: var(--moss); }
.howto { list-style: decimal; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.6rem; }
.howto li { padding-left: 0.2rem; }
.issued {
  display: flex; align-items: center; gap: 0.75rem 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; padding: 1rem 1.15rem;
  background: var(--hivis-wash); border: 1px solid var(--hivis-deep); border-radius: var(--radius);
}
.issued p { flex: 1 1 18rem; }
.issued output { font: 700 1.5rem var(--display); letter-spacing: 0.04em; }

/* ----------------------------------------------------------------- viewer */

.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(13, 18, 25, 0.94); display: grid; place-items: center; padding: 1rem; }
.viewer__stage { max-width: 100%; max-height: 100%; display: grid; place-items: center; }
.viewer__stage img, .viewer__stage video { max-width: 100%; max-height: calc(100vh - 2rem); border-radius: 4px; }
.viewer__close {
  position: absolute; top: 0.75rem; right: 0.75rem; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%;
  background: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; z-index: 1;
}
body.is-viewing { overflow: hidden; }

/* ------------------------------------------------------------------- gate */

body.bare { background: var(--ink); }
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.gate__card {
  width: min(24rem, 100%); padding: 1.75rem; border-radius: 14px; background: var(--surface);
  display: flex; flex-direction: column; gap: 1.1rem;
  box-shadow: 0 0 0 6px rgba(255, 210, 31, 0.16);
}
.gate__brand { display: flex; align-items: center; gap: 0.7rem; }
.gate__brand .brand__name { color: var(--ink); }
.gate__brand .brand__name small { color: var(--ink-3); }
.gate__title { font: 700 1.6rem/1.1 var(--display); }
.gate__text { color: var(--ink-2); }
.gate__error { padding: 0.6rem 0.8rem; border-radius: var(--radius-small); background: var(--brick-wash); color: #7d2416; font-weight: 500; }
.gate .stack { gap: 0.9rem; }

/* ---------------------------------------------------------- invoice sheet */

.sheet-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(0.75rem, 3vw, 2rem); overflow-x: auto; }
.sheet { font: 400 12.5px/1.45 Arial, Helvetica, sans-serif; color: #111; min-width: 34rem; max-width: 46rem; margin: 0 auto; }
.sheet address { font-style: normal; }
.sheet__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1.6rem; }
.sheet__top strong { font-size: 1.45em; color: #333; }
.sheet__top span { font-size: 2.5em; color: #777; letter-spacing: 0.02em; }
.sheet__meta { display: flex; justify-content: space-between; gap: 2rem; }
.sheet__meta dl div { display: grid; grid-template-columns: 6.5em auto; }
.sheet__meta dt { font-weight: 700; }
.sheet__to { margin: 1.4rem 0 1.5rem; }
.sheet__lines { width: 100%; border-collapse: collapse; border: 1.5px solid #111; }
.sheet__lines th { font-weight: 400; padding: 0.55em; border: 1.5px solid #111; text-align: center; }
.sheet__lines td { padding: 0.45em 0.4em; border-left: 1.5px solid #111; height: 2.4em; }
.sheet__lines tbody tr:nth-child(odd) td { background: #d9d9d9; }
.sheet__lines tbody tr:nth-child(even) td.amt { background: #d9d9d9; }
.sheet__lines th:nth-child(1) { width: 55%; }
.sheet .r { text-align: right; }
.sheet__lines td.amt span:last-child { float: right; }
.sheet__foot { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.8rem; }
.sheet__bank { padding-top: 3.4em; }
.sheet__totals { border-collapse: collapse; width: 44.6%; }
.sheet__totals th { font-weight: 400; text-align: right; padding: 0.55em 1.4em 0.55em 0; width: 56%; }
.sheet__totals td { border: 1.5px solid #111; height: 2.5em; padding: 0 0.4em; }
.sheet__totals td.shade { background: #d9d9d9; }
.sheet__totals td.amt span:last-child { float: right; }
.sheet__totals .total th, .sheet__totals .total td { font-weight: 700; }
.sheet > p { margin-top: 0.9em; }
.sheet__thanks { text-align: center; font-weight: 700; margin-top: 1.8em !important; }

body.print-page { background: #fff; padding: 2rem; }
.print-bar { display: flex; gap: 0.6rem; justify-content: center; margin-bottom: 2rem; }

/* ----------------------------------------------------------------- mobile */

@media (max-width: 960px) {
  .cols--wide, .cols--even { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20; height: auto;
    flex-direction: row; gap: 0; overflow: visible;
    padding: 0.3rem calc(0.3rem + env(safe-area-inset-right)) calc(0.3rem + env(safe-area-inset-bottom)) calc(0.3rem + env(safe-area-inset-left));
    border-top: 1px solid #2a3746;
  }
  .brand { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; gap: 0; }
  .nav__link { flex-direction: column; gap: 0.15rem; padding: 0.4rem 0.2rem; font-size: 0.7rem; position: relative; flex: 1; min-width: 0; align-items: center; }
  .nav__link span { flex: none; max-width: 100%; }
  .nav__link.is-active { box-shadow: inset 0 3px 0 var(--hivis); background: none; }
  .nav__link .icon { width: 1.4rem; height: 1.4rem; }
  .nav__count { position: absolute; top: 0.1rem; left: 50%; margin-left: 0.3rem; padding: 0.15rem 0.35rem; font-size: 0.68rem; }
  /* The phone bar carries the daily four; the rest sit behind the account page. */
  .nav__link[href="/clients"], .nav__link[href="/team"], .nav__link[href="/settings"] { display: none; }
  .side__foot { margin: 0; border: 0; padding: 0; flex-direction: row; flex: 0 0 20%; }
  .side__foot form { display: none; }
  .main { padding: 1.1rem calc(0.9rem + env(safe-area-inset-right)) calc(5.5rem + env(safe-area-inset-bottom)) calc(0.9rem + env(safe-area-inset-left)); }

  .form { grid-template-columns: minmax(0, 1fr); }
  .evidence { grid-template-columns: minmax(0, 1fr); }
  /* Three across even on a phone, as three tiles that between them fill the
     whole width — the figure sized to its tile rather than left small. */
  .figures--row {
    grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin-bottom: 0.9rem;
    padding: 0; background: none; border: 0; border-radius: 0;
  }
  .figures--row > div {
    display: flex; flex-direction: column; justify-content: space-between; gap: 0.3rem;
    padding: 0.65rem 0.7rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  }
  .figures--row dt { font-size: 0.78rem; line-height: 1.2; }
  .figures--row dd { font-size: clamp(1.05rem, 5.4vw, 1.5rem); white-space: nowrap; }
  .head__actions { width: 100%; }
  .search, .search input { flex: 1 1 100%; width: 100%; }
  .action__set { grid-template-columns: minmax(0, 1fr); }
  .action__btn { min-height: 3rem; }

  /* Tables become cards, with each column's name as its label. */
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; }
  .table--cards tr { padding: 0.8rem 1rem; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; }
  .table--cards tbody tr:first-child { border-top: 0; }
  .table--cards td { padding: 0; border: 0; text-align: left; }
  .table--cards td:first-child, .table--cards td:nth-child(2):has(.table__link) { grid-column: 1 / -1; }
  .table--cards td[data-label]:not(:has(.table__link))::before { content: attr(data-label); display: block; color: var(--ink-3); font-size: 0.8rem; }
  .table--cards td:empty { display: none; }
  .table--cards .table__tool { grid-column: 1 / -1; }
}

/* Phones: the invoice preview shrinks to fit rather than scrolling sideways. */
@media (max-width: 760px) {
  .sheet-wrap { padding: 0.9rem 0.7rem; }
  .sheet { min-width: 0; font-size: clamp(7.5px, 2.45vw, 12.5px); }
  .sheet__lines th, .sheet__lines td, .sheet__totals td { border-width: 1px; }
  .sheet__lines { border-width: 1px; }
  .sheet__lines td { padding: 0.4em 0.3em; }
  .sheet__meta { gap: 0.75rem; }
  .sheet__top { margin-bottom: 1.1rem; }

  .head { margin-bottom: 1.1rem; }
  .head__actions .btn, .head__actions form.inline, .head__actions form { flex: 1 1 auto; }
  .head__actions form .btn { width: 100%; }
  .panel__head { padding: 0.85rem 0.95rem 0; }
  .panel__body { padding: 0.85rem 0.95rem 1rem; }
  .panel__body--flush { padding: 0.4rem 0 0; }
  .row { padding: 0.75rem 0.95rem; }
  .row__main strong, .row__main span { white-space: normal; }
  .row--static .row__meta { width: 100%; }
  .tile { padding: 0.8rem 0.9rem; }
  .tile b { font-size: 2rem; }
  .keybox output { font-size: 1.7rem; letter-spacing: 0.1em; }
  .contact .btn { flex: 1 1 100%; }
  .media { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .media__delete { width: 2rem; height: 2rem; }
  .form__actions .btn--primary { flex: 1 1 100%; }
  .pdf { height: 70vh; }
  .viewer { padding: 0; }
  .toolbar { gap: 0.6rem; }
  .tabs { margin: 0 -0.9rem; padding: 0 0.9rem 2px; max-width: calc(100% + 1.8rem); }
  .issued output { flex: 1 1 100%; }
  .print-bar { flex-wrap: wrap; }
  body.print-page { padding: 0.75rem; }
}

/* A phone on its side, or a small tablet: keep the bar, give the page two columns back. */
@media (min-width: 620px) and (max-width: 760px) {
  .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form--single { grid-template-columns: minmax(0, 1fr); }
  .evidence { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action__set { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Tablets keep the sidebar, slimmer. */
@media (min-width: 761px) and (max-width: 1100px) {
  :root { --side: 196px; }
  .main { padding: 1.5rem 1.25rem 3rem; }
  .table th, .table td { padding-left: 0.7rem; padding-right: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  .print-bar { display: none; }
  body.print-page { padding: 0; }
  .sheet { max-width: none; font-size: 11pt; }
  .sheet__lines tbody tr:nth-child(odd) td, .sheet__lines td.amt, .sheet__totals td.shade { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
