:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #edf2f5;
  --text: #182025;
  --muted: #65727c;
  --line: #dbe2e7;
  --primary: #127269;
  --primary-2: #1f9d8f;
  --accent: #c2563f;
  --warning: #b98516;
  --danger: #b83b45;
  --ok: #287a4c;
  --shadow: 0 18px 45px rgba(34, 45, 55, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(420px, 760px);
  align-items: start;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(24, 184, 196, 0.14), transparent 34%), var(--bg);
}

.is-authenticated .login-screen {
  display: none;
}

.is-locked .app-shell {
  display: none;
}

.login-panel {
  width: 100%;
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.login-brand img {
  width: 86px;
  height: 86px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
}

.login-brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.login-help {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: #f6f8fa;
  border: 1px solid var(--line);
  color: var(--muted);
}

.payment-return {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--line));
  background: color-mix(in srgb, var(--primary) 8%, #ffffff);
  color: var(--text);
}

.payment-return span {
  color: var(--muted);
  line-height: 1.45;
}

.public-directory {
  display: grid;
  gap: 16px;
  width: 100%;
}

.public-directory[hidden] {
  display: none;
}

.public-directory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 2px;
}

.public-directory-head h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.psychologist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.psychologist-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(34, 45, 55, 0.08);
}

.profile-avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 12%, #ffffff);
  color: var(--primary);
  font-weight: 800;
}

.profile-specialty {
  margin: 8px 0 6px;
  font-weight: 800;
}

.psychologist-card .primary-btn {
  margin-top: 12px;
}

.single-public-card {
  grid-column: 1 / -1;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 288px 1fr;
}

.sidebar {
  min-height: 100vh;
  padding: 24px;
  color: #ffffff;
  background: linear-gradient(180deg, #173841, #1f4f4a 52%, #2c3f42);
  position: sticky;
  top: 0;
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: #ffffff;
  color: var(--primary);
  flex: 0 0 auto;
  padding: 6px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-block h1,
.topbar h2,
.hero-product h3,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  font-size: 20px;
  line-height: 1.14;
}

.eyebrow {
  margin: 0 0 6px;
  color: inherit;
  opacity: 0.72;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0;
}

.switcher-label {
  display: block;
  margin: 28px 0 8px;
  font-size: 13px;
  opacity: 0.8;
}

.clinic-select,
.search-input,
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
  color: var(--text);
}

