:root {
  --brand: #0f766e; --brand-d: #0b5550; --brand-l: #e6f4f2; --ink: #14212b; --mut: #5d6b78; --line: #e2e8ee;
  --bg: #f4f7f9; --card: #fff; --ok: #15803d; --ok-l: #dcfce7; --warn: #b45309; --warn-l: #fef3c7; --bad: #b91c1c; --bad-l: #fee2e2;
  --info: #1d4ed8; --info-l: #dbeafe; --wa: #1fa855; --r: 14px; --sh: 0 1px 3px rgba(20, 33, 43, .08), 0 4px 14px rgba(20, 33, 43, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 17px; } h4 { font-size: 15px; margin-top: 16px; }
p { margin: 0 0 10px; }
.muted { color: var(--mut); } .small { font-size: 13.5px; } .center { text-align: center; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.pre { white-space: pre-wrap; word-break: break-word; }
i.req, label i { color: var(--bad); font-style: normal; }

.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; min-width: 0; }
.brand #brandName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: #fff; color: var(--brand); display: grid; place-items: center; font-size: 24px; font-weight: 800; flex: 0 0 auto; }
.top-right { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 0 auto; }
.top .btn { white-space: nowrap; }
.who { display: flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; min-width: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; font-size: 14px; }
.role { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: rgba(255, 255, 255, .2); border-radius: 999px; padding: 2px 8px; }
.demo-bar { background: var(--warn-l); color: #713f12; font-size: 13.5px; padding: 8px 16px; text-align: center; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 18px 16px 40px; }
.wrap.narrow { max-width: 640px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 18px; margin-bottom: 14px; }
.card.hl { border: 2px solid var(--brand); }
.ok-card { border-left: 5px solid var(--ok); }
.err-card { border-left: 5px solid var(--bad); }
.sec { margin: 22px 2px 10px; font-size: 18px; }
.ph { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.ph h1, .ph h2 { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.center { justify-content: center; }
.loading { padding: 40px; text-align: center; color: var(--mut); }
.foot { text-align: center; color: var(--mut); font-size: 13px; margin-top: 24px; }
.note { background: var(--info-l); color: #1e3a8a; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
details > summary { cursor: pointer; padding: 6px 0; color: var(--brand); font-weight: 600; }
details.card > summary { color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-d); }
.btn.ghost { background: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-ghost { color: var(--bad); border-color: #f3c4c4; background: #fff; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.light { background: #fff; color: var(--brand); border-color: #fff; }
.btn.ghost-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .55); }
.btn.big { min-height: 50px; padding: 12px 22px; font-size: 16.5px; }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: 13.5px; }
.btn.full { width: 100%; }
.spin { width: 16px; height: 16px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp .8s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }

.hero { background: linear-gradient(135deg, var(--brand), #115e8a); color: #fff; padding: 36px 0 30px; }
.hero h1 { font-size: 30px; }
.hero p { font-size: 17px; opacity: .95; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: -10px 0 8px; }
.step { background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 16px; }
.step span { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-l); color: var(--brand); font-weight: 800; margin-bottom: 6px; }
.step b { display: block; } .step p { color: var(--mut); font-size: 14px; margin: 4px 0 0; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 14px; }
.doc-card { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 14px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--brand-l); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 19px; flex: 0 0 auto; }

.fsec { margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--brand-l); color: var(--brand); font-size: 15.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.span2 { grid-column: 1 / -1; }
.field { display: block; margin-bottom: 12px; }
.grid2 .field { margin-bottom: 0; }
.field > span { display: block; font-size: 13.5px; font-weight: 600; color: #34434f; margin-bottom: 5px; }
.field small { display: block; color: var(--mut); font-size: 12.5px; margin-top: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid #cdd6de; border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(15, 118, 110, .2); border-color: var(--brand); }
input.bad, select.bad, textarea.bad { border-color: var(--bad); background: #fff7f7; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--brand); transform: scale(1.15); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; font-size: 15px; }
.check input { margin-top: 4px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.seg label { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; cursor: pointer; font-size: 15px; }
.form-err { background: var(--bad-l); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 14.5px; margin: 12px 0; }
.tabs2 { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs2 a { flex: 1; text-align: center; padding: 10px; border-radius: 10px; background: #fff; box-shadow: var(--sh); text-decoration: none; color: var(--mut); font-weight: 700; }
.tabs2 a.on { background: var(--brand); color: #fff; }

.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge.pending { background: var(--warn-l); color: var(--warn); }
.badge.approved, .badge.scheduled { background: var(--info-l); color: var(--info); }
.badge.completed { background: var(--ok-l); color: var(--ok); }
.badge.rejected, .badge.cancelled { background: var(--bad-l); color: var(--bad); }
.badge.live-b { background: #dcfce7; color: #166534; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.live { display: flex; gap: 8px; align-items: center; background: #dcfce7; color: #166534; font-weight: 700; border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #16a34a; animation: pulse 1.2s ease-in-out infinite; }
.appt { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; background: var(--brand-l); border-radius: 12px; padding: 12px 14px; margin: 10px 0 12px; }
.appt b { display: block; font-size: 17px; } .appt span { display: block; }
.problem { background: #f8fafb; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0 12px; }
.problem p { margin: 4px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.share { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 6px 14px; margin: 6px 0 10px; font-size: 15px; }
.kv dt { color: var(--mut); font-weight: 600; font-size: 13.5px; padding-top: 2px; }
.kv dd { margin: 0; word-break: break-word; }
.rx .kv { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 10px 0 12px; }
.stat { background: #fff; border: 2px solid transparent; border-radius: var(--r); box-shadow: var(--sh); padding: 12px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--mut); font-weight: 600; }
.stat.on { border-color: var(--brand); }
.stat.pending b { color: var(--warn); } .stat.approved b { color: var(--info); } .stat.completed b { color: var(--ok); } .stat.rejected b { color: var(--bad); }
.search { margin-bottom: 12px; }
.prow { display: flex; justify-content: space-between; gap: 12px; background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 14px; margin-bottom: 10px; text-decoration: none; color: inherit; border: 2px solid transparent; }
.prow:hover { border-color: var(--brand-l); }
.prow-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.prow-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; flex: 0 0 auto; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }

.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 32, .55); display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; }
.modal-h .x { border: 0; background: #eef2f5; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; cursor: pointer; }
.modal-b { padding: 16px 18px; overflow: auto; -webkit-overflow-scrolling: touch; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; background: #14212b; color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14.5px; max-width: 92vw; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); text-align: center; }
.toast.err { background: var(--bad); }

/* video */
.pre { text-align: left; }
.pre-video { position: relative; background: #0d1820; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; max-width: 520px; margin: 12px auto; }
.pre-video video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.pv-msg { position: absolute; inset: auto 0 0 0; padding: 10px 12px; color: #fff; background: rgba(0, 0, 0, .55); font-size: 14px; text-align: center; }
.call { display: grid; grid-template-columns: 1fr; gap: 12px; }
.call.with-notes { grid-template-columns: 1fr 340px; }
.stage { position: relative; background: #0d1820; border-radius: 16px; overflow: hidden; min-height: 60vh; }
#rv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0d1820; }
#lv { position: absolute; right: 12px; top: 54px; width: 28%; max-width: 200px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; border: 2px solid rgba(255, 255, 255, .7); transform: scaleX(-1); background: #22313c; z-index: 3; }
.stage-msg { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 2; color: #fff; background: rgba(0, 0, 0, .5); padding: 12px 18px; border-radius: 12px; display: flex; gap: 10px; align-items: center; max-width: 86%; text-align: center; font-weight: 600; }
.stage-msg.failed, .stage-msg.error { background: rgba(185, 28, 28, .85); }
.stage-msg.failed .spin, .stage-msg.error .spin, .stage-msg.waiting .spin { display: none; }
.topinfo { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; gap: 10px; align-items: center; padding: 12px 14px; color: #fff; background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
.topinfo b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctrls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; justify-content: center; gap: 12px; padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.cbtn { width: 56px; height: 56px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); font-size: 22px; cursor: pointer; display: grid; place-items: center; }
.cbtn.off { background: #fca5a5; text-decoration: line-through; }
.cbtn.end { width: auto; padding: 0 20px; border-radius: 28px; background: #dc2626; color: #fff; font-size: 16px; font-weight: 700; }
.btn.tap { position: absolute; left: 50%; top: 60%; transform: translateX(-50%); z-index: 4; }
.notes { background: #fff; border-radius: 16px; box-shadow: var(--sh); padding: 16px; max-height: 80vh; overflow: auto; }
.notes .field { margin-bottom: 10px; }
.notes-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.notes-h h3 { margin: 0 0 6px; }
.notes-x { display: none; }
.backup { grid-column: 1 / -1; background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 12px 16px; }
.backup.show { border: 2px solid var(--warn); background: var(--warn-l); }
body.in-call .foot, body.in-call .demo-bar { display: none; }

/* checks */
.checks { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.checks li { padding: 8px 12px; border-radius: 10px; font-size: 14.5px; }
.checks li.ok { background: var(--ok-l); color: #14532d; } .checks li.bad { background: var(--bad-l); color: #7f1d1d; } .checks li.info { background: var(--info-l); color: #1e3a8a; }
.meter { height: 10px; background: #e5eaee; border-radius: 6px; overflow: hidden; max-width: 520px; margin: 0 auto 4px; }
.meter span { display: block; height: 100%; width: 0; background: #16a34a; transition: width .08s; }
pre.code { background: #0f1b24; color: #d6e2ea; padding: 14px; border-radius: 12px; overflow: auto; font-size: 12.5px; line-height: 1.45; max-height: 420px; }

/* prescription */
.rx-page { background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 28px; max-width: 800px; margin: 0 auto; }
.rx-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--brand); padding-bottom: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.rx-head h1 { color: var(--brand); margin: 0; }
.rx-head p { margin: 2px 0 0; color: var(--mut); }
.rx-doc { text-align: right; }
.rx-page h3 { margin: 16px 0 6px; color: var(--brand); font-size: 16px; }
.rx-sign { margin: 50px 0 10px auto; width: 220px; border-top: 1px solid #333; text-align: center; padding-top: 4px; font-size: 13px; }

@media (max-width: 860px) {
  .call.with-notes { grid-template-columns: 1fr; }
  .notes { display: none; }
  .notes.open { display: block; position: fixed; inset: auto 0 0 0; max-height: 78vh; z-index: 50; border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .3); }
  .notes.open .notes-h { position: sticky; top: -16px; background: #fff; margin: -16px -16px 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); z-index: 1; }
  .notes-x { display: inline-flex; flex: 0 0 auto; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .wrap { padding: 14px 12px 36px; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat.all { grid-column: 1 / -1; }
  .hero h1 { font-size: 25px; }
  .hero .btn.big { width: 100%; }
  .who-name { display: none; }
  .stage { min-height: 70vh; border-radius: 12px; }
  body.in-call .wrap { padding: 6px; }
  .cbtn { width: 50px; height: 50px; font-size: 20px; }
  .modal-back { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 94vh; }
  .modal-f .btn { flex: 1; }
  .prow { flex-direction: column; }
  .prow-side { flex-direction: row; justify-content: space-between; align-items: center; }
  .clip { max-width: 80vw; }
  h1 { font-size: 23px; }
}
@media print {
  .top, .demo-bar, .noprint, .toast, .foot { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: none; }
  .rx-page { box-shadow: none; padding: 0; }
}
