:root {
  --ink: #1f2a37;
  --ink-soft: #5b6b7c;
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e2e8ee;
  --brand: #3d5a80;
  --brand-deep: #2c4361;
  --brand-soft: #e8eef5;
  --accent: #98c1d9;
  --good: #2e7d5b;
  --good-soft: #e3f2ec;
  --warn: #b3701f;
  --warn-soft: #fbf0df;
  --bad: #b3403f;
  --bad-soft: #fae8e8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 42, 55, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
a { color: var(--brand); }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--brand-deep); color: #fff;
  display: flex; flex-direction: column; padding: 1.25rem 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 1.25rem 1.25rem; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.sidebar .brand .star { color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: #cdd9e5; text-decoration: none; padding: .6rem 1.25rem; font-weight: 500;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--accent); }
.sidebar .foot { margin-top: auto; padding: 1rem 1.25rem 0; font-size: .8rem; color: #9fb3c8; }
.sidebar .foot button { background: none; border: 1px solid #4d6580; color: #cdd9e5; border-radius: 6px; padding: .35rem .75rem; cursor: pointer; }
.sidebar .foot button:hover { background: rgba(255,255,255,.08); }

.main { flex: 1; padding: 1.5rem 2rem 4rem; max-width: 1100px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }

/* cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.card h2 { margin-bottom: .75rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } }

.stat { text-align: left; }
.stat .num { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.stat .lbl { color: var(--ink-soft); font-size: .85rem; }
.card.click { cursor: pointer; transition: border-color .12s, transform .12s; }
.card.click:hover { border-color: var(--brand); transform: translateY(-1px); }

/* tables / lists */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); padding: .4rem .6rem; border-bottom: 2px solid var(--line); }
td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--brand-soft); }
.empty { color: var(--ink-soft); padding: 1rem 0; font-style: italic; }

/* badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge.brand { background: var(--brand-soft); color: var(--brand-deep); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.soft { background: #eef1f4; color: var(--ink-soft); }

/* forms */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin: .6rem 0 .2rem; }
input, select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--brand); }
textarea { min-height: 84px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* buttons */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); padding: .5rem .9rem; font-weight: 600;
}
button:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-danger { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: .25rem .6rem; font-size: .82rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border: none; background: none; padding: .5rem .9rem; border-radius: 7px 7px 0 0; color: var(--ink-soft); }
.tabs button.active { color: var(--brand-deep); background: var(--brand-soft); font-weight: 700; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: .75rem; font-weight: 700; color: var(--ink-soft); text-align: center; padding: .25rem 0; }
.cal-cell { background: #fff; border: 1px solid var(--line); border-radius: 7px; min-height: 84px; padding: .25rem .35rem; font-size: .78rem; cursor: pointer; }
.cal-cell:hover { border-color: var(--brand); }
.cal-cell.dim { background: var(--bg); color: #aab6c2; }
.cal-cell.today { border: 2px solid var(--brand); }
.cal-cell .d { font-weight: 700; }
.cal-evt { background: var(--brand-soft); color: var(--brand-deep); border-radius: 4px; padding: 0 .3rem; margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-evt.hypnotherapy { background: #efe7f6; color: #5b3a86; }
.cal-evt.nlp { background: var(--good-soft); color: var(--good); }
.cal-evt.consultation { background: var(--warn-soft); color: var(--warn); }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(31,42,55,.45); display: flex; align-items: flex-start; justify-content: center; padding: 3rem 1rem; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; padding: 1.25rem 1.5rem 1.5rem; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal h2 { margin-bottom: .25rem; }

/* toast */
#toast-root { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--ink); color: #fff; padding: .6rem 1.1rem; border-radius: 8px; box-shadow: var(--shadow); animation: fadein .2s; }
.toast.error { background: var(--bad); }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* auth screens */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--brand-deep), var(--brand)); padding: 1rem; }
.auth-card { background: #fff; border-radius: 14px; padding: 2rem; width: 100%; max-width: 420px; box-shadow: 0 16px 50px rgba(0,0,0,.25); }
.auth-card .logo { font-size: 1.3rem; font-weight: 800; color: var(--brand-deep); margin-bottom: .25rem; }
.auth-card .sub { color: var(--ink-soft); font-size: .88rem; margin-bottom: 1rem; }
.auth-card button { width: 100%; margin-top: 1rem; padding: .65rem; }
.auth-err { color: var(--bad); font-size: .85rem; margin-top: .6rem; min-height: 1.2em; }

/* note editor */
.note-field label { color: var(--brand-deep); }
.note-meta { color: var(--ink-soft); font-size: .82rem; margin-bottom: .5rem; }
.locked-banner { background: var(--good-soft); color: var(--good); border-radius: 7px; padding: .5rem .8rem; font-size: .85rem; margin-bottom: .75rem; font-weight: 600; }
.amendment { border-left: 3px solid var(--accent); padding: .4rem .8rem; margin: .5rem 0; background: var(--brand-soft); border-radius: 0 7px 7px 0; font-size: .9rem; }
.note-view-field { margin-bottom: .75rem; }
.note-view-field .k { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.note-view-field .v { white-space: pre-wrap; }

/* print */
@media print {
  .sidebar, .btn-row, button, .btn, .tabs, #toast-root, #modal-root, input[type="file"] { display: none !important; }
  .layout { display: block; }
  .main { max-width: none; padding: 0; }
  body { background: #fff; font-size: 12px; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* responsive */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: .5rem .75rem; overflow-x: auto; }
  .sidebar .brand { padding: 0 .75rem 0 0; white-space: nowrap; }
  .sidebar nav { flex-direction: row; }
  .sidebar nav a { padding: .5rem .7rem; border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .sidebar nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .sidebar .foot { display: none; }
  .main { padding: 1rem; }
  .cal-cell { min-height: 56px; }
}
