:root {
  --ink: #172033;
  --muted: #68738a;
  --line: #dce3ef;
  --surface: #ffffff;
  --canvas: #f3f6fb;
  --navy: #102a56;
  --blue: #1967d2;
  --blue-2: #0f4da8;
  --cyan: #22b8cf;
  --green: #16855b;
  --amber: #b46a00;
  --red: #c93756;
  --shadow: 0 18px 50px rgba(34, 55, 91, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Segoe UI Variable Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(25, 103, 210, .22);
  outline-offset: 2px;
}

.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(220, 227, 239, .9);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(16px);
}
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--navy); font-weight: 800; letter-spacing: -.02em; }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-name { color: var(--muted); font-size: 13px; }

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 15px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}
.btn:hover { transform: translateY(-1px); border-color: #b8c5da; box-shadow: 0 8px 22px rgba(23, 32, 51, .08); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { color: #fff; border-color: var(--blue); background: linear-gradient(135deg, var(--blue), var(--blue-2)); }
.btn-success { color: #fff; border-color: var(--green); background: var(--green); }
.btn-danger, .btn-red { color: #fff; border-color: var(--red); background: var(--red); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 34px; padding: 6px 11px; border-radius: 9px; font-size: 13px; }
.btn-block { width: 100%; }

.page { padding: 34px 0 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; color: var(--navy); line-height: 1.2; letter-spacing: -.025em; }
h1 { font-size: clamp(28px, 4vw, 42px); }
h2 { font-size: 23px; }
h3 { font-size: 17px; }
p { margin: 0; }
.subtitle { max-width: 720px; margin-top: 8px; color: var(--muted); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.stat { position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; width: 78px; height: 78px; right: -22px; top: -25px; border-radius: 50%; background: rgba(25, 103, 210, .08); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { margin-top: 7px; color: var(--navy); font-size: 30px; font-weight: 850; }

.field { display: grid; gap: 7px; }
.field label { color: #34405a; font-size: 13px; font-weight: 750; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fbfcff;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input, .select { min-height: 45px; }
.textarea { min-height: 150px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(25, 103, 210, .11); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.help { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 20px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { white-space: nowrap; }
.tab.active { color: #fff; border-color: var(--blue); background: var(--blue); }
.tab-panel[hidden] { display: none; }

.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 14px; border-bottom: 1px solid #edf1f7; text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); background: #f8faff; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 7px; }

.badge { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 800; background: #edf2fa; color: #43506a; }
.badge-blue { background: #e8f0fe; color: #1258b5; }
.badge-green { background: #e4f6ee; color: #0d754d; }
.badge-amber { background: #fff1d7; color: #925500; }
.badge-red { background: #fde9ed; color: #aa2944; }
.badge-dark { background: #e8ebf1; color: #263148; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 6px; color: var(--navy); font-size: 17px; }
.divider { height: 1px; margin: 22px 0; background: var(--line); }
.stack { display: grid; gap: 14px; }
.inline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.queue-search { flex: 1 1 420px; justify-content: flex-end; }
.queue-search .input { flex: 1 1 240px; min-width: 220px; }
.muted { color: var(--muted); }

.alert { display: flex; gap: 12px; border: 1px solid #c9dbfa; border-radius: 14px; padding: 13px 15px; color: #194c92; background: #eff5ff; }
.alert-warning { border-color: #f0d198; color: #825000; background: #fff8e9; }
.alert-danger { border-color: #efb6c2; color: #91223a; background: #fff0f3; }

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgba(12, 22, 42, .52); backdrop-filter: blur(5px); }
.modal[hidden] { display: none; }
.modal-card { width: min(980px, 100%); max-height: calc(100vh - 36px); overflow: auto; border-radius: 20px; padding: 24px; background: #fff; box-shadow: 0 30px 90px rgba(0, 0, 0, .25); }

.toast-area { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 9px; width: min(380px, calc(100vw - 36px)); }
.toast { border-left: 4px solid var(--green); border-radius: 12px; padding: 12px 14px; color: #fff; background: #1d2a40; box-shadow: 0 16px 50px rgba(0,0,0,.22); animation: toast-in .22s ease both; }
.toast.error { border-left-color: #ff5575; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.loading-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(244, 247, 252, .82); backdrop-filter: blur(5px); }
.loading-overlay[hidden] { display: none; }
.loading-box { min-width: min(360px, 100%); border: 1px solid var(--line); border-radius: 18px; padding: 24px; text-align: center; background: #fff; box-shadow: var(--shadow); }
.spinner { width: 42px; height: 42px; margin: 0 auto 14px; border: 4px solid #dbe6f8; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.auth-art { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 54px; color: #fff; background: radial-gradient(circle at 20% 10%, #2886f2 0, transparent 35%), linear-gradient(145deg, #0a1f47, #103e7c); }
.auth-art::after { content: ''; position: absolute; width: 430px; height: 430px; right: -170px; bottom: -170px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.03), 0 0 0 140px rgba(255,255,255,.025); }
.auth-art h1 { max-width: 650px; color: #fff; font-size: clamp(38px, 6vw, 70px); }
.auth-art p { max-width: 620px; margin-top: 16px; color: #c9dbfa; font-size: 18px; }
.auth-main { display: grid; place-items: center; padding: 36px; background: #fff; }
.auth-card { width: min(430px, 100%); }
.auth-card h2 { margin-top: 26px; font-size: 30px; }

.hero { position: relative; overflow: hidden; padding: 100px 0 90px; color: #fff; background: radial-gradient(circle at 75% 20%, rgba(34,184,207,.35), transparent 30%), linear-gradient(145deg, #081a3d, #124a91); }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 50px; }
.hero h1 { max-width: 820px; color: #fff; font-size: clamp(45px, 7vw, 82px); }
.hero p { max-width: 690px; margin-top: 20px; color: #cfe0fb; font-size: 19px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.hero-panel { border: 1px solid rgba(255,255,255,.18); border-radius: 24px; padding: 24px; background: rgba(255,255,255,.08); backdrop-filter: blur(16px); box-shadow: 0 25px 80px rgba(0,0,0,.2); }
.hero-line { display: flex; justify-content: space-between; gap: 15px; padding: 13px 0; border-bottom: 1px solid rgba(255,255,255,.12); }
.hero-line:last-child { border: 0; }
.section { padding: 78px 0; }
.section-white { background: #fff; }
.feature-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 13px; color: #fff; background: linear-gradient(135deg, var(--blue), var(--cyan)); font-weight: 900; }
.about-intro { max-width: 820px; }
.benefit-grid { margin-top: 30px; align-items: stretch; }
.benefit-card { position: relative; overflow: hidden; }
.benefit-card::after { content: ""; position: absolute; width: 150px; height: 150px; right: -75px; top: -75px; border-radius: 50%; background: linear-gradient(135deg, rgba(22,119,255,.08), rgba(24,190,206,.12)); pointer-events: none; }
.benefit-list { display: grid; gap: 13px; margin: 22px 0 0; padding: 0; list-style: none; }
.benefit-list li { position: relative; padding-left: 29px; color: var(--muted); line-height: 1.6; }
.benefit-list li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--green); font-weight: 900; }
.catalog-document-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.template-editor { min-height: 300px; font-family: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif; line-height: 1.65; }
.settings-group { padding-top: 22px; margin-top: 22px; border-top: 1px solid var(--line); }
.settings-group:first-of-type { margin-top: 0; }
.pricing-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 34px 0 15px; }
.plan-grid { align-items: stretch; }
.plan-card { display: flex; flex-direction: column; gap: 20px; }
.plan-card h3 { margin-top: 12px; font-size: 1.32rem; }
.plan-card .btn { margin-top: auto; }
.plan-price { color: var(--navy); font-size: 1.45rem; font-weight: 850; }
.plan-price small { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; font-weight: 500; }
.plan-features { display: grid; gap: 9px; margin: 0; padding-left: 22px; color: var(--muted); }
.sales-modal-card { width: min(760px, 100%); }
.sales-honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.consent { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.consent input { margin-top: 4px; }
.setting-toggle { display: flex; align-items: flex-start; gap: 12px; margin-top: 20px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #f8faff; cursor: pointer; }
.setting-toggle input { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--blue); }
.setting-toggle span { display: grid; gap: 4px; }
.setting-toggle small { color: var(--muted); line-height: 1.45; }
.alert-error { border-color: #f5b5c1 !important; color: #8a1730 !important; background: #fff3f5 !important; }
body.modal-open { overflow: hidden; }

.recorder { display: flex; align-items: center; gap: 13px; border: 1px dashed #b8c7df; border-radius: 14px; padding: 13px; background: #f8faff; }
.audio-preview { display: block; width: 100%; margin-top: 12px; }
.audio-preview[hidden] { display: none; }
.record-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.record-dot.live { animation: pulse 1s ease infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(201, 55, 86, .15); } }
.editor { min-height: 310px; line-height: 1.75; font-family: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif; }
.reference-text { margin-top: 10px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.reference-sections, .normal-category-list { display: grid; gap: 12px; }
.reference-section, .normal-category, .normal-document { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; }
.reference-section > summary, .normal-category > summary, .normal-document > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; cursor: pointer; background: #f8fafc; }
.reference-section > summary span:first-child, .normal-category > summary span:first-child { display: grid; gap: 3px; }
.reference-section > summary small, .normal-category > summary small { color: var(--muted); font-weight: 400; }
.reference-section[open] > summary, .normal-category[open] > summary { border-bottom: 1px solid var(--line); }
.reference-section-body { padding: 14px; }
.normal-category-list { gap: 10px; }
.normal-category-body { display: grid; gap: 8px; padding: 10px; }
.normal-document { border-radius: 11px; }
.normal-document > summary { padding: 11px 13px; background: #fff; }
.normal-document-body { padding: 0 13px 13px; border-top: 1px solid #eef2f7; }
.normal-document-body .form-actions { margin-top: 10px; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }
.editor-size-control { gap: 6px; margin-left: auto; font-size: .82rem; color: var(--muted); }
.editor-size-control .select { width: auto; min-height: 34px; padding: 5px 28px 5px 9px; }
.rich-editor { overflow: auto; white-space: pre-wrap; background: #fff; }
.rich-editor:empty::before { content: attr(data-placeholder); color: #97a3b6; pointer-events: none; }
.training-output { min-height: 220px; white-space: pre-wrap; overflow-wrap: anywhere; }
.focus-card { scroll-margin-top: 92px; }
.case-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; }
.case-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(25,103,210,.1); }
.access-toolbar { display: grid; grid-template-columns: 1fr auto auto; gap: 9px; margin-top: 14px; }
.access-summary { display: flex; justify-content: space-between; gap: 12px; margin: 10px 2px; color: var(--muted); font-size: .88rem; }
.access-groups, #catalogList { display: grid; gap: 10px; }
.access-group, .catalog-group { border: 1px solid var(--line); border-radius: 13px; background: #fff; overflow: hidden; }
.access-group summary, .catalog-group summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; cursor: pointer; background: #f8fafc; }
.access-documents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.access-document { display: flex; align-items: flex-start; gap: 9px; padding: 11px 13px; background: #fff; cursor: pointer; }
.access-document:hover { background: #f8fbff; }
.access-document small { display: block; margin-top: 2px; color: var(--muted); }
.catalog-documents { display: grid; gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.catalog-document { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #fff; }

@media (max-width: 920px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-page, .hero-grid { grid-template-columns: 1fr; }
  .auth-art { min-height: 340px; padding: 38px; }
  .hero { padding-top: 72px; }
}

@media (max-width: 650px) {
  .container { width: min(100% - 22px, 1180px); }
  .topbar-inner { min-height: 64px; }
  .brand span, .nav-name { display: none; }
  .topbar .nav-actions .btn-ghost { display: none; }
  .topbar .nav-actions { gap: 6px; }
  .topbar .nav-actions .btn { padding: 9px 10px; font-size: .78rem; }
  .mobile-sticky-tabs { position: sticky; top: 64px; z-index: 15; margin-inline: -11px; padding: 7px 11px; overflow-x: auto; flex-wrap: nowrap; background: rgba(244,247,252,.96); backdrop-filter: blur(8px); }
  .mobile-sticky-tabs .tab { flex: 1 0 auto; white-space: nowrap; }
  .doctor-stats, .secretary-stats { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 5px; }
  .doctor-stats .stat, .secretary-stats .stat { min-width: 145px; scroll-snap-align: start; }
  .focus-card { scroll-margin-top: 132px; }
  .editor-toolbar { position: sticky; top: 119px; z-index: 10; }
  .rich-editor { min-height: 260px; }
  .page { padding-top: 24px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .queue-card-head { align-items: stretch; flex-direction: column; }
  .queue-search { flex-basis: auto; justify-content: stretch; }
  .queue-search .input { flex-basis: 100%; min-width: 0; }
  .queue-search .btn { flex: 1; }
  .grid-2, .grid-3, .grid-4, .form-row, .access-documents { grid-template-columns: 1fr; }
  .access-toolbar { grid-template-columns: 1fr 1fr; }
  .access-toolbar .input { grid-column: 1 / -1; }
  .card { padding: 17px; border-radius: 15px; }
  .auth-art { min-height: 290px; padding: 28px 24px; }
  .auth-main { padding: 30px 22px; }
  .hero { padding: 62px 0; }
  .section { padding: 55px 0; }
  .pricing-heading { align-items: flex-start; flex-direction: column; }
  th, td { padding: 10px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
