/* Bein: tokens from docs/brand.md. Navy = structure, Azzurro = action, Ciano = movement. */
:root {
  --color-navy: #0D2646;
  --color-blue: #0084FE;
  --color-cyan: #00C7EA;
  --color-blue-light: #00AAF6;
  --color-ink: #1B2430;
  --color-slate: #6B7A90;
  --color-mist: #F3F5F8;
  --color-line: #D9DFE7;
  --color-paper: #FDFDFC;
  --color-success: #1B9E5A;
  --color-warning: #E59A0B;
  --color-danger: #D64545;
  --gradient-brand: linear-gradient(90deg, #00C7EA 0%, #0084FE 100%);

  --font-display: "Poppins", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;
  --font-code: "JetBrains Mono", ui-monospace, monospace;
  --radius: 8px;
  --sidebar: 232px;
  --t: 160ms ease;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/1.5 var(--font-ui);
  color: var(--color-ink);
  background: var(--color-mist);
}
a { color: var(--color-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; border-radius: 4px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.code { font-family: var(--font-code); font-size: 12.5px; }
.muted { color: var(--color-slate); }
.small { font-size: 12px; }
.icon { flex: none; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--color-navy);
  color: rgba(255, 255, 255, .78);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand-tile {
  background: var(--color-paper);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
}
.brand-tile img { display: block; width: 132px; height: auto; }
.nav-title { font-size: 12px; color: rgba(255, 255, 255, .5); padding: 0 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  color: inherit; text-decoration: none;
  transition: background var(--t), color var(--t);
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a[aria-current="page"] { background: rgba(0, 132, 254, .18); color: #fff; box-shadow: inset 3px 0 0 var(--color-blue); }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding: 12px; font-size: 13px; }
.sidebar-foot form { margin: 0; }
.sidebar-foot button {
  background: none; border: 0; color: rgba(255, 255, 255, .7); padding: 6px 0; cursor: pointer;
  display: flex; align-items: center; gap: 8px; font: inherit;
}
.sidebar-foot button:hover { color: #fff; }

.main { min-width: 0; padding: 28px 36px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--color-slate); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.crumbs a { color: var(--color-slate); }
h1, h2, h3 { font-family: var(--font-display); color: var(--color-navy); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 600; line-height: 1.25; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.lead { color: var(--color-slate); margin: 6px 0 0; max-width: 70ch; }

/* ------------------------------------------------------------ cards */
.card { background: var(--color-paper); border: 1px solid var(--color-line); border-radius: var(--radius); }
.card + .card, .stack > * + * { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--color-line); }
.card-body { padding: 20px; }
.empty { padding: 40px 20px; text-align: center; color: var(--color-slate); }
.empty h3 { margin-bottom: 6px; }

/* ------------------------------------------------------------ tables */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  background: var(--color-mist); color: var(--color-slate);
  font-weight: 500; font-size: 12.5px; text-align: left;
  padding: 10px 16px; border-bottom: 1px solid var(--color-line);
}
table.data td { padding: 9px 16px; border-bottom: 1px solid var(--color-line); height: 40px; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #F8F9FB; }
table.data a.row-link { color: var(--color-navy); font-weight: 600; }

/* ------------------------------------------------------------ buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 6px;
  font: 500 14px/1 var(--font-ui); cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; text-decoration: none !important;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.btn-primary { background: var(--color-blue); color: #fff; }
.btn-primary:hover { background: var(--color-blue-light); }
.btn-secondary { background: var(--color-paper); color: var(--color-navy); border-color: var(--color-line); }
.btn-secondary:hover { border-color: var(--color-navy); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-danger-ghost { background: none; color: var(--color-danger); border-color: transparent; }
.btn-danger-ghost:hover { border-color: var(--color-danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn-icon { width: 32px; padding: 0; height: 32px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { font-weight: 500; font-size: 13px; color: var(--color-ink); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .hint { font-size: 12px; color: var(--color-slate); }
input[type="text"], input[type="number"], input[type="password"], input[type="date"], input[type="time"], select, textarea {
  font: 400 14px var(--font-ui); color: var(--color-ink);
  background: #fff; border: 1px solid var(--color-line); border-radius: 6px;
  height: 36px; padding: 0 10px; width: 100%;
  transition: border-color var(--t);
}
textarea { height: auto; padding: 8px 10px; min-height: 72px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #b9c3d0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-blue); box-shadow: 0 0 0 3px rgba(0, 132, 254, .15); }
select.compact, input.compact { height: 32px; font-size: 13px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; align-items: end; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--color-danger); font-size: 12.5px; }

/* drop zone for uploads */
.drop {
  position: relative; display: flex; align-items: center; gap: 14px;
  border: 1.5px dashed var(--color-line); border-radius: var(--radius);
  padding: 16px; background: #fff; cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
.drop:hover, .drop.is-over { border-color: var(--color-blue); background: #F5FAFF; }
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .drop-icon { color: var(--color-slate); }
.drop strong { display: block; color: var(--color-navy); font-weight: 600; }
.drop .file-name { font-size: 12.5px; color: var(--color-slate); word-break: break-all; }
.drop.has-file { border-style: solid; border-color: var(--color-blue); }
.drop.has-file .drop-icon { color: var(--color-blue); }

/* ------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft { background: var(--color-mist); color: var(--color-slate); }
.badge-generated, .badge-running { background: rgba(0, 199, 234, .16); color: var(--color-navy); }
.badge-generated::before, .badge-running::before { background: var(--color-cyan); }
.badge-sent { background: rgba(229, 154, 11, .14); color: #8a5a00; }
.badge-sent::before { background: var(--color-warning); }
.badge-approved { background: rgba(27, 158, 90, .12); color: #11663a; }
.badge-approved::before { background: var(--color-success); }
.badge-rejected, .badge-failed { background: rgba(214, 69, 69, .1); color: #a32b2b; }
.badge-rejected::before, .badge-failed::before { background: var(--color-danger); }

.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 13.5px; }
.notice-warning { background: rgba(229, 154, 11, .1); color: #6d4700; }
.notice-warning .icon { color: var(--color-warning); }
.notice-danger { background: rgba(214, 69, 69, .08); color: #8f2424; }
.notice-danger .icon { color: var(--color-danger); }
.notice-ok { background: rgba(27, 158, 90, .08); color: #11663a; }
.notice-ok .icon { color: var(--color-success); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* ------------------------------------------------------------ approval track (versions of a batch) */
.track { display: flex; align-items: flex-start; padding: 22px 24px 18px; overflow-x: auto; }
.stop { position: relative; flex: 1 1 0; min-width: 120px; text-align: center; color: inherit; text-decoration: none !important; }
.stop::before {                      /* rail to the previous stop */
  content: ""; position: absolute; top: 11px; right: 50%; width: 100%; height: 2px; background: var(--color-line);
}
.stop:first-child::before { display: none; }
.stop.done::before { background: var(--gradient-brand); }
.stop .dot {
  position: relative; z-index: 1; display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--color-paper); border: 2px solid var(--color-line); color: var(--color-slate);
}
.stop.done .dot { border-color: var(--color-blue); background: var(--color-blue); color: #fff; }
.stop.current .dot { border-color: var(--color-cyan); box-shadow: 0 0 0 4px rgba(0, 199, 234, .2); }
.stop.rejected .dot { border-color: var(--color-danger); color: var(--color-danger); }
.stop.approved .dot { border-color: var(--color-success); background: var(--color-success); color: #fff; }
.stop .stop-name { display: block; margin-top: 8px; font: 600 14px var(--font-display); color: var(--color-navy); }
.stop .stop-meta { display: block; font-size: 12px; color: var(--color-slate); }
a.stop:hover .stop-name { color: var(--color-blue); }

/* ------------------------------------------------------------ progress */
.progress { height: 8px; border-radius: 4px; background: var(--color-mist); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--gradient-brand); border-radius: 4px; transition: width .4s ease; }

/* ------------------------------------------------------------ version workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 20px; align-items: start; }
.workspace > * { min-width: 0; }
#mapping { overflow: hidden; }
table.map-table { table-layout: fixed; }
table.map-table th, table.map-table td { padding-left: 12px; padding-right: 12px; }
table.map-table td { overflow: hidden; }
.ph-name { overflow: hidden; text-overflow: ellipsis; }
.ph-name { font-family: var(--font-code); font-size: 12.5px; color: var(--color-navy); white-space: nowrap; }
.ph-kind { font-size: 11.5px; color: var(--color-slate); }
.map-cell { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 6px; }
.sample { font-size: 12.5px; color: var(--color-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample.is-empty { color: var(--color-slate); font-style: italic; }
tr.is-missing td:first-child { box-shadow: inset 3px 0 0 var(--color-danger); }

.preview-pane { position: sticky; top: 20px; }
.recnav { display: flex; align-items: center; gap: 8px; }
.recnav input { width: 84px; text-align: center; }
.sheet-stage { background: #E8ECF1; padding: 18px; border-radius: 0 0 var(--radius) var(--radius); max-height: calc(100vh - 210px); overflow-y: auto; }
.sheet {                              /* the letter page, with the folded corner of the logo */
  position: relative; background: #fff; margin: 0 auto 14px; max-width: 520px;
  box-shadow: 0 1px 2px rgba(13, 38, 70, .12), 0 4px 14px rgba(13, 38, 70, .06);
}
.sheet img { display: block; width: 100%; height: auto; }
.sheet::after {
  content: ""; position: absolute; top: 0; right: 0; width: 22px; height: 22px;
  background: linear-gradient(225deg, #E8ECF1 50%, #dfe4ea 50%, #f4f6f9 100%);
}
.sheet-label { text-align: center; font-size: 12px; color: var(--color-slate); margin: -6px 0 12px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(0, 132, 254, .25); border-top-color: var(--color-blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stat-row { display: flex; gap: 32px; flex-wrap: wrap; }
.stat strong { display: block; font: 600 20px var(--font-display); color: var(--color-navy); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--color-slate); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--color-mist); }
.login-card { width: 100%; max-width: 380px; }
.login-card .card-body { padding: 28px; }
.login-card .brand-strip { height: 4px; background: var(--gradient-brand); border-radius: var(--radius) var(--radius) 0 0; }
.messages { list-style: none; padding: 0; margin: 0 0 20px; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px; }
  .brand-tile { margin: 0; padding: 8px 10px; }
  .brand-tile img { width: 96px; }
  .nav-title, .sidebar-foot .who { display: none; }
  .nav { display: flex; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .main { padding: 20px 16px 48px; }
  .split { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------ daily letters, tracking pool */
.stat strong.is-low { color: var(--color-danger); }
tr.is-excluded td { color: var(--color-slate); text-decoration: line-through; }
tr.is-excluded td.keep { text-decoration: none; }
tr.has-warning td:first-child { box-shadow: inset 3px 0 0 var(--color-warning); }
tr.has-problem td:first-child { box-shadow: inset 3px 0 0 var(--color-danger); }
.warn-list { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; color: #6d4700; }
.warn-list li.problem { color: #a32b2b; }
.edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.edit-grid input { width: 100%; }

/* ------------------------------------------------------------ mailing requests */
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 14px; height: 36px; }
.check-list { max-height: 320px; overflow: auto; border: 1px solid var(--color-line); border-radius: 6px; padding: 8px 12px; background: #fff; }
.check-list label { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; font-weight: 400; font-size: 14px; }
.check-list label.is-linked { padding-left: 24px; color: var(--color-slate); }
.todo-list { margin: 6px 0 0; padding-left: 18px; }
input[type="file"] { font: 400 14px var(--font-ui); }
[hidden] { display: none !important; }
table.plan-rows td { vertical-align: top; }
table.plan-rows .nowrap { white-space: nowrap; }
table.plan-rows .wide { min-width: 200px; }

/* list of buildings to tick (logins of a firm): tall, scrolling, two columns on wide screens */
.condo-picker { max-height: 420px; overflow-y: auto; border: 1px solid var(--color-line); border-radius: 8px; padding: 8px 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.condo-picker .check { margin: 0; }

/* "Indietro" above the crumbs of every page (Sergio, 2026-11-16) */
.back-link { margin-bottom: 10px; }
