/* AnesOps demo app styles. Brand colors and fonts come from /assets/tokens.css. */
body { min-height: 100vh; }
.shell { max-width: 1280px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Top bar */
.topbar { background: var(--grad-hero); color: var(--white); position: relative; overflow: hidden; }
.topbar::after { content: ''; position: absolute; top: -90px; right: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(200,150,62,0.12); pointer-events: none; }
.topbar .shell { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px; }
.topbar .brand-name { font-size: 22px; }
.topbar .brand-mark { width: 34px; height: 34px; }
.practice { display: flex; flex-direction: column; gap: 2px; border-left: 1px solid rgba(255,255,255,0.25); padding-left: 14px; margin-left: 4px; }
.practice b { font-weight: 600; font-size: 15px; }
.practice span { font: 11px var(--mono); color: var(--gold-light); letter-spacing: 0.06em; text-transform: uppercase; }
.top-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-right a { color: #D0E2E8; font-size: 14px; }

/* Tabs */
.tabs { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.tabs .shell { display: flex; gap: 4px; overflow-x: auto; padding-block: 8px; }
.tab { flex: none; min-height: 42px; padding: 0 16px; border: 0; border-radius: 100px; background: transparent; color: var(--slate); font: 500 15px var(--sans); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { background: var(--mist); color: var(--navy); }
.tab[aria-current="page"] { background: var(--grad-teal); color: var(--white); font-weight: 600; }

main.shell { padding-block: 24px 64px; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.view-head h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 3.4vw, 38px); }
.view-head p { margin: 4px 0 0; color: var(--slate); font-size: 15px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--white); border: 1px solid var(--line); border-radius: 100px; padding: 4px; }
.month-nav button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; font-size: 18px; color: var(--navy); }
.month-nav button:hover { background: var(--mist); }
.month-nav span { min-width: 150px; text-align: center; font-family: var(--serif); font-size: 19px; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 20px 22px; }
.panel h2 { margin: 0 0 4px; font-family: var(--serif); font-weight: 400; font-size: 22px; }
.panel .hint { margin: 0 0 16px; color: var(--slate); font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .k { font: 11px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--slate); }
.stat .v { font-family: var(--serif); font-size: 26px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.warn .v { color: var(--gold-text); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: left; font: 500 11.5px var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--slate); background: var(--mist); padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #E6EFF2; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; background: var(--mist); border-top: 1px solid var(--line); }

/* Schedule grid */
.sched th:first-child, .sched td:first-child { position: sticky; left: 0; background: var(--white); z-index: 1; }
.sched th:first-child { background: var(--mist); }
.sched td { min-width: 170px; }
.sched td:first-child { min-width: 92px; width: 92px; font-weight: 600; white-space: nowrap; }
.sched tr.weekend td { background: #FAFCFD; }
.sched tr.today td:first-child { color: var(--teal); }
.sched tr.today td:first-child::after { content: ' • today'; font: 10px var(--mono); color: var(--gold-text); }
.datecell small { display: block; font: 11px var(--mono); color: var(--slate); font-weight: 400; }
.cell { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.shift { text-align: left; border: 0; border-radius: 9px; padding: 7px 9px; font: 500 13px/1.25 var(--sans); cursor: pointer; }
.shift small { display: block; font: 11px var(--mono); opacity: 0.85; margin-top: 2px; }
.shift:hover { filter: brightness(0.96); }
.c-a { background: var(--ice); color: var(--navy-2); }
.c-b { background: var(--teal); color: var(--white); }
.c-c { background: var(--navy); color: var(--white); }
.c-d { background: #F3E9D6; color: #5E4310; }
.c-e { background: #E4E9F7; color: #263A73; }
.c-open { background: #FFF6E4; color: var(--gold-text); border: 1.5px dashed var(--gold); }
.add-shift { border: 1.5px dashed var(--line); background: transparent; color: var(--slate-light); border-radius: 9px; min-height: 30px; font-size: 13px; cursor: pointer; opacity: 0; transition: opacity .15s; }
td:hover .add-shift, .add-shift:focus-visible { opacity: 1; }
@media (hover: none) { .add-shift { opacity: 0.7; } }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; font-size: 13px; }
.legend span { padding: 4px 10px; border-radius: 100px; }

/* Forms */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--navy-2); }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--mist); color: var(--navy); font: 15px var(--sans); }
textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal-light); box-shadow: 0 0 0 3px rgba(42,139,159,0.18); background: var(--white); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--teal); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.grid-form .wide { grid-column: 1 / -1; }
.edit-table input, .edit-table select, .edit-table textarea { min-height: 38px; padding: 7px 9px; font-size: 14px; background: var(--white); }
.edit-table textarea { min-height: 60px; }
.edit-table td { padding: 8px; }
.icon-btn { border: 0; background: transparent; color: var(--slate); cursor: pointer; border-radius: 8px; min-width: 36px; min-height: 36px; font-size: 18px; }
.icon-btn:hover { background: #FBEAE7; color: var(--danger); }
.btn-danger { background: var(--white); color: var(--danger); border-color: #EBC2BA; }
.btn-danger:hover { background: #FBEAE7; color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Facility cards on invoice tab */
.fac-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 18px; }
.fac-card { text-align: left; background: var(--white); border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; cursor: pointer; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 6px; }
.fac-card:hover { border-color: var(--teal-light); }
.fac-card[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(42,139,159,0.15); }
.fac-card b { font-family: var(--serif); font-weight: 400; font-size: 20px; }
.fac-card .row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--slate); }
.tag { display: inline-block; font: 500 11px var(--mono); letter-spacing: 0.05em; padding: 4px 9px; border-radius: 100px; }
.tag-good { background: #E3F2EA; color: var(--good); }
.tag-wait { background: #FFF6E4; color: var(--gold-text); }

/* Printable documents */
.doc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.paper { background: #fff; color: #131B2A; max-width: 820px; margin: 0 auto; padding: clamp(24px, 5vw, 56px); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 10px 30px rgba(13,43,62,0.08); font-size: 13.5px; }
.paper + .paper { margin-top: 24px; }
.paper { overflow-x: auto; overflow-wrap: anywhere; }
.edit-table td:first-child input { min-width: 190px; }
.edit-table td textarea { min-width: 200px; }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; align-items: flex-start; }
.doc-org { display: flex; gap: 12px; align-items: flex-start; }
.doc-org .brand-mark { width: 40px; height: 40px; }
.doc-org b { font-family: var(--serif); font-weight: 400; font-size: 22px; display: block; }
.doc-org div { line-height: 1.5; color: #444; }
.doc-title { text-align: right; }
.doc-title h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: 0.04em; }
.doc-title div { line-height: 1.6; color: #444; font-variant-numeric: tabular-nums; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 26px 0 18px; padding: 16px 0; border-top: 2px solid var(--navy); border-bottom: 1px solid #ddd; }
.doc-meta .k { margin-bottom: 4px; }
.doc-meta div { white-space: pre-line; line-height: 1.5; }
.paper table { font-size: 13px; }
.paper th { background: #EEF3F5; }
.paper tfoot td { background: #EEF3F5; font-size: 15px; }
.doc-foot { margin-top: 22px; line-height: 1.6; color: #444; font-size: 12.5px; }
.doc-conf { margin-top: 26px; padding-top: 10px; border-top: 1px solid #bbb; font-size: 10.5px; color: #666; font-style: italic; line-height: 1.5; }

/* Billing calculator */
.calc-out { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 18px; }
.calc-out .stat .v { font-size: 24px; }
.calc-out .stat.total { background: var(--grad-teal); color: var(--white); border-color: transparent; }
.calc-out .stat.total .k { color: var(--ice); }

/* Dialog */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(5,20,30,0.35); color: var(--navy); }
dialog::backdrop { background: rgba(13,43,62,0.45); }
.dlg-head { background: var(--grad-hero); color: var(--white); padding: 18px 22px; }
.dlg-head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 24px; }
.dlg-body { padding: 20px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dlg-body .wide { grid-column: 1 / -1; }
.dlg-foot { padding: 0 22px 20px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.seg { display: inline-flex; background: var(--mist); border: 1px solid var(--line); border-radius: 100px; padding: 3px; gap: 3px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px; border-radius: 100px; font-weight: 500; font-size: 14px; color: var(--slate); }
.seg input:checked + span { background: var(--grad-teal); color: var(--white); }
.seg input:focus-visible + span { outline: 3px solid var(--gold-light); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--navy); color: var(--white); padding: 12px 20px; border-radius: 100px; font-size: 14.5px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.demo-note { background: #FFF6E4; color: var(--gold-text); border: 1px solid #EFDBA0; border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 18px; }
.empty { padding: 28px; text-align: center; color: var(--slate); }

@media (max-width: 560px) {
  .dlg-body { grid-template-columns: 1fr; }
  .practice { display: none; }
  .doc-title { text-align: left; }
}

@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable { position: absolute; left: 0; top: 0; width: 100%; }
  .paper { border: 0; box-shadow: none; max-width: none; padding: 0; margin: 0; }
  .paper + .paper { break-before: page; margin-top: 0; }
  .doc-actions { display: none; }
}
