:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #1c2430; --muted: #667085; --line: #e3e6ea;
  --brand: #1f5f8b; --brand-2: #174a6d; --rec: #c62828; --good: #1b7a4a; --warn: #a15c00; --bad: #b42318; --info: #3b5a78;
  --radius: 10px; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.4; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand b { display: block; font-size: 1.05rem; }
.brand small { color: var(--muted); font-size: .78rem; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.who { color: var(--muted); font-size: .9rem; margin-right: 6px; }

.layout { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.15fr); gap: 16px; padding: 16px; max-width: 1600px; margin: 0 auto; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.tabs { display: flex; gap: 6px; background: #eef1f4; padding: 4px; border-radius: 9px; }
.tab { flex: 1; border: 0; background: transparent; padding: 9px 8px; border-radius: 7px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: .9rem; }
.tab.active { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.span2 { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
label.block { gap: 6px; }
label small { font-weight: 400; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid #cfd5dc; border-radius: 7px; padding: 7px 9px; background: #fff; width: 100%; font-weight: 400; }
label.check input { width: auto; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3e0; border-color: var(--brand); }

body.tpl-visit .therapy-only, body.tpl-therapy .visit-only, body.inperson .tele, body.no-addon .addon-field { display: none; }

.btn { font: inherit; font-weight: 600; border: 1px solid #cfd5dc; background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { border-color: #9aa5b1; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; justify-content: center; padding: 10px; }
.btn.record { color: var(--rec); border-color: #e6b4b4; }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
body.is-recording .btn.record { background: var(--rec); color: #fff; border-color: var(--rec); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .75; } }

.recorder { border: 1px dashed #cfd5dc; border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: #fafbfc; }
.rec-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; margin-left: 4px; }
.level { flex: 1; min-width: 60px; height: 6px; background: #e6e9ed; border-radius: 4px; overflow: hidden; }
.level span { display: block; height: 100%; width: 0; background: var(--good); transition: width .1s; }
.hint { color: var(--muted); font-size: .82rem; margin: 0; }
.hint.bad { color: var(--bad); font-weight: 600; }
.interim { color: var(--muted); font-style: italic; min-height: 1.2em; font-size: .88rem; margin-top: -6px; }

.codebox { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #f8fafc; font-size: .86rem; display: flex; flex-direction: column; gap: 4px; }
.codebox .codes { font-weight: 700; color: var(--brand); }
.codebox .line::before { content: "• "; }
.codebox .good { color: var(--good); } .codebox .warn { color: var(--warn); } .codebox .bad { color: var(--bad); font-weight: 600; } .codebox .info { color: var(--info); }

.out-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.out-head h2 { margin: 0; font-size: 1.1rem; }
.note { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .86rem; min-height: 520px; flex: 1; }
.pill { background: #fff4e5; color: var(--warn); border: 1px solid #f3d19e; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; margin-right: 6px; }
.hidden { display: none; }
.audit { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; background: #fbfaf5; }
.audit summary { cursor: pointer; font-weight: 600; }
.audit pre { white-space: pre-wrap; font-family: inherit; font-size: .86rem; margin: 8px 0 0; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .4); }
.settings { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.settings h3 { margin: 0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; max-width: 90vw; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%); }

.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.error { color: var(--bad); background: #fdecea; padding: 8px 10px; border-radius: 7px; margin: 0; }
.notice { color: var(--info); background: #eef4fa; padding: 8px 10px; border-radius: 7px; margin: 0; }
.fine { color: var(--muted); font-size: .78rem; margin: 0; text-align: center; }
