:root {
  --bg: #0b0d10;
  --panel: #12151a;
  --panel2: #171b21;
  --border: #232830;
  --text: #e8eaed;
  --muted: #8b93a0;
  --cyan: #38bdf8;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --violet: #a78bfa;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Geist', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}
a { color: var(--cyan); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.field { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--cyan); color: #06222e;
  border: none; border-radius: 8px;
  padding: 9px 16px; font-weight: 700; font-size: 13.5px;
  transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.danger { background: var(--red); color: #2b0808; }
.btn.green { background: var(--green); color: #05261a; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }

/* login */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px; width: 380px; text-align: center;
}
.login-lock { font-size: 34px; margin-bottom: 10px; }
.login-logo { font-size: 24px; font-weight: 800; }
.login-logo span { color: var(--cyan); }
.login-sub { color: var(--muted); margin: 8px 0 24px; }
.login-card form { text-align: left; }
.login-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 218px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.side .logo { font-size: 18px; font-weight: 800; padding: 0 10px 18px; }
.side .logo span { color: var(--cyan); }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--muted);
  padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 600;
  text-align: left; width: 100%;
}
.nav-btn:hover { color: var(--text); background: var(--panel2); }
.nav-btn.active { color: var(--text); background: var(--panel2); box-shadow: inset 2px 0 0 var(--cyan); }
.side .spacer { flex: 1; }
.side .whoami { padding: 10px 12px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }
.main { flex: 1; padding: 28px 32px; max-width: 1240px; min-width: 0; }
.page-title { font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 22px; }

/* cards & stats */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .num { font-size: 26px; font-weight: 800; font-family: 'Geist Mono', monospace; }
.stat-card .lbl { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 130px; }
.row > .fix { flex: 0 0 auto; min-width: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.015); }
.clinic-nm { font-weight: 600; }
.meta { font-size: 12px; color: var(--muted); }

.badge { display: inline-block; padding: 2.5px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.b-green { background: rgba(52,211,153,.14); color: var(--green); }
.b-red { background: rgba(248,113,113,.14); color: var(--red); }
.b-amber { background: rgba(251,191,36,.14); color: var(--amber); }
.b-cyan { background: rgba(56,189,248,.14); color: var(--cyan); }
.b-gray { background: rgba(139,147,160,.14); color: var(--muted); }
.b-violet { background: rgba(167,139,250,.14); color: var(--violet); }

/* progress bar */
.pbar { height: 8px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
.pbar > div { height: 100%; background: var(--cyan); border-radius: 6px; transition: width .4s; }

/* overlay */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; justify-content: center; align-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* toast */
#toast { position: fixed; bottom: 22px; right: 22px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--cyan); border-radius: 8px; padding: 12px 16px; font-size: 13.5px; max-width: 380px; animation: slidein .25s; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* editor */
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .editor-grid { grid-template-columns: 1fr; } }
textarea.body-edit { min-height: 320px; font-family: 'Geist Mono', monospace; font-size: 13px; line-height: 1.55; resize: vertical; }
.preview-box { background: #fff; color: #222; border-radius: 10px; padding: 22px; min-height: 320px; font-family: Arial, sans-serif; font-size: 14.5px; line-height: 1.6; overflow-wrap: break-word; }
.preview-subject { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.tags-hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.7; }
.tags-hint code { background: var(--panel2); padding: 1px 6px; border-radius: 5px; font-family: 'Geist Mono', monospace; font-size: 11.5px; color: var(--cyan); cursor: pointer; }

/* guide */
.guide h2 { font-size: 17px; margin: 26px 0 10px; color: var(--cyan); }
.guide h2:first-child { margin-top: 0; }
.guide p, .guide li { line-height: 1.7; color: #c9cdd4; }
.guide ul, .guide ol { padding-left: 22px; margin: 8px 0; }
.guide strong { color: var(--text); }
.guide .ex { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 8px; padding: 14px 16px; margin: 10px 0; font-size: 13.5px; line-height: 1.65; }
.guide .ex.bad { border-left-color: var(--red); }
.guide .ex .t { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.guide .ex.bad .t { color: var(--red); }
.guide .ex .t { color: var(--green); }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type=checkbox] { width: auto; }
.muted { color: var(--muted); }
.mono { font-family: 'Geist Mono', monospace; font-size: 12.5px; }
.mt { margin-top: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
