/* Casali Office: phone-first, brand green, one radius scale, prints cleanly to PDF. */
:root {
  --bg: #f6f7f5; --surface: #ffffff; --surface-2: #eceeea; --text: #17201b; --muted: #4f5a53; --line: #d9ddd7;
  --accent: #2d6a4f; --accent-ink: #f4f7f3; --accent-soft: #d6eadd; --deep: #1b4332;
  --red: #b42318; --red-soft: #fde7e4; --amber: #a15c07; --amber-soft: #fdf0d8; --green-soft: #e3f1e8;
  --radius: 10px; --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.015em; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.boot { min-height: 100dvh; display: grid; place-items: center; }

/* Shell */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top img { height: 34px; display: block; }
.top-tag { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-left: 6px; }
.icon-btn { width: 42px; height: 42px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 20px; cursor: pointer; text-decoration: none; color: var(--text); }
main { max-width: 860px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-left)) calc(110px + env(safe-area-inset-bottom)); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.tabs a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 12px; font-weight: 500; color: var(--muted); text-decoration: none; border-radius: 8px; }
.tabs a .ph { font-size: 23px; }
.tabs a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* Building blocks */
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-title h1 { font-size: 26px; }
.lede { color: var(--muted); margin-top: -8px; margin-bottom: 18px; max-width: 60ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.section-h { font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1.5px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--accent); color: var(--accent-ink); }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14.5px; }
.btn.danger { background: var(--surface); color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.btn.block { width: 100%; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* Lists */
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; cursor: pointer; width: 100%; text-align: left; }
.item:hover { border-color: var(--accent); }
.item .ph { font-size: 24px; color: var(--accent); flex: none; }
.item-main { flex: 1; min-width: 0; }
.item-main strong { display: block; font-weight: 600; }
.item-main span { display: block; color: var(--muted); font-size: 14.5px; overflow-wrap: anywhere; }
.item-end { text-align: right; flex: none; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.empty-note { color: var(--muted); padding: 22px; text-align: center; border: 1.5px dashed var(--line); border-radius: var(--radius); }

/* Status chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--accent); }
.chip.grey { background: var(--surface-2); color: var(--muted); }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { font-size: 13.5px; color: var(--muted); }
.stat.alert b { color: var(--red); }
@media (max-width: 480px) { .stats { grid-template-columns: 1fr 1fr; } }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Forms */
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 14.5px; }
.field .hint { font-size: 13.5px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 16px; }
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.ticks { display: grid; gap: 8px; }
.tick { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.tick input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.tick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tick small { display: block; color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 90px; text-align: center; padding: 11px 10px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 500; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--deep); }
.callout { padding: 14px 16px; border-radius: var(--radius); background: var(--amber-soft); color: #5c3606; font-size: 15px; }
.callout.green { background: var(--accent-soft); color: var(--deep); }
.callout.red { background: var(--red-soft); color: #7a1a10; }

/* Wizard steps */
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { flex: 1; height: 5px; border-radius: 999px; background: var(--surface-2); }
.steps span.on { background: var(--accent); }
.wiz-nav { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; gap: 10px; justify-content: space-between; margin-top: 22px; padding: 10px 0; background: linear-gradient(transparent, var(--bg) 30%); }

/* Invoice lines */
.line { display: grid; grid-template-columns: 1fr 80px 110px auto; gap: 8px; align-items: end; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.line .field.desc { grid-column: 1 / -1; }
@media (max-width: 560px) { .line { grid-template-columns: 1fr 1fr; } .line .rm { grid-column: 1 / -1; } }
.totals { display: grid; gap: 6px; margin-top: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals .grand { font-size: 20px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }

/* Documents (invoice, safety pack): on screen a paper-like sheet, in print just the sheet */
.doc { background: #fff; color: #17201b; border: 1px solid var(--line); border-radius: var(--radius); padding: 36px; max-width: 800px; margin: 0 auto; font-size: 14.5px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; border-bottom: 2px solid var(--accent); padding-bottom: 18px; margin-bottom: 22px; }
.doc-head img { height: 52px; }
.doc-head .meta { text-align: right; font-size: 13.5px; color: #4f5a53; }
.doc h1 { font-size: 24px; color: var(--deep); }
.doc h2 { font-size: 16px; margin: 24px 0 8px; color: var(--deep); }
.doc table { width: 100%; border-collapse: collapse; }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e3e6e1; vertical-align: top; }
.doc th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: #4f5a53; background: #f3f5f2; }
.doc td.num, .doc th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc .two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.doc ul { margin: 6px 0; padding-left: 20px; }
.doc .small { font-size: 12.5px; color: #4f5a53; }
.doc .foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid #e3e6e1; font-size: 12px; color: #4f5a53; }
.doc .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 28px; }
.doc .sign div { border-top: 1px solid #17201b; padding-top: 6px; font-size: 12.5px; }
.doc .badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #d6eadd; color: #1b4332; font-size: 12px; font-weight: 600; }
@media (max-width: 600px) { .doc { padding: 20px 16px; } .doc .two { grid-template-columns: 1fr; } .doc-head { flex-direction: column; } .doc-head .meta { text-align: left; } }
.doc-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 0 auto 18px; max-width: 800px; }

@media print {
  .top, .tabs, .doc-actions, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .doc { border: 0; padding: 0; max-width: none; }
  @page { margin: 16mm; }
}

/* Sign-in */
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.signin .card { width: min(420px, 100%); padding: 28px; display: grid; gap: 16px; }
.signin img { height: 54px; justify-self: start; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--deep); color: #fff; padding: 12px 18px; border-radius: 999px; font-weight: 500; z-index: 50; box-shadow: 0 10px 30px rgb(0 0 0 / .2); }

/* Phone fixes: status chips move under the text instead of pushing rows wider than the screen */
.top a { text-decoration: none; }
@media (max-width: 600px) {
  .item { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 6px; }
  .item > .chip, .item > .item-end, .item > .ph-caret-right { grid-column: 2; justify-self: start; text-align: left; }
  .item-end { display: flex; gap: 10px; align-items: center; }
  .chip { white-space: normal; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: 1 / -1; }
}