.sidebar .clinic-select {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.sidebar .clinic-select option {
  color: var(--text);
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 26px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  text-align: left;
  padding: 10px 12px;
}

.nav-item span {
  width: 22px;
  text-align: center;
  font-weight: 800;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.sidebar-card {
  margin-top: 28px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-card strong,
.sidebar-card small {
  display: block;
}

.sidebar-card small {
  margin-top: 8px;
  line-height: 1.5;
  opacity: 0.78;
}

.user-card {
  display: grid;
  gap: 8px;
}

.user-card .ghost-btn {
  width: 100%;
  margin-top: 6px;
}

.main-panel {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h2 {
  font-size: 26px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary-btn,
.ghost-btn,
.text-btn {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
}

.primary-btn {
  color: #ffffff;
  background: var(--primary);
}

.primary-btn:hover {
  background: var(--primary-2);
}

.ghost-btn {
  color: var(--text);
  background: #ffffff;
  border-color: var(--line);
}

.text-btn {
  color: var(--primary);
  background: transparent;
  padding-inline: 8px;
}

.danger-btn {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  padding: 9px 14px;
  color: var(--danger);
  background: #ffffff;
  font-weight: 700;
}

.danger-btn:hover {
  color: #ffffff;
  background: var(--danger);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.hero-product {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.1fr);
  gap: 24px;
  align-items: stretch;
  padding: 24px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.hero-product h3 {
  font-size: 34px;
  line-height: 1.08;
  max-width: 620px;
}

.hero-product p:last-child {
  color: var(--muted);
  line-height: 1.6;
  max-width: 600px;
}

.mini-calendar {
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #fbfcfd, #edf3f0);
  padding: 14px;
}

.calendar-head,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.calendar-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.calendar-tile {
  min-height: 148px;
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  display: grid;
  align-content: start;
  gap: 8px;
}

.slot-chip {
  border-left: 4px solid var(--primary);
  background: var(--surface-2);
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.25;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
}

.metric-card strong {
  display: block;
  font-size: 28px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  display: grid;
  gap: 18px;
}

.two-col {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.stack,
.schedule-list,
.patient-list,
.finance-summary,
.report-grid {
  display: grid;
  gap: 12px;
}

.item-row,
.patient-card,
.payment-row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: #f9fbfc;
  border: 1px solid var(--line);
}

.row-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.row-top strong {
  line-height: 1.25;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.ok {
  color: #0d5130;
  background: #dbf3e4;
}

.pill.warn {
  color: #744d00;
  background: #fff0c7;
}

.pill.danger {
  color: #842832;
  background: #ffe0e3;
}

.pill.neutral {
  color: #34515d;
  background: #e4edf0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-session-box {
  display: grid;
  gap: 12px;
  padding: 14px 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.ai-session-box h4 {
  margin-top: 2px;
  font-size: 16px;
}

.consent-row {
  grid-template-columns: auto 1fr;
  align-items: start;
  color: var(--text);
  line-height: 1.45;
}

.consent-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.ai-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.booking-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.ai-session-box audio {
  width: 100%;
}

.ai-session-box textarea {
  min-height: 104px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.full-span {
  grid-column: 1 / -1;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
  font-weight: 800;
  font-size: 12px;
}

.segmented button.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(28, 42, 48, 0.12);
}

.schedule-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-label {
  min-width: 220px;
  max-width: 260px;
}

.compact-label select {
  min-height: 38px;
  padding-block: 8px;
}

.service-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.service-summary span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.doc-grid {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.clinical-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.doc-check {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #f8fafb;
  border: 1px solid var(--line);
}

.doc-check button {
  border: 0;
  border-radius: 6px;
  min-width: 74px;
  padding: 7px 10px;
  color: #ffffff;
  background: var(--muted);
}

.doc-check.done button {
  background: var(--ok);
}

.note-card {
  border-left: 4px solid var(--primary);
}

.clinical-record {
  display: grid;
  gap: 14px;
}

.print-header {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #f9fbfc;
}

.print-header h2 {
  margin: 0 0 6px;
}

.print-header p {
  margin: 0;
  color: var(--muted);
}

.record-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.record-section h3 {
  font-size: 16px;
}

.record-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.check-grid,
.score-grid,
.signature-grid {
  display: grid;
  gap: 10px;
}

.check-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.score-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #f9fbfc;
}

.check-label input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.record-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 12px;
}

.record-table th,
.record-table td {
  border: 1px solid var(--line);
  padding: 8px;
  vertical-align: top;
}

.record-table th {
  background: var(--surface-2);
  text-align: left;
}

.record-table input {
  min-width: 82px;
  padding: 7px 8px;
  border-radius: 6px;
}

.compact-table .record-table {
  min-width: 520px;
}

.signature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.signature-block {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f9fbfc;
}

.signature-line {
  min-height: 54px;
  display: flex;
  align-items: end;
  color: var(--muted);
  border-bottom: 1px solid var(--text);
  padding-bottom: 6px;
}

.record-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  position: sticky;
  bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.inline-actions {
  position: static;
  justify-content: flex-start;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.therapy-session-stack {
  display: grid;
  gap: 14px;
}

.therapy-session-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.therapy-session-card h4 {
  margin: 0;
}

.print-footer {
  display: none;
}

.report-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.design-preview {
  min-height: 260px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 24px;
}

.design-preview img {
  width: min(280px, 100%);
  max-height: 160px;
  object-fit: contain;
}

.design-preview strong {
  font-size: 24px;
}

.design-preview span {
  color: var(--muted);
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e4eaee;
  overflow: hidden;
  margin-top: 12px;
}

.bar-fill {
  height: 100%;
  width: var(--value);
  background: var(--primary);
}

dialog {
  width: min(620px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(10, 20, 25, 0.45);
}

.booking-card {
  padding: 24px;
  position: relative;
}

.booking-card h3 {
  margin: 0 0 8px;
  font-size: 28px;
}

.close-btn {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  cursor: pointer;
}

.public-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.public-slots button {
  border: 1px solid var(--line);
  background: #f9fbfc;
  border-radius: 8px;
  padding: 12px;
}

.public-slots button.active,
.public-slots button:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, #ffffff);
}

.wallet-brick {
  margin-top: 14px;
}

.wallet-brick[hidden] {
  display: none;
}

.wallet-fallback {
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

@media (max-width: 980px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .psychologist-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero-product,
  .two-col,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-panel,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-head,
  .row-top {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .segmented,
  .schedule-controls,
  .compact-label {
    width: 100%;
  }

  .topbar-actions > *,
  .segmented button {
    flex: 1;
  }

  .form-grid,
  .calendar-head,
  .calendar-grid,
  .public-slots,
  .ai-controls,
  .booking-actions,
  .psychologist-card,
  .record-grid,
  .check-grid,
  .score-grid,
  .signature-grid {
    grid-template-columns: 1fr;
  }

  .hero-product h3 {
    font-size: 28px;
  }

  .nav-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 641px) and (max-width: 1120px) {
  .record-grid,
  .check-grid,
  .score-grid,
  .signature-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media print {
  @page {
    margin: 12mm;
  }

  body,
  .main-panel {
    background: #ffffff;
    padding: 0;
  }

  .sidebar,
  .topbar,
  .no-print,
  #noteForm,
  .record-actions {
    display: none !important;
  }

  .app-shell,
  .content-grid,
  .two-col {
    display: block;
  }

  .panel {
    border: 0;
    padding: 0;
  }

  .clinical-record {
    gap: 8px;
    color: #000000;
  }

  .print-header,
  .record-section,
  .signature-block {
    border-color: #9aa2a8;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .therapy-session-card {
    background: #ffffff;
    border-color: #9aa2a8;
    page-break-inside: avoid;
  }

  .record-grid,
  .check-grid,
  .score-grid,
  .signature-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  input,
  select,
  textarea,
  .check-label {
    border-color: #b9c0c5;
    background: #ffffff;
  }

  .table-wrap {
    overflow: visible;
  }

  .record-table {
    min-width: 0;
    font-size: 10px;
  }

  .record-table input {
    min-width: 0;
    padding: 3px;
  }

  .print-footer {
    display: block;
    margin-top: 14px;
    color: #333333;
    font-size: 11px;
  }
}
