/* Marzoni AI portal: brand look (colours from marzoni.it; Montserrat stands in for Gotham). */
:root {
  --bg: #F7F2EA;
  --surface: #FFFFFF;
  --surface-soft: #FBF8F3;
  --line: #E6DACB;
  --line-soft: #F1EAE0;
  --ink: #2B1A12;
  --brand: #442316;
  --muted: #7F655C;
  --camel: #D1AE86;
  --cream: #F0E5D3;
  --sand: #D6C8B2;
  --ok: #3F5A2C;     --ok-bg: #EAF1E3;   --ok-line: #C9DBB8;
  --wait: #7A4B00;   --wait-bg: #FBF0DA; --wait-line: #EED6A6;
  --bad: #9B3D1E;    --bad-bg: #F8E6DF;  --bad-line: #EBC3B4;
  --radius: 10px;
  font-family: Montserrat, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.45; }
a { color: var(--brand); }
a:hover { color: var(--muted); }
h1 { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1280px; margin: 0 auto; padding-left: 32px; padding-right: 32px; }
.eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* --- top bar --- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 32px; min-height: 68px; }
.brand { display: flex; align-items: baseline; gap: 12px; text-decoration: none; color: var(--brand); }
.wordmark { font-weight: 600; font-size: 18px; letter-spacing: 0.32em; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.mainnav { display: flex; flex-wrap: wrap; gap: 0 28px; flex: 1; }
.mainnav a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--muted);
             font-weight: 500; padding: 22px 0 20px; border-bottom: 2px solid transparent; }
