:root {
  color-scheme: light;
  --bg-a: #d7e2ef;
  --bg-b: #ffe0ad;
  --surface: rgba(255, 252, 246, .84);
  --surface-strong: #fffdf9;
  --inset: #f0ece7;
  --ink: #261d18;
  --muted: #766b63;
  --border: rgba(80, 60, 46, .14);
  --teal: #0b7772;
  --teal-soft: #d9eeeb;
  --amber: #d58d38;
  --amber-ink: #2d1b0a;
  --red: #b54640;
  --shadow: 0 22px 60px rgba(49, 39, 33, .12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-a: #263447;
    --bg-b: #81501e;
    --surface: rgba(43, 33, 27, .86);
    --surface-strong: #31251f;
    --inset: #211914;
    --ink: #fff8ef;
    --muted: #c3b5a9;
    --border: rgba(255, 238, 220, .14);
    --teal: #73d0c5;
    --teal-soft: #173e3b;
    --amber: #e4a358;
    --amber-ink: #281708;
    --red: #f2837d;
    --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: linear-gradient(135deg, var(--bg-a), var(--bg-b)) fixed; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); display: grid; gap: 26px; padding: 30px; border: 1px solid var(--border); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 300; white-space: nowrap; }
.brand b { font-weight: 800; }
.brand-mark { position: relative; width: 38px; height: 38px; display: inline-block; border-radius: 50%; background: #075d64; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.brand-mark i { position: absolute; width: 8px; height: 8px; background: white; border-radius: 50%; }
.brand-mark i:nth-child(1) { left: 8px; top: 7px; }
.brand-mark i:nth-child(2) { right: 7px; top: 15px; }
.brand-mark i:nth-child(3) { left: 9px; bottom: 6px; }
.brand-mark::after { content: ""; position: absolute; inset: 7px 10px 7px 8px; border: 2px solid white; border-right-color: transparent; border-radius: 50%; }
h1, h2, p { margin: 0; }
h1 { margin-bottom: 7px; font-size: 28px; }
h2 { font-size: 19px; }
p, small { color: var(--muted); line-height: 1.45; }
.stack, .dialog-card { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
input, select { min-height: 42px; padding: 9px 11px; color: var(--ink); background: var(--surface-strong); border: 1px solid var(--border); border-radius: 11px; outline: none; }
input:focus, select:focus { border-color: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber), transparent 76%); }
.primary, .quiet { min-height: 42px; padding: 9px 15px; border-radius: 11px; border: 1px solid transparent; font-weight: 750; }
.primary { color: var(--amber-ink); background: var(--amber); }
.primary:hover { filter: brightness(1.05); }
.quiet { color: var(--ink); background: var(--surface-strong); border-color: var(--border); }
.compact { min-height: 38px; white-space: nowrap; }
.form-error { min-height: 18px; color: var(--red); font-size: 13px; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 10px clamp(16px, 4vw, 54px); background: color-mix(in srgb, var(--surface-strong), transparent 7%); border-bottom: 1px solid var(--border); backdrop-filter: blur(20px); }
.account { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.account .quiet { min-height: 34px; padding: 6px 11px; }
.content { width: min(1460px, calc(100% - 32px)); margin: 28px auto 60px; }
.overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.overview article { display: grid; gap: 7px; padding: 18px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); backdrop-filter: blur(16px); }
.overview span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.overview strong { font-size: 27px; }
.workspace-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.tabs { display: flex; gap: 5px; padding: 4px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.tab { min-height: 35px; padding: 7px 13px; color: var(--muted); border: 0; border-radius: 9px; background: transparent; font-weight: 700; }
.tab.active { color: var(--amber-ink); background: var(--amber); }
.workspace-actions { display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; gap: 7px; min-width: 260px; padding-left: 11px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-strong); }
.search span { font-size: 21px; color: var(--muted); }
.search input { min-width: 0; width: 100%; border: 0; background: transparent; box-shadow: none; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.panel-heading p { margin-top: 3px; font-size: 13px; }
.panel-heading select { min-width: 150px; min-height: 36px; }
.filter-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--inset), transparent 54%); }
.filter-groups { min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; }
.filter-group { min-width: 0; display: grid; gap: 6px; }
.filter-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip, .clear-filters { min-height: 30px; padding: 5px 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; background: var(--surface-strong); font-size: 12px; font-weight: 750; white-space: nowrap; }
.filter-chip:hover, .clear-filters:hover { color: var(--ink); border-color: color-mix(in srgb, var(--amber), var(--border) 55%); }
.filter-chip.active { color: var(--amber-ink); border-color: color-mix(in srgb, var(--amber), transparent 25%); background: var(--amber); }
.clear-filters { flex: none; color: var(--red); background: transparent; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1040px; }
th, td { padding: 13px 15px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); background: color-mix(in srgb, var(--inset), transparent 24%); font-size: 11px; text-transform: uppercase; letter-spacing: .045em; }
td { font-size: 13px; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-strong), transparent 45%); }
.identity { display: grid; gap: 2px; }
.identity strong { font-size: 14px; }
.identity small { color: var(--muted); }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status.waiting { color: #75460d; background: #ffe3b7; }
.status.answered { color: #075d57; background: #cfebe7; }
.status.closed { color: var(--muted); background: var(--inset); }
.role { text-transform: capitalize; }
.active-dot, .inactive-dot { display: inline-flex; align-items: center; gap: 6px; }
.active-dot::before, .inactive-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.active-dot::before { background: #27966e; }
.inactive-dot::before { background: var(--muted); }
.row-action { min-height: 31px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); background: var(--surface-strong); font-size: 12px; font-weight: 700; }
.row-action.danger { color: var(--red); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.doctor-select { min-width: 165px; min-height: 34px; padding: 5px 8px; font-size: 12px; }
.empty { padding: 34px; text-align: center; }

dialog { width: min(470px, calc(100% - 30px)); padding: 0; color: var(--ink); border: 1px solid var(--border); border-radius: 22px; background: var(--surface-strong); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(14, 12, 10, .58); backdrop-filter: blur(5px); }
.dialog-card { padding: 22px; }
.dialog-heading, .dialog-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-heading p { margin-top: 3px; font-size: 13px; }
.dialog-actions { justify-content: flex-end; margin-top: 4px; }
.icon-button { width: 34px; height: 34px; padding: 0; color: var(--muted); border: 1px solid var(--border); border-radius: 50%; background: var(--inset); font-size: 22px; }
.toast { position: fixed; z-index: 50; right: 20px; bottom: 20px; max-width: 380px; padding: 12px 15px; color: var(--ink); border: 1px solid var(--border); border-radius: 12px; background: var(--surface-strong); box-shadow: var(--shadow); }

@media (max-width: 800px) {
  .content { width: min(100% - 20px, 1460px); margin-top: 16px; }
  .overview { grid-template-columns: repeat(2, 1fr); }
  .workspace-bar { align-items: stretch; flex-direction: column; }
  .workspace-actions, .search { width: 100%; }
  .search { min-width: 0; }
  .workspace-actions .primary { flex: none; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
  .account span { display: none; }
  .filter-bar { align-items: stretch; flex-direction: column; padding-inline: 14px; }
  .filter-groups { display: grid; gap: 12px; }
  .filter-group { overflow: hidden; }
  .filter-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .clear-filters { align-self: flex-start; }
}

@media (max-width: 470px) {
  .topbar { padding-inline: 12px; }
  .brand { font-size: 18px; }
  .brand-mark { width: 34px; height: 34px; }
  .overview article { padding: 14px; }
  .overview strong { font-size: 23px; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .panel-heading select { width: 100%; }
}
