:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #1d2a26;
  --muted: #64746f;
  --line: #dde3e1;
  --brand: #13795b;
  --brand-dark: #0d5c45;
  --brand-soft: #e3f2ec;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b42318;
  --danger-soft: #fde8e7;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* layout */
.top { display: flex; align-items: center; gap: 18px; background: var(--brand-dark); color: #fff; padding: 0 18px; height: 52px; position: sticky; top: 0; z-index: 10; }
.top .logo { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .2px; white-space: nowrap; }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; }
.top nav a { color: #d4ebe2; padding: 6px 10px; border-radius: 6px; font-weight: 500; }
.top nav a:hover, .top nav a.on { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.top form { margin-left: auto; }
.top input[type=search] { width: 260px; border: 0; border-radius: 6px; padding: 7px 10px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 18px 60px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.side { grid-template-columns: 320px 1fr; }
@media (max-width: 900px) { .side { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
td.num, th.num { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); padding: 12px 0; }

/* forms */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: 7px 9px; border: 1px solid #c9d2cf; border-radius: 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd5c1; border-color: var(--brand); }
input[type=checkbox] { width: auto; margin-right: 6px; }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; font-weight: 500; color: var(--ink); font-size: 14px; margin: 6px 0; }
.fields { display: grid; gap: 10px 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 12px; }
.fields .wide { grid-column: 1 / -1; }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline > div { flex: 1 1 120px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand-dark); border-color: #bcd9cd; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f1b4ae; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
form.i { display: inline; }

/* bits */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.flash.ok { background: var(--brand-soft); color: var(--brand-dark); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #eef1f0; color: #3b4a45; white-space: nowrap; }
.tag.pomv { background: #fde8e7; color: #9b1c13; }
.tag.pomvps { background: #fff1db; color: #8a4b00; }
.tag.nfa { background: #e5effd; color: #1d4f91; }
.tag.avm { background: #e3f2ec; color: #0d5c45; }
.tag.cd { background: #2b2b2b; color: #fff; }
.tag.alert { background: var(--danger); color: #fff; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; }
.kv dt { color: var(--muted); font-size: 12px; padding-top: 1px; }
.kv dd { margin: 0; }
.stat { font-size: 26px; font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs a.on { color: var(--brand-dark); border-color: var(--brand); text-decoration: none; }
.tab { display: none; }
.tab.on { display: block; }
.soap b { display: inline-block; min-width: 18px; color: var(--brand-dark); }
.entry { border-left: 3px solid var(--line); padding: 6px 0 6px 12px; margin-bottom: 10px; }
.entry.Consult { border-color: var(--brand); }
.entry.Vaccination { border-color: #6aa2e8; }
.entry.Prescription { border-color: #e69b3c; }
.entry.Consent { border-color: #9a7ad6; }
.pre { white-space: pre-wrap; }
.status-Arrived { background: #fff6dc; }
.status-In\ consult { background: #e5effd; }
.status-Done { background: #e9f5ef; color: var(--muted); }
.status-DNA, .status-Cancelled { background: #f6f6f6; color: #999; text-decoration: line-through; }

/* diary */
.diary { table-layout: fixed; }
.diary td, .diary th { border: 1px solid var(--line); padding: 0; height: 26px; }
.diary th { padding: 6px; text-align: center; background: #fafcfb; }
.diary td.time { width: 60px; font-size: 12px; color: var(--muted); text-align: center; vertical-align: middle; }
.diary td.slot a.add { display: block; height: 100%; min-height: 25px; }
.diary td.slot a.add:hover { background: var(--brand-soft); }
.diary td.appt { background: #e3f2ec; padding: 3px 6px; font-size: 12px; border-left: 3px solid var(--brand); }
.diary tr.hour td { border-top: 1px solid #b9c6c2; }

/* autocomplete */
.ac { position: relative; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.08); max-height: 260px; overflow: auto; }
.ac-list div { padding: 7px 10px; cursor: pointer; }
.ac-list div:hover, .ac-list div.on { background: var(--brand-soft); }

@media print {
  .top, .noprint, .actions, .flash { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
}

/* logins, banners */
.userbox { display: flex; align-items: center; gap: 8px; margin-left: 10px; color: #fff; white-space: nowrap; }
.userbox a { color: #fff; font-weight: 600; }
.lic-banner { padding: 8px 18px; font-weight: 600; }
.lic-banner.warn { background: var(--warn-soft); color: var(--warn); }
.lic-banner.error { background: var(--danger-soft); color: var(--danger); }
.lic-banner.info { background: var(--brand-soft); color: var(--brand-dark); }
.authbox { max-width: 400px; margin: 9vh auto; }
.authbox .logo { font-size: 24px; font-weight: 700; color: var(--brand-dark); margin-bottom: 10px; }
.authbox label { display: block; margin: 10px 0 3px; font-weight: 600; }
.authbox input { width: 100%; }