.mainnav a:hover { color: var(--brand); }
.mainnav a[aria-current="page"] { color: var(--brand); font-weight: 600; border-bottom-color: var(--camel); }
.count { background: var(--bad); color: #FFFFFF; border-radius: 999px; font-size: 12px; font-weight: 600; padding: 2px 8px; }
.logout { display: flex; align-items: center; gap: 14px; margin: 0; }
.logout span { color: var(--muted); font-size: 14px; }

/* --- buttons --- */
button { font: inherit; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 14px;
       font-weight: 600; text-decoration: none; border-radius: 6px; padding: 0 16px; min-height: 40px;
       border: 1px solid var(--sand); background: var(--surface); color: var(--brand); white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #FFFFFF; min-height: 44px; padding: 0 18px; }
.btn-primary:hover { background: #2B1A12; color: #FFFFFF; }
.btn-soft { background: var(--cream); border-color: #E2D2BD; }
.btn-plain { font-weight: 400; }
.btn svg { flex: none; }

/* --- layout pieces --- */
.main { padding-top: 28px; padding-bottom: 64px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head > div { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 8px; }
.crumbs a { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
             padding: 18px 20px; border-bottom: 1px solid #EFE6DA; }
.card-foot { padding: 14px 20px; border-top: 1px solid #EFE6DA; font-size: 13px; color: var(--muted); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* --- chips --- */
.chip { display: inline-block; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600;
        white-space: nowrap; border: 1px solid var(--line); background: var(--surface); }
.chip-complete { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.chip-waiting { background: var(--wait-bg); color: var(--wait); border-color: var(--wait-line); }
.chip-review { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }

/* --- stat tiles --- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- document cards --- */
.docs { padding: 8px 20px; }
.docs h2 { margin: 12px 0 4px; }
.doc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 8px 0 14px; }
.doc { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid #EFE6DA;
       border-radius: 8px; text-decoration: none; color: var(--ink); min-width: 0; }
a.doc:hover { border-color: var(--sand); color: var(--ink); }
.doc-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.doc-kind { font-weight: 600; font-size: 14px; }
.doc-file { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-missing { border-style: dashed; border-color: #C9BBAA; color: var(--muted); }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* --- warnings --- */
.warnings { background: #FFF8F0; border: 1px solid var(--wait-line); border-radius: var(--radius); padding: 16px 20px; }
.warnings h2 { font-size: 16px; margin-bottom: 6px; }
.warnings ul, .reasons { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.55; }
.warnings p { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* --- tables --- */
.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
.grid th { text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
           font-weight: 600; padding: 12px 10px; white-space: nowrap; background: var(--surface-soft); }
.grid td { padding: 14px 10px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.grid th:first-child, .grid td:first-child { padding-left: 20px; }
.grid th:last-child, .grid td:last-child { padding-right: 20px; }
.grid .right { text-align: right; }
.grid form { margin: 0; }
.pieces { min-width: 1180px; }
.pieces td { padding: 6px 4px; white-space: nowrap; }
.pieces td.row-actions { padding-right: 12px; text-align: right; }
.list-table { min-width: 900px; }
.list-table a.strong { font-weight: 600; text-decoration: none; }
.docmarks { display: flex; gap: 6px; }
.docmark { width: 26px; height: 26px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
           font-size: 12px; font-weight: 700; background: var(--cream); color: var(--brand); }
.docmark.missing { background: var(--surface); color: #8C7E74; border: 1px dashed #C9BBAA; }

/* --- copy buttons --- */
.copy { font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--surface);
        border: 1px solid transparent; border-radius: 6px; padding: 7px 8px; min-height: 36px; white-space: nowrap;
        text-align: left; -webkit-tap-highlight-color: transparent; }
.copy:hover, .copy:focus-visible { border-color: var(--sand); background: var(--surface-soft); }
.copy.copied { background: var(--ok-bg); border-color: var(--ok); }
.copy.row { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--brand);
            border-color: var(--sand); padding: 7px 12px; }
.copy.row.copied { color: var(--ok); border-color: var(--ok); }
.copy-icon { display: none; }
.unknown { color: var(--muted); padding: 0 8px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: calc(100vw - 32px);
         display: flex; align-items: center; gap: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
         background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 8px; font-size: 14px;
         box-shadow: 0 8px 24px rgba(43, 26, 18, 0.25); opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; }

/* --- list page: filters and search --- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab { display: inline-flex; align-items: center; font-size: 14px; color: var(--brand); text-decoration: none;
       background: var(--surface); border: 1px solid var(--sand); border-radius: 999px; padding: 0 16px; min-height: 36px; }
.tab:hover { border-color: var(--brand); }
.tab[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: #FFFFFF; font-weight: 600; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--sand);
          border-radius: 8px; padding: 0 6px 0 12px; min-height: 44px; width: 360px; max-width: 100%; margin: 0; }
.search input { border: 0; outline: none; font: inherit; font-size: 14px; flex: 1; min-width: 0; background: transparent; color: var(--ink); }
.search:focus-within { border-color: var(--brand); }

/* --- daily batches (shipments page) --- */
.check-status { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--muted); }
.check-status.check-failed { color: var(--bad); background: var(--bad-bg); border: 1px solid var(--bad-line);
                             border-radius: 8px; padding: 10px 14px; font-weight: 500; }
.batch { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.batch > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center;
                   gap: 6px 14px; padding: 16px 20px; min-height: 56px; }
.batch > summary::-webkit-details-marker { display: none; }
.batch > summary:hover { background: var(--surface-soft); }
.batch > summary:focus-visible { outline: 2px solid var(--camel); outline-offset: -2px; }
.batch[open] > summary { border-bottom: 1px solid #EFE6DA; }
.batch-chevron { color: var(--muted); transition: transform .15s; flex: none; }
.batch[open] .batch-chevron { transform: rotate(90deg); }
.batch-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.batch-date { font-size: 17px; font-weight: 600; }
.batch-meta { font-size: 13px; color: var(--muted); margin-left: auto; }
.batch-review { color: var(--bad); font-weight: 600; }
.chip-current { background: var(--cream); color: var(--brand); border-color: #E2D2BD; }
.batch-note { margin: 0; padding: 12px 20px 0; font-size: 13px; color: var(--muted); }
.batch .empty { padding: 24px 20px; }

/* --- review page --- */
.section-title { margin-top: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.issue { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-start; }
.issue-main { display: flex; gap: 14px; flex: 999 1 560px; min-width: 0; }
.issue-icon { flex: none; width: 40px; height: 40px; border-radius: 8px; background: var(--bad-bg);
              display: flex; align-items: center; justify-content: center; }
.issue-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.issue-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.issue-title a { font-weight: 600; }
.issue-meta { font-size: 13px; color: var(--muted); }
.issue-actions { display: flex; gap: 8px; flex: 1 1 auto; justify-content: flex-end; }
.issue-actions form { margin: 0; }

/* --- forms (login, users) --- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.field input { font: inherit; font-size: 15px; padding: 0 14px; min-height: 48px; border: 1px solid var(--sand);
               border-radius: 8px; background: var(--surface); color: var(--ink); }
.field input:focus { outline: 2px solid var(--camel); outline-offset: 1px; border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.error { color: var(--bad); background: var(--bad-bg); border: 1px solid var(--bad-line); padding: 10px 14px;
         border-radius: 8px; font-size: 14px; }
.form-card { max-width: 420px; display: flex; flex-direction: column; gap: 14px; }

/* --- login --- */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login-brand { flex: 1 1 460px; background: var(--brand); color: var(--bg); padding: 56px 64px; display: flex;
               flex-direction: column; justify-content: space-between; gap: 48px; min-height: 300px; }
.login-brand .wordmark { font-size: 22px; letter-spacing: 0.34em; }
.login-brand h1 { font-size: 34px; line-height: 1.2; max-width: 440px; }
.login-brand p { color: #E2D2BD; line-height: 1.6; max-width: 440px; margin-top: 16px; }
.login-brand small { font-size: 13px; color: var(--camel); }
.login-form-wrap { flex: 1 1 460px; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login-form .btn-primary { min-height: 50px; font-size: 15px; margin-top: 4px; }

/* --- home --- */
.tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tool { display: flex; flex-direction: column; gap: 8px; padding: 22px; text-decoration: none; color: var(--ink); }
a.tool:hover { border-color: var(--sand); color: var(--ink); }
.tool strong { font-size: 17px; }

/* --- phone --- */
@media (max-width: 760px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .topbar-inner { gap: 0 20px; }
  .brand-sub { display: none; }
  .mainnav { order: 3; flex-basis: 100%; gap: 0 20px; }
  .mainnav a { padding: 10px 0 12px; }
  .logout { margin-left: auto; }
  h1 { font-size: 24px; }
  .main { padding-top: 18px; gap: 18px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 22px; }
  .doc-grid, .tools { grid-template-columns: minmax(0, 1fr); }
  .login-brand { padding: 32px 24px; min-height: 0; gap: 24px; }
  .login-brand h1 { font-size: 26px; }
  .search { width: 100%; }

  /* each piece / shipment becomes a card of label : value pairs with large tap targets */
  .grid.pieces, .grid.list-table { min-width: 0; background: transparent; }
  .table-wrap.cards { overflow: visible; }
  .pieces thead, .list-table thead { display: none; }
  .pieces, .pieces tbody, .pieces tr, .pieces td,
  .list-table, .list-table tbody, .list-table tr, .list-table td { display: block; width: 100%; }
  .pieces tr, .list-table tr { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
                               margin: 0 0 14px; padding: 8px 14px 14px; }
  .pieces td, .list-table td { display: flex; align-items: center; gap: 10px; border: 0; white-space: normal;
                               padding: 3px 0 !important; text-align: left !important; }
  .pieces td::before, .list-table td::before { content: attr(data-label); flex: 0 0 104px; font-size: 12px; color: var(--muted); }
  .pieces td.row-actions::before { content: none; }
  .pieces .copy { flex: 1; min-width: 0; min-height: 44px; font-size: 15px; border-color: #EFE6DA; padding: 10px 12px;
                  display: flex; align-items: center; gap: 8px; }
  .pieces .copy .copy-icon { display: block; margin-left: auto; }
  .pieces .copy.row { justify-content: center; margin-top: 8px; min-height: 48px; background: var(--brand);
                      border-color: var(--brand); color: #FFFFFF; }
  .pieces .copy.row.copied { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
  .pieces .copy.row .copy-icon { display: none; }
  .section-card.pieces-card, .list-card { background: transparent; border: 0; }
  /* inside a batch the batch is the card: shipments are separated by a line, not boxed again */
  .batch .list-table tr { border: 0; border-radius: 0; margin: 0; border-top: 1px solid var(--line-soft); }
  .batch .list-table tr:first-child { border-top: 0; }
  .batch-meta { margin-left: 30px; }
  .pieces-card .card-head { padding: 0 0 12px; border: 0; }
  .pieces-card .card-foot { border: 0; padding: 0; }
  .toast { left: 16px; right: 16px; transform: none; bottom: 20px; }
}

/* running number: first column of the pieces table */
.pieces .num { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; padding-right: 8px; }

/* Export to Excel beside Copy all rows */
.page-head > .head-actions { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
.head-actions .btn-soft { min-height: 44px; padding: 0 16px; text-decoration: none; color: var(--brand); }

/* each daily batch: Export to Excel and Copy all rows for all its pieces */
.batch-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.batch-actions .muted { margin-right: auto; font-size: 13px; }
.batch-actions .btn-soft { min-height: 44px; padding: 0 16px; text-decoration: none; color: var(--brand); }
@media (max-width: 760px) {
  .batch-actions { padding: 10px 0; border: 0; }
  .batch-actions .btn { flex: 1 1 auto; }
}

/* Check mailbox now, beside the last-check line */
.check-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.check-row .check-status { flex: 1 1 320px; }
.check-now { margin: 0; }
.check-now .btn { min-height: 40px; padding: 0 14px; color: var(--brand); }
.check-now .btn[disabled] { opacity: .6; cursor: progress; }
.check-status.check-running { color: var(--brand); font-weight: 500; }

/* Delete shipment (administrators) */
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
               border: 1px solid var(--bad-line); border-radius: var(--radius); padding: 16px 20px; background: var(--surface); }
.danger-zone h2 { font-size: 15px; }
.danger-zone p { font-size: 13px; margin-top: 4px; max-width: 640px; }
.danger-zone form { margin: 0; }
.btn-danger { background: var(--surface); border-color: var(--bad-line); color: var(--bad); min-height: 44px; padding: 0 16px; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
