/* Osiolog Clinic — calm, clinical, easy to read on a phone at the chairside. */
:root {
  --bg: #f4f7f6; --card: #fff; --ink: #14201d; --muted: #5d6b67; --faint: #8a9793; --line: #e1e8e5; --line2: #eef3f1;
  --primary: #0f766e; --primary-ink: #fff; --primary-soft: #e3f3f0; --primary-dark: #0b5c55;
  --green: #15803d; --green-soft: #e6f6eb; --red: #c0392b; --red-soft: #fdecea; --amber: #b45309; --amber-soft: #fff4e0;
  --blue: #1d4ed8; --blue-soft: #e8efff; --violet: #6d28d9; --violet-soft: #f1ebff;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,40,35,.06), 0 4px 14px rgba(16,40,35,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
small, .muted { color: var(--muted); }
.bad { color: var(--red); } .good { color: var(--green); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
svg { flex: none; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.layout { min-height: 100vh; }
.side { display: none; }
main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); min-width: 0; }
.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar a.on { color: var(--primary); }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 236px 1fr; }
  .tabbar { display: none; }
  main { padding-bottom: 40px; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; }
  .side nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
  .side nav a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; }
  .side nav a:hover { background: var(--line2); }
  .side nav a.on { background: var(--primary-soft); color: var(--primary-dark); font-weight: 650; }
  .side-foot { margin-top: auto; display: grid; gap: 8px; }
  .side-foot .who { font-size: 13px; color: var(--muted); padding: 0 6px; }
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px; }
.brand .logo { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand b { display: block; font-size: 14px; line-height: 1.2; }
.brand small { font-size: 12px; }

.screen { max-width: 1100px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 8px 14px; background: rgba(244,247,246,.94); backdrop-filter: blur(8px); border-bottom: 1px solid transparent; }
.topbar h1 { font-size: 19px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; gap: 6px; align-items: center; }
.pad { padding: 0 14px; }
.section { padding: 6px 14px 14px; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 16px 2px 8px; }
.section-h h2 { font-size: 15px; font-weight: 700; }
.section-h a, .section-h button.link { font-size: 14px; font-weight: 600; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; min-height: 40px; white-space: nowrap; }
.btn:hover { background: var(--line2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--line2); }
.link { background: none; border: 0; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { font-size: 12px; }
input, select, textarea { width: 100%; border: 1px solid #cfdad6; background: #fff; border-radius: 10px; padding: 10px 12px; min-height: 42px; outline: none; }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.14); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 12px; font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 11px; color: var(--faint); }
.search input { padding-left: 40px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 14px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg { display: inline-flex; background: var(--line2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 14px 16px; }
.list { display: grid; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: inherit; cursor: pointer; }
.item:hover { border-color: #c6d4cf; }
.item .mid { flex: 1; min-width: 0; }
.item .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { text-align: right; flex: none; }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--primary-soft); color: var(--primary-dark); flex: none; }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--line2); color: var(--muted); white-space: nowrap; }
.tag.paid, .tag.st-done { background: var(--green-soft); color: var(--green); }
.tag.partial, .tag.st-arrived { background: var(--amber-soft); color: var(--amber); }
.tag.unpaid, .tag.st-noshow { background: var(--red-soft); color: var(--red); }
.tag.st-chair { background: var(--violet-soft); color: var(--violet); }
.tag.st-booked { background: var(--blue-soft); color: var(--blue); }
.tag.cancelled, .tag.st-cancel { background: #eee; color: #777; text-decoration: line-through; }
.tag.alert { background: var(--red-soft); color: var(--red); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .kpis.k4 { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; cursor: pointer; color: inherit; display: block; }
.kpi .v { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .l { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
.kpi.accent { background: var(--primary); border-color: var(--primary); color: #fff; }
.kpi.accent .l, .kpi.accent .sub { color: rgba(255,255,255,.82); }
.kpi.warn .v { color: var(--red); }
.period-note { font-size: 13px; color: var(--muted); margin: 0 2px 10px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-size: 12.5px; font-weight: 650; color: var(--ink); text-align: center; }
.quick a svg { color: var(--primary); }

/* ---------- bar chart ---------- */
.bars { width: 100%; height: auto; display: block; }
.bars .bar { fill: var(--primary); }
.bars .bar:hover, .bars .bar.sel { fill: var(--primary-dark); }
.bars text { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.bars .grid { stroke: var(--line); stroke-width: 1; }
.chart-tip { font-size: 13px; min-height: 20px; color: var(--muted); margin: 4px 2px 0; }
.chart-tip b { color: var(--ink); }

/* ---------- appointments ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; padding: 0 14px 10px; flex-wrap: wrap; }
.cal-head .date { font-weight: 700; font-size: 16px; min-width: 150px; }
.daygrid { position: relative; display: grid; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 190px); }
.daygrid .hdr { position: sticky; top: 0; z-index: 3; background: #fff; border-bottom: 1px solid var(--line); padding: 8px 6px; font-weight: 650; font-size: 13px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.daygrid .hdr i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.daygrid .times { position: sticky; left: 0; z-index: 2; background: #fff; border-right: 1px solid var(--line); }
.daygrid .tm { font-size: 11px; color: var(--faint); text-align: right; padding: 0 6px; transform: translateY(-7px); }
.daygrid .col { position: relative; border-right: 1px solid var(--line2); }
.daygrid .slot { border-top: 1px solid var(--line2); cursor: pointer; }
.daygrid .slot.hour { border-top-color: var(--line); }
.daygrid .slot:hover { background: var(--primary-soft); }
.appt { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 4px 7px; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; border-left: 4px solid; background: #f3f7ff; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.appt b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.done { opacity: .62; }
.appt.cancelled, .appt.no_show { opacity: .45; text-decoration: line-through; }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 2; pointer-events: none; }
.queue .item { align-items: flex-start; }
.weekgrid { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.weekday { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 140px; }
.weekday h3 { font-size: 13px; margin-bottom: 6px; cursor: pointer; }
.weekday.today { border-color: var(--primary); }
.wk-appt { font-size: 12px; padding: 4px 6px; border-radius: 6px; background: var(--line2); margin-bottom: 4px; border-left: 3px solid; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- patient ---------- */
.p-head { display: flex; gap: 14px; align-items: center; padding: 4px 14px 12px; }
.p-head .avatar { width: 54px; height: 54px; font-size: 18px; }
.p-head h2 { font-size: 20px; }
.alerts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 10px; border-bottom: 1px solid var(--line); scrollbar-width: none; background: var(--bg); position: sticky; top: 58px; z-index: 15; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; font-weight: 600; color: var(--muted); border-bottom: 2.5px solid transparent; white-space: nowrap; font-size: 14px; }
.tabs a.on { color: var(--primary-dark); border-color: var(--primary); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.timeline { display: grid; gap: 10px; }
.tl { border-left: 3px solid var(--primary-soft); padding: 2px 0 2px 12px; }
.tl .d { font-size: 12px; color: var(--muted); font-weight: 650; }

/* ---------- tooth chart ---------- */
.chart-wrap { overflow-x: auto; padding: 8px 0; }
.dentition { display: grid; gap: 4px; min-width: 640px; }
.arch { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; }
.arch.milk { grid-template-columns: repeat(3, 1fr) repeat(10, 1fr) repeat(3, 1fr); }
.arch .gap { visibility: hidden; }
.dentition.narrow { min-width: 0; }
.arch.q { grid-template-columns: repeat(8, 1fr); }
.qlabel { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.tooth { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; border-radius: 8px; padding: 3px 0; border: 1.5px solid transparent; background: none; }
.tooth:hover { background: var(--line2); }
.tooth.sel { border-color: var(--primary); background: var(--primary-soft); }
.tooth .no { font-size: 11px; font-weight: 700; color: var(--muted); }
.tooth svg { width: 100%; max-width: 40px; height: auto; }
.tooth .cond { font-size: 9.5px; font-weight: 700; line-height: 1.1; min-height: 11px; text-align: center; }
.midline { height: 1px; background: var(--line); margin: 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.cond-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cond-pick button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 11px; font-size: 13px; font-weight: 600; cursor: pointer; }
.cond-pick button.on { color: #fff; }
.surf-pick { display: flex; gap: 6px; margin-bottom: 12px; }
.surf-pick button { width: 44px; height: 40px; border: 1.5px solid var(--line); background: #fff; border-radius: 9px; font-weight: 700; cursor: pointer; }
.surf-pick button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- plans ---------- */
.plan { margin-bottom: 12px; }
.plan-h { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line2); }
.plan-h h3 { font-size: 15px; flex: 1; }
.plan-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--line2); }
.plan-row:last-child { border-bottom: 0; }
.plan-row .ord { display: flex; flex-direction: column; }
.plan-row .ord button { width: 28px; height: 22px; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; display: grid; place-items: center; }
.plan-row .ord button:disabled { opacity: .25; }
.plan-row.done .what { text-decoration: line-through; color: var(--muted); }
.plan-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: var(--line2); border-radius: 0 0 var(--radius) var(--radius); font-size: 14px; flex-wrap: wrap; }

/* ---------- bills ---------- */
.lines { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 64px 92px 34px; gap: 6px; align-items: start; }
.line .nm { display: grid; gap: 4px; }
.line input { min-height: 38px; padding: 7px 9px; }
.line .sub { display: grid; grid-template-columns: 70px 1fr; gap: 4px; }
.totals { display: grid; gap: 6px; font-size: 15px; }
.totals div { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.totals .big { font-size: 19px; font-weight: 750; }
.totals input { max-width: 120px; text-align: right; }
.sticky-foot { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 10; background: var(--bg); padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
@media (min-width: 900px) { .sticky-foot { bottom: 0; } }
.sticky-foot .btn { flex: 1; }
.suggest { position: relative; }
.suggest-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.12); max-height: 260px; overflow-y: auto; }
.suggest-list button { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; border: 0; background: #fff; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line2); }
.suggest-list button:hover, .suggest-list button.on { background: var(--primary-soft); }
.suggest-list small { color: var(--muted); }

/* ---------- printable documents (shown on screen as a paper preview) ---------- */
.paper-wrap { padding: 8px 14px 20px; overflow-x: auto; }
.paper { background: #fff; color: #111; width: 100%; max-width: 794px; margin: 0 auto; padding: 32px 36px; box-shadow: var(--shadow); border: 1px solid var(--line); font-size: 13px; line-height: 1.45; }
.paper .ph { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--tc, #0f766e); padding-bottom: 12px; margin-bottom: 14px; }
.paper .ph .cn { font-size: 21px; font-weight: 800; color: var(--tc, #0f766e); }
.paper .ph img { max-height: 64px; max-width: 120px; object-fit: contain; }
.paper .ttl { text-align: center; font-weight: 800; letter-spacing: .12em; font-size: 13px; margin: 2px 0 12px; }
.paper .meta { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.paper table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.paper th { background: var(--tc, #0f766e); color: #fff; font-size: 11.5px; text-align: left; padding: 6px 8px; }
.paper td { padding: 6px 8px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.paper .n { text-align: right; white-space: nowrap; }
.paper .sum { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; }
.paper .sum table { width: 280px; margin: 0; }
.paper .sum td { border: 0; padding: 3px 8px; }
.paper .sum .gt td { border-top: 2px solid #111; font-weight: 800; font-size: 15px; }
.paper .qr { display: flex; gap: 10px; align-items: center; font-size: 12px; }
.paper .qr img { width: 104px; height: 104px; }
.paper .sign { text-align: right; margin-top: 30px; font-size: 12px; }
.paper .sign img { max-height: 54px; max-width: 160px; display: block; margin-left: auto; }
.paper .foot { margin-top: 18px; padding-top: 8px; border-top: 1px solid #ddd; font-size: 11.5px; color: #555; text-align: center; }
.paper .rx-sym { font: italic 800 30px Georgia, serif; color: var(--tc, #0f766e); }
.paper .words { font-size: 12px; color: #444; }
/* bill themes */
.paper.theme-modern .ph { background: var(--tc, #0f766e); color: #fff; margin: -32px -36px 16px; padding: 22px 36px; border: 0; }
.paper.theme-modern .ph .cn { color: #fff; }
.paper.theme-modern .ph img { background: #fff; border-radius: 6px; padding: 3px; }
.paper.theme-modern .ttl { color: var(--tc, #0f766e); font-size: 15px; }
.paper.theme-modern tbody tr:nth-child(even) td { background: #f6f8f7; }
.paper.theme-simple .ph { border-bottom: 1px solid #111; }
.paper.theme-simple .ph .cn, .paper.theme-simple .rx-sym { color: #111; }
.paper.theme-simple th { background: #fff; color: #111; border-top: 1px solid #111; border-bottom: 1px solid #111; }
@media (max-width: 600px) { .paper.theme-modern .ph { margin: -18px -16px 14px; padding: 16px; } }
@media (max-width: 600px) { .paper { padding: 18px 16px; font-size: 12px; } .paper .sum { flex-direction: column-reverse; align-items: stretch; } .paper .sum table { width: 100%; } }
.thermal { width: 58mm; font: 12px/1.35 "Courier New", monospace; color: #000; background: #fff; padding: 3mm; margin: 0 auto; }
.thermal.w80 { width: 80mm; }
.thermal .c { text-align: center; } .thermal .b { font-weight: 700; } .thermal .big { font-size: 15px; }
.thermal .r { display: flex; justify-content: space-between; gap: 6px; }
.thermal hr { border: 0; border-top: 1px dashed #000; margin: 4px 0; }

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(10,25,22,.42); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.sheet-wrap.in { opacity: 1; }
.sheet { background: #fff; width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; transform: translateY(24px); transition: transform .18s; }
.sheet-wrap.in .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 6px 18px; }
.sheet-head h2 { font-size: 17px; flex: 1; }
.sheet-body { padding: 6px 18px 16px; overflow-y: auto; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line2); }
.sheet-foot .btn { flex: 1; }
@media (min-width: 700px) {
  .sheet-wrap { align-items: center; }
  .sheet { width: 520px; border-radius: 16px; max-height: 88vh; }
  .sheet.wide { width: 760px; }
  .sheet-foot .btn { flex: none; min-width: 110px; }
}
.confirm-msg { font-size: 15px; margin: 4px 0 8px; }

/* ---------- sync status ---------- */
.sync { display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 650; cursor: pointer; background: var(--green-soft); color: var(--green); }
.sync svg { width: 16px; height: 16px; }
.sync.off { background: var(--amber-soft); color: var(--amber); }
.sync.busy { background: var(--blue-soft); color: var(--blue); }
.sync.err { background: var(--red-soft); color: var(--red); }
@media (max-width: 520px) { .topbar .sync span { display: none; } .topbar .sync { padding: 6px; } }
#toasts { position: fixed; z-index: 200; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 28px)); pointer-events: none; }
.toast { background: #17231f; color: #fff; padding: 11px 14px; border-radius: 10px; font-weight: 550; box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: opacity .4s, transform .4s; }
.toast.good { background: var(--green); } .toast.bad { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- sign in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #e3f3f0, #f4f7f6 55%); }
.auth-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 26px 24px; box-shadow: 0 12px 40px rgba(16,60,52,.12); }
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; color: var(--primary); }
.auth-brand svg { width: 40px; height: 40px; }
.auth-brand b { display: block; font-size: 20px; color: var(--ink); }
.auth .seg { width: 100%; margin-bottom: 16px; } .auth .seg button { flex: 1; padding: 8px; }
.auth-err { color: var(--red); min-height: 20px; font-size: 14px; margin-bottom: 6px; }
.fine { font-size: 12.5px; color: var(--muted); text-align: center; margin: 12px 0 0; }

.menu { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu a, .menu button { display: flex; gap: 12px; align-items: center; background: #fff; padding: 13px 16px; color: var(--ink); font-weight: 550; border: 0; text-align: left; cursor: pointer; width: 100%; }
.menu a:hover, .menu button:hover { background: var(--line2); }
.menu svg:first-child { color: var(--primary); }
.menu .mid { flex: 1; } .menu small { display: block; font-weight: 400; }

@media print {
  body * { visibility: hidden !important; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; }
  .print-area .paper { box-shadow: none; border: 0; max-width: none; padding: 0; }
  @page { margin: 12mm; }
}

/* ---------- statement of account (billing app layout) ---------- */
.paper.a4 { width: 794px; max-width: none; padding: 40px 46px; font-size: 13px; }
.doc .st-tag { font-size: 12px; font-weight: 650; letter-spacing: .3px; }
.doc .st-head { display: flex; gap: 22px; align-items: center; margin: 24px 0; }
.doc .st-head img { width: 120px; max-height: 96px; object-fit: contain; }
.doc .st-bn { font-size: 28px; font-weight: 750; color: var(--tc); }
.doc .st-ba { font-size: 12.5px; margin-top: 4px; color: #333; }
.doc .st-bar { height: 8px; background: var(--tc); }
.doc .st-meta { display: flex; justify-content: space-between; background: #e8e8e8; padding: 12px 18px; }
.doc .st-billto { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; }
.doc .st-lbl { font-size: 12.5px; letter-spacing: .4px; color: #444; }
.doc .st-nm { font-weight: 700; font-size: 14px; margin-top: 6px; }
.doc .st-sbox { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 2px 0 14px; }
.doc .st-sbox div { border: 1px solid #ddd; border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.doc .st-sbox span { font-size: 11.5px; color: #666; } .doc .st-sbox b { font-size: 15px; }
.doc table.st-items { width: 100%; border-collapse: collapse; font-size: 12px; margin: 0; }
.doc .st-items th { background: none; color: #222; font-weight: 650; padding: 9px 7px; border-top: 2px solid var(--tc); border-bottom: 2px solid var(--tc); font-size: 12px; }
.doc .st-items td { padding: 8px 7px; border-bottom: 1px solid #e3e3e3; }
.doc .st-items tr { break-inside: avoid; }
.doc .st-items tr.st-sub td { font-weight: 700; border-top: 2px solid var(--tc); border-bottom: 2px solid var(--tc); }
.doc .st-note { font-size: 11px; color: #777; margin-top: 6px; }
.doc .st-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 18px; }
.doc .st-sign { text-align: right; } .doc .st-sign img { max-width: 170px; max-height: 64px; display: block; margin-left: auto; }
/* an A4 page shown shrunk to fit a phone screen, like the billing app */
.fit-wrap { padding: 12px 14px; overflow: hidden; }
.fit-wrap .fit { transform-origin: top left; }
.doc-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 900px) { .doc-actions { left: 236px; } }
.doc-actions .inner { max-width: 760px; margin: 0 auto; }
.doc-actions .who { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px 6px; }
.doc-actions .wa-row { padding: 4px 16px 10px; }
.doc-actions .btns4 { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.doc-actions .btns4 button { background: none; border: 0; padding: 10px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--primary); font-weight: 650; cursor: pointer; font-size: 14px; }
.doc-actions .btns4 svg { width: 24px; height: 24px; }
.stat2 { border-radius: var(--radius); padding: 16px; border: 1px solid #cfe0f3; background: #f6f9fe; }
.stat2 .v { font-size: 24px; font-weight: 750; } .stat2 .l { font-size: 15px; color: var(--muted); margin-top: 2px; }
.stat2.green { background: var(--green-soft); border-color: #a9dcbc; } .stat2.green .l { color: var(--green); font-weight: 650; }
.stat2.red { background: var(--red-soft); border-color: #f2b9b5; } .stat2.red .l { color: var(--red); font-weight: 650; }
.print-area .paper.a4 { width: auto; padding: 0; }

.doc .st-box { border: 1px solid #888; padding: 1px 6px; font-weight: 500; color: #555; margin-left: 8px; }
.doc .st-desc { color: #777; font-size: 11.5px; }
.doc .st-items tr.st-spacer td { height: 90px; border-bottom: 0; }
.doc .st-items td { vertical-align: top; }
.doc .st-totals { display: flex; justify-content: space-between; gap: 30px; margin-top: 14px; }
.doc .st-totals .left { flex: 1; font-size: 12.5px; }
.doc .st-totals .right { width: 330px; }
.doc .st-totals .tr { display: flex; justify-content: space-between; padding: 5px 0; }
.doc .st-totals .tr.strong { font-weight: 700; border-top: 1px solid #333; border-bottom: 1px solid #333; padding: 8px 0; margin-bottom: 6px; }
.doc .st-words { text-align: right; margin-top: 14px; } .doc .st-words b { display: block; font-weight: 650; }
.doc .st-terms { margin-top: 18px; font-size: 12px; white-space: pre-wrap; }
.doc > .st-sign { margin-top: 26px; }
.doc .qr img { width: 96px; height: 96px; }
.doc.theme-modern .st-head { background: var(--tc); color: #fff; margin: 0 -46px 0; padding: 20px 46px; }
.doc.theme-modern .st-head .st-bn, .doc.theme-modern .st-head .st-ba { color: #fff; }
.doc.theme-modern .st-head img { background: #fff; border-radius: 6px; padding: 4px; }
.doc.theme-modern .st-meta { background: color-mix(in srgb, var(--tc) 12%, #fff); }
.doc.theme-simple { --tc: #222 !important; } .doc.theme-simple .st-bar { height: 2px; } .doc.theme-simple .st-meta { background: #f2f2f2; }
.print-area .paper.doc .st-items tr.st-spacer td { height: 40px; }
