/* ==========================================================================
   Chek In Gat — espace agence (dashboard)
   Same brand language as the public site: ink + signal yellow, cream paper.
   ========================================================================== */
:root {
  --ink: #161616;
  --ink-2: #1f1f1f;
  --ink-3: #2b2b2b;
  --sun: #ffc20e;
  --sun-2: #ffd34d;
  --sun-soft: #fff4cc;
  --sun-deep: #b98a00;
  --bg: #f7f4ec;
  --bg-2: #efeadd;
  --surface: #ffffff;
  --surface-2: #f6f2e8;
  --text: #1a1a1a;
  --muted: #5b574e;
  --line: #e4ddcb;
  --line-strong: #cfc6af;
  --red: #c8102e;
  --red-soft: #fde8eb;
  --green: #17803f;
  --green-soft: #e3f5ea;
  --blue: #1d4ed8;
  --blue-soft: #e5edff;
  --violet: #6d28d9;
  --violet-soft: #efe7ff;
  --orange: #b45309;
  --orange-soft: #fdf0dc;
  --grey-soft: #eeebe3;

  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-ar: "Cairo", sans-serif;
  --r: 14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .05);
  --shadow: 0 2px 6px rgb(0 0 0 / .05), 0 16px 36px -16px rgb(0 0 0 / .18);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --side-w: 256px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 500 15px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.15; letter-spacing: -.015em; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sprite { position: absolute; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 8px; }
[lang="ar"], .ar { font-family: var(--font-ar); }
.mono { font-family: var(--font-mono); font-size: .9em; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 0; border-radius: 11px; font-family: var(--font-display); font-weight: 600; font-size: .9375rem; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s, box-shadow .15s, transform .15s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn--sun { background: var(--sun); color: var(--ink); }
.btn--sun:hover { background: var(--sun-2); }
.btn--ink { background: var(--ink); color: #fff; }
.btn--ink:hover { background: var(--ink-3); }
.btn--ghost { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--surface); color: var(--red); box-shadow: inset 0 0 0 1px #f0b8c1; }
.btn--danger:hover { background: var(--red-soft); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: .875rem; border-radius: 9px; }
.btn--block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text); cursor: pointer; transition: background-color .15s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn--dark { color: #cfcbc2; }
.icon-btn--dark:hover { background: rgb(255 255 255 / .08); color: #fff; }
.icon-btn--danger:hover { background: var(--red-soft); color: var(--red); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .row > label, .label { font-family: var(--font-display); font-size: .8125rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
  font-weight: 500; transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none;
}
.field select, select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23161616' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; cursor: pointer; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgb(255 194 14 / .35); }
.field .hint { font-size: .8125rem; color: var(--muted); }
.field.has-error input, .field.has-error select { border-color: var(--red); }
.err { color: var(--red); font-size: .8125rem; font-weight: 600; }
.req { color: var(--red); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.span-2 { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 40px; height: 24px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background-color .2s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 3px solid var(--sun); outline-offset: 2px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(var(--line) 1px, transparent 1.3px) 0 0 / 22px 22px, var(--bg); }
.login__card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 20px; }
.login__title { font-size: 1.625rem; font-weight: 800; }
.login__lead { color: var(--muted); margin-top: 6px; }
.login__sent { width: 64px; height: 64px; border-radius: 18px; background: var(--sun-soft); color: var(--ink); display: grid; place-items: center; margin-bottom: 8px; }
.login__sent .ico { width: 30px; height: 30px; }
.login__back { font-size: .875rem; color: var(--muted); text-decoration: none; justify-self: center; }
.login__back:hover { color: var(--text); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand--dark { color: var(--ink); }
.brand__mark { width: 40px; height: 40px; }
.brand__word { display: flex; flex-direction: column; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; line-height: 1; letter-spacing: -.02em; }
.brand__word b { color: var(--sun); }
.brand--dark .brand__word b { color: var(--sun-deep); }
.brand__word small { font-size: .6875rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #a9a59b; margin-top: 5px; }
.brand--dark .brand__word small { color: var(--muted); }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40; background: var(--ink); color: #e8e5de;
  display: flex; flex-direction: column; padding: 20px 14px; gap: 22px; transform: translateX(-100%); transition: transform .3s var(--ease);
}
.side.is-open { transform: none; }
.side .brand { padding: 0 8px; }
.side__nav { display: grid; gap: 2px; overflow-y: auto; }
.side__nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: .9375rem; color: #cfcbc2; transition: background-color .15s, color .15s; }
.side__nav a:hover { background: rgb(255 255 255 / .06); color: #fff; }
.side__nav a.is-active { background: var(--sun); color: var(--ink); }
.nav-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--sun); color: var(--ink); font-size: .75rem; font-weight: 800; display: inline-grid; place-items: center; }
.side__nav a.is-active .nav-count { background: var(--ink); color: var(--sun); }
.side__sep { margin: 14px 12px 6px; font-size: .6875rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #77736a; }
.side__foot { margin-top: auto; display: grid; gap: 10px; }
.side__site { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #cfcbc2; text-decoration: none; font-weight: 600; font-size: .875rem; }
.side__site:hover { background: rgb(255 255 255 / .06); color: #fff; }
.side__user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgb(255 255 255 / .05); }
.side__me { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.side__me b { font-size: .875rem; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__me small { font-size: .75rem; color: #8f8b82; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--sun); color: var(--ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; flex: none; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / .4); }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: rgb(247 244 236 / .9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar__title { min-width: 0; flex: 1; }
.topbar__title h1 { font-size: 1.375rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__crumb { font-size: .8125rem; color: var(--muted); font-weight: 600; }
.topbar__crumb a { text-decoration: none; }
.topbar__crumb a:hover { color: var(--text); text-decoration: underline; }
.topbar__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.view { padding: 20px 16px 64px; outline: none; max-width: 1280px; }

@media (min-width: 1024px) {
  .side { transform: none; }
  .scrim { display: none !important; }
  .main { margin-left: var(--side-w); }
  .topbar { padding: 18px 32px; }
  .topbar__burger { display: none; }
  .view { padding: 28px 32px 80px; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar__actions { width: 100%; justify-content: stretch; }
  .topbar__actions .btn { flex: 1; }
}

/* ---------- Cards, sections ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.card__head h2 { font-size: 1.125rem; font-weight: 700; }
.card__head p { color: var(--muted); font-size: .875rem; }
.layout-2 { display: grid; gap: 16px; }
.layout-2 > * { min-width: 0; }
@media (min-width: 1100px) { .layout-2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; } }
.section-title { font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 4px 0 10px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ico { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--line-strong); }
.empty h3 { color: var(--text); font-size: 1.0625rem; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* Stat tiles */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; display: grid; gap: 6px; text-decoration: none; transition: border-color .15s, transform .2s var(--ease); }
a.stat:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.stat__label { display: flex; align-items: center; gap: 8px; font-size: .8125rem; font-weight: 600; color: var(--muted); }
.stat__label .ico { width: 16px; height: 16px; }
.stat__value { font-family: var(--font-display); font-size: clamp(1.25rem, 4.6vw, 1.75rem); white-space: nowrap; font-weight: 800; letter-spacing: -.02em; }
.stat__sub { font-size: .8125rem; color: var(--muted); }
.stat--sun { background: var(--sun); border-color: var(--sun); }
.stat--sun .stat__label, .stat--sun .stat__sub { color: #4a3800; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .8125rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .count { font-family: var(--font-mono); font-size: .75rem; opacity: .7; }
.tabs { display: inline-flex; padding: 4px; background: var(--bg-2); border-radius: 12px; gap: 2px; margin-bottom: 16px; }
.tabs button { min-height: 36px; padding: 0 14px; border: 0; background: transparent; border-radius: 9px; font-weight: 700; font-family: var(--font-display); cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; transition: background-color .12s; }
.table tbody tr[data-href]:hover { background: #fbf8f0; }
.table .t-main { font-weight: 700; }
.table .t-sub { font-size: .8125rem; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 760px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 3px 0; }
  .table td[data-label]::before { content: attr(data-label) " · "; color: var(--muted); font-size: .75rem; font-weight: 700; }
  .table .num { text-align: left; }
  .table .hide-sm { display: none; }
}

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700; white-space: nowrap; background: var(--grey-soft); color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--blue { background: var(--blue-soft); color: var(--blue); }
.badge--sun { background: var(--sun-soft); color: #7a5b00; }
.badge--orange { background: var(--orange-soft); color: var(--orange); }
.badge--violet { background: var(--violet-soft); color: var(--violet); }
.badge--green { background: var(--green-soft); color: var(--green); }
.badge--red { background: var(--red-soft); color: var(--red); }
.badge--ink { background: var(--ink); color: var(--sun); }
.cat { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 700; }
.cat i { width: 10px; height: 10px; border-radius: 3px; background: var(--sun); display: inline-block; }

/* ---------- Detail views ---------- */
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 8px 16px; font-size: .9375rem; }
.kv dt { color: var(--muted); font-weight: 600; font-size: .8125rem; padding-top: 2px; }
.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.status-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.status-steps button { min-height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: .8125rem; cursor: pointer; }
.status-steps button:hover { border-color: var(--line-strong); }
.status-steps button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.timeline { display: grid; gap: 0; position: relative; }
.timeline li { list-style: none; position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 3px var(--surface); z-index: 1; }
.timeline li::after { content: ""; position: absolute; left: 10px; top: 10px; bottom: -6px; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .t-when { font-size: .75rem; color: var(--muted); font-weight: 600; }
.timeline .t-what { font-weight: 600; }
.timeline .t-note { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin-top: 4px; white-space: pre-wrap; }
ul.timeline { margin: 0; padding: 0; }
.files { display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.file__icon { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.file__body { min-width: 0; flex: 1; }
.file__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__meta { font-size: .75rem; color: var(--muted); }
.drop { display: block; border: 2px dashed var(--line-strong); border-radius: 14px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background-color .15s; }
.drop:hover, .drop.is-over { border-color: var(--ink); background: var(--sun-soft); color: var(--text); }
.drop .ico { width: 24px; height: 24px; margin: 0 auto 6px; }

/* ---------- Billing editor ---------- */
.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-size: .75rem; font-weight: 700; color: var(--muted); padding: 0 6px 8px; text-transform: uppercase; letter-spacing: .05em; }
.lines td { padding: 4px 6px; vertical-align: top; }
.lines .input { min-height: 40px; }
.lines .c-qty { width: 90px; }
.lines .c-price { width: 150px; }
.lines .c-tva { width: 100px; }
.lines .c-total { width: 140px; text-align: right; font-weight: 700; padding-top: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .c-del { width: 44px; }
@media (max-width: 760px) {
  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100% !important; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .lines td.c-desc { grid-column: 1 / -1; }
  .lines td.c-total { grid-column: 1 / 4; text-align: left; padding-top: 4px; }
}
.totals { display: grid; gap: 6px; max-width: 360px; margin-left: auto; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: 16px; }
.totals .grand { font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 8px; margin-top: 4px; }

/* ---------- Catalogue ---------- */
.items { display: grid; gap: 10px; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.item__body { min-width: 0; flex: 1; }
.item__title { font-weight: 700; }
.item__sub { font-size: .8125rem; color: var(--muted); }
.item__thumb { width: 52px; height: 52px; border-radius: 12px; background: var(--surface-2); flex: none; overflow: hidden; display: grid; place-items: center; color: var(--muted); }
.item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.item.is-off { opacity: .6; }
.order { display: grid; }
.order .icon-btn { width: 30px; height: 26px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgb(22 22 22 / .45); animation: fade .2s ease; }
.modal__box { width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 22px; box-shadow: 0 30px 80px -20px rgb(0 0 0 / .5); animation: rise .28s var(--ease); }
.modal__box--sm { max-width: 440px; }
.modal__head { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal__head h2 { font-size: 1.1875rem; flex: 1; }
.modal__body { padding: 20px; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--shadow); animation: rise .25s var(--ease); max-width: 360px; }
.toast .ico { color: var(--sun); }
.toast--error { background: var(--red); }
.toast--error .ico { color: #fff; }
.demo-flag { white-space: nowrap; position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 70; background: var(--sun); color: var(--ink); font-weight: 700; font-size: .8125rem; padding: 6px 14px; border-radius: 99px; box-shadow: var(--shadow); }

/* Skeleton while loading */
.loading { display: grid; gap: 10px; }
.loading span { height: 52px; border-radius: 14px; background: linear-gradient(90deg, var(--bg-2), #f6f2e7, var(--bg-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   Printable quote / invoice (A4)
   ========================================================================== */
.doc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.paper { background: #fff; color: #111; width: 100%; max-width: 820px; margin: 0 auto; padding: 44px 48px; border-radius: 6px; box-shadow: var(--shadow); font-size: 13.5px; line-height: 1.5; }
.paper__head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 3px solid var(--ink); }
.paper__agency { display: grid; gap: 2px; }
.paper__agency .brand { color: #111; margin-bottom: 8px; }
.paper__agency img { max-height: 60px; max-width: 200px; object-fit: contain; margin-bottom: 8px; }
.paper__legal { font-size: 11.5px; color: #444; display: grid; gap: 1px; }
.paper__title { text-align: right; }
.paper__title h2 { font-size: 30px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.paper__title .no { font-family: var(--font-mono); font-size: 14px; font-weight: 700; margin-top: 4px; }
.paper__title .dates { margin-top: 10px; font-size: 12.5px; color: #333; }
.paper__parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 24px 0; }
.paper__box { border: 1px solid #ddd; border-radius: 8px; padding: 12px 14px; }
.paper__box h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #666; margin-bottom: 6px; }
.paper table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.paper th { background: var(--ink); color: #fff; text-align: left; padding: 9px 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.paper td { padding: 9px 10px; border-bottom: 1px solid #e5e5e5; vertical-align: top; }
.paper .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper__sum { display: flex; justify-content: flex-end; margin-top: 16px; }
.paper__sum table { width: 300px; margin: 0; }
.paper__sum td { border: 0; padding: 4px 10px; }
.paper__sum tr.grand td { font-size: 16px; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 10px; }
.paper__words { margin-top: 18px; padding: 12px 14px; background: #faf7ef; border-left: 4px solid var(--sun); font-size: 13px; }
.paper__notes { margin-top: 16px; font-size: 12.5px; color: #333; white-space: pre-wrap; }
.paper__foot { margin-top: 32px; padding-top: 12px; border-top: 1px solid #ddd; font-size: 11px; color: #555; text-align: center; }
.paper__sign { display: flex; justify-content: flex-end; margin-top: 28px; }
.paper__sign div { width: 220px; text-align: center; font-size: 12px; color: #444; border-top: 1px dashed #aaa; padding-top: 6px; }
@media (max-width: 700px) { .paper { padding: 24px 18px; } .paper__head, .paper__parties { grid-template-columns: 1fr; display: grid; } .paper__title { text-align: left; } }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .side, .topbar, .doc-actions, .toasts, .demo-flag, .scrim { display: none !important; }
  .main { margin: 0 !important; }
  .view { padding: 0 !important; max-width: none; }
  .paper { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .paper th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .paper__words { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 640px) { .topbar { position: static; } }
.paper__lines { overflow-x: auto; }
.paper__lines table { min-width: 520px; }
@media print { .paper__lines { overflow: visible; } .paper__lines table { min-width: 0; } }
#login-form { margin-top: 18px; }
.topbar__back { flex: none; }
@media (max-width: 640px) { .topbar__back span { display: none; } .topbar__back { width: 40px; padding: 0; } }
#login-step-sent .btn, #login-denied .btn { margin-top: 18px; }

/* Password login */
.login__step { display: grid; gap: 4px; }
.login__step form { margin-top: 18px; }
.login__alt { margin-top: 16px; text-align: center; color: var(--muted); font-size: .9375rem; }
.login__backlink { margin-top: 14px; justify-self: center; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: .875rem; }
.link-btn:hover { color: var(--sun-deep); }
.pw { position: relative; }
.pw input { padding-right: 46px; }
.pw__toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 0; background: none; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.pw__toggle:hover { background: var(--surface-2); color: var(--text); }
.pw__toggle[aria-pressed="true"] { color: var(--text); }
