:root {
  --aqua: #6ec9d6;
  --aqua-dark: #2f9ead;
  --aqua-soft: #eafbfe;
  --navy: #113a46;
  --muted: #5a7d86;
  --line: rgba(85, 154, 169, 0.2);
  --surface: rgba(255, 255, 255, 0.84);
  --white: #fff;
  --green: #26b99a;
  --yellow: #f5a623;
  --red: #e45656;
  --shadow: 0 22px 60px rgba(8, 61, 74, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--navy);
  font-family: Inter, Arial, sans-serif;
  background:
    linear-gradient(90deg, rgba(255,255,255,.2), rgba(255,255,255,.9)),
    url("assets/backgrounds/clinic_soft.png") center / cover fixed;
}

body:not(.authenticated) {
  overflow: hidden;
}

body:not(.authenticated) .shell {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  align-items: center;
  gap: 32px;
  padding: clamp(24px, 5vw, 72px);
  background:
    linear-gradient(90deg, rgba(255,255,255,.92) 0%, rgba(255,255,255,.82) 48%, rgba(234,251,254,.54) 100%),
    url("assets/backgrounds/login_finance_soft.png") center / cover no-repeat;
}

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

.login-content {
  display: grid;
  gap: 22px;
  max-width: 760px;
}

.login-logo {
  width: min(300px, 72vw);
}

.login-copy h1 {
  margin: 0 0 18px;
  color: #0f2f3d;
  font-size: clamp(38px, 5vw, 68px);
  line-height: .95;
  font-weight: 900;
  letter-spacing: 0;
}

.login-kicker {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 10px;
  padding: 7px 11px;
  border: 1px solid rgba(47,158,173,.24);
  border-radius: 999px;
  color: var(--aqua-dark);
  background: rgba(255,255,255,.72);
  font-weight: 800;
}

.login-feature-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px 22px;
  max-width: 720px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #244c58;
  font-weight: 800;
}

.login-feature-list li {
  position: relative;
  padding-left: 28px;
}

.login-feature-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  background: linear-gradient(135deg, #6ec9d6, #2f9ead);
}

.login-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid rgba(255,255,255,.84);
  border-radius: 12px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 30px 90px rgba(8, 61, 74, .18);
  backdrop-filter: blur(18px);
}

.login-card h2 {
  margin: 8px 0 0;
  font-size: 27px;
}

.login-card p {
  margin: 0 0 4px;
  color: var(--muted);
}

.login-card small {
  color: var(--muted);
}

.login-submit {
  min-height: 48px;
}

.login-orb {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  margin: -78px auto 0;
  border-radius: 50%;
  color: #d9fbff;
  font-size: 54px;
  background:
    radial-gradient(circle at 50% 42%, rgba(105,241,255,.98), rgba(34,136,166,.92) 42%, rgba(5,38,58,.96) 72%),
    #083042;
  box-shadow:
    0 0 34px rgba(72, 210, 228, .55),
    inset 0 0 24px rgba(255,255,255,.26);
}

.login-orb span {
  display: grid;
  place-items: center;
  width: 66px;
  height: 86px;
  border: 3px solid rgba(219, 251, 255, .95);
  border-radius: 50% 50% 44% 44%;
  text-shadow: 0 0 14px #62efff;
}

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

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  padding: 28px;
  gap: 24px;
  transition: grid-template-columns .22s ease;
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100vh - 56px);
  padding: 24px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 24px 80px rgba(38, 120, 140, 0.12);
  backdrop-filter: blur(18px);
}

.sidebar-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--aqua-dark);
  background: rgba(255,255,255,.88);
  box-shadow: 0 10px 24px rgba(8, 61, 74, 0.08);
  z-index: 2;
}

.sidebar-collapsed .shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

.sidebar-collapsed .sidebar {
  padding: 68px 14px 18px;
  align-items: center;
}

.sidebar-collapsed .brand img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  object-position: left center;
}

.sidebar-collapsed .platform-title,
.sidebar-collapsed .platform-copy,
.sidebar-collapsed .module-button:not(.active),
.sidebar-collapsed .module-button.active,
.sidebar-collapsed .compliance-card div:not(.shield) {
  font-size: 0;
}

.sidebar-collapsed .module-button {
  justify-content: center;
  padding: 10px;
}

.sidebar-collapsed .compliance-card {
  padding: 10px;
  width: 54px;
  justify-content: center;
  overflow: hidden;
}

.sidebar-collapsed .shield {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  font-size: 14px;
}

.brand img {
  width: 240px;
  max-width: 100%;
  display: block;
}

.platform-title {
  margin: 12px 0 0;
  font-size: 25px;
  line-height: 1.12;
  font-weight: 800;
  color: #0f2f3d;
}

.platform-copy {
  margin: -8px 0 8px;
  color: var(--muted);
  line-height: 1.55;
}

.module-list {
  display: grid;
  gap: 9px;
}

.module-button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 48px;
  padding: 11px 15px;
  border: 1px solid rgba(86, 157, 170, 0.18);
  border-radius: 8px;
  color: #287e8e;
  font-weight: 700;
  text-align: left;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 8px 22px rgba(15, 62, 76, 0.08);
}

.module-button:hover,
.module-button.active {
  color: #fff;
  background: linear-gradient(135deg, #6ec9d6, #2f9ead);
}

.module-button img,
.module-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.module-button.active img,
.module-button:hover img {
  filter: brightness(0) invert(1);
}

.grid-icon,
.settings-icon {
  display: inline-grid;
  place-items: center;
  color: currentColor;
}

.follow-icon {
  display: inline-grid;
  place-items: center;
  color: currentColor;
}

.follow-icon::before {
  content: "↻";
  font-size: 23px;
}

.grid-icon::before {
  content: "▦";
  font-size: 23px;
}

.settings-icon::before {
  content: "⚙";
  font-size: 23px;
}

.compliance-card {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
}

.shield {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #31c5cf, #34b58e);
}

.compliance-card strong,
.compliance-card span {
  display: block;
}

.compliance-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 16px;
  z-index: 5;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 8px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 14px 45px rgba(8, 61, 74, 0.12);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.utilitybar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: -6px 0 18px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 8px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 12px 32px rgba(8, 61, 74, 0.09);
  backdrop-filter: blur(18px);
}

.utilitybar .search {
  min-width: min(420px, 62vw);
}

.top-tabs,
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.top-tabs {
  overflow-x: auto;
}

.top-actions {
  flex-shrink: 1;
}

.top-tab,
.icon-button,
.profile,
.pill-button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--navy);
}

.top-tab {
  padding: 10px 13px;
  color: #315b66;
  font-weight: 700;
  white-space: nowrap;
}

.top-tab.active,
.top-tab:hover {
  color: var(--aqua-dark);
  background: #eefbfc;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--navy);
}

.icon-button {
  width: 38px;
  height: 38px;
  border-color: var(--line);
  color: var(--aqua-dark);
  background: #fff;
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px 5px 5px;
  border-color: var(--line);
  background: #fff;
  text-align: left;
  font-weight: 800;
  min-width: 0;
}

.profile small {
  display: block;
  color: var(--muted);
  font-weight: 500;
}

.profile span:last-child {
  min-width: 0;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #18394a, var(--aqua));
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeUp .22s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin: 12px 0 16px;
}

.view-header h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: 0;
}

.view-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.date-chip,
.status-chip,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.date-chip {
  border: 1px solid var(--line);
  color: #396775;
  background: rgba(255,255,255,.76);
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.dashboard-grid {
  grid-template-columns: 1.15fr .9fr .72fr;
  align-items: start;
}

.dashboard-main-row {
  grid-template-columns: minmax(260px, 1.05fr) minmax(320px, 1.15fr) minmax(250px, .9fr);
  align-items: stretch;
}

.dashboard-clinical-card {
  margin-top: 16px;
}

.clinical-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, .8fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: start;
}

.clinical-dashboard-grid h3 {
  margin: 0 0 8px;
}

.clinical-dashboard-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.clinical-rx-strip {
  grid-template-columns: repeat(3, minmax(70px, 1fr));
}

.clinical-rx-strip .rx-thumb {
  min-height: 96px;
}

.clinical-timeline {
  align-self: stretch;
}

.wide-dashboard {
  grid-template-columns: 1fr 1fr .9fr .85fr;
}

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

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

.card,
.metric-card,
.panel {
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 45px rgba(8, 61, 74, 0.1);
  backdrop-filter: blur(18px);
}

.card,
.panel {
  padding: 18px;
  min-width: 0;
}

.metric-card {
  display: flex;
  justify-content: space-between;
  min-height: 94px;
  padding: 16px;
}

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

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 25px;
}

.metric-card small {
  color: var(--green);
  font-weight: 800;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: var(--aqua-dark);
  font-size: 23px;
  background: #ddf6f9;
}

.card-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 900;
}

.link-button {
  border: 0;
  color: var(--aqua-dark);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.patient-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 15px;
}

.patient-photo {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border-radius: 8px;
  color: #fff;
  font-size: 30px;
  font-weight: 900;
  background: linear-gradient(135deg, #35b7c6, #9de6e7);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
}

.patient-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.patient-meta {
  display: grid;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.patient-layout {
  grid-template-columns: minmax(520px, 1.25fr) minmax(340px, .75fr);
  align-items: start;
}

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

.selected-row {
  background: rgba(110, 201, 214, .1);
}

.profile-actions {
  margin-top: 14px;
}

.file-button input {
  display: none;
}

.contact-list,
.document-list {
  display: grid;
  gap: 10px;
}

.contact-card,
.document-row,
.treatment-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.62);
}

.contact-card strong,
.document-row strong,
.treatment-summary strong {
  display: block;
}

.contact-card small,
.document-row small,
.treatment-summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.file-icon {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  background: linear-gradient(135deg, #42c2cf, #2f9ead);
}

.slim {
  min-height: 78px;
}

.treatment-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.52);
}

.compact-table th,
.compact-table td {
  padding: 9px 8px;
}

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

.info-box {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.64);
  font-size: 12px;
}

.info-box strong {
  display: block;
  color: var(--navy);
  font-size: 13px;
}

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

.rx-thumb {
  min-height: 78px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 48% 35%, rgba(255,255,255,.6), rgba(21,58,72,.35) 28%, rgba(9,22,31,.88) 70%),
    linear-gradient(135deg, #162937, #5d8794);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 18px;
  border: 2px dashed #8ad8e1;
  border-radius: 8px;
  color: var(--aqua-dark);
  text-align: center;
  background: rgba(255,255,255,.55);
}

.timeline {
  display: grid;
  gap: 11px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.timeline li:last-child {
  border-bottom: 0;
}

.dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  background: var(--aqua-dark);
  font-size: 12px;
  font-weight: 900;
}

.status-chip.ok,
.badge.ok {
  color: #0f8a68;
  background: #daf8ee;
}

.status-chip.pending,
.badge.pending {
  color: #946200;
  background: #fff1ce;
}

.status-chip.warn,
.badge.warn {
  color: #b64040;
  background: #ffe4e4;
}

.treatment-list,
.payment-list,
.doctor-list,
.audit-list {
  display: grid;
  gap: 10px;
}

.line-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.line-item:last-child {
  border-bottom: 0;
}

.line-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--aqua-dark);
  background: #e4f9fb;
}

.money {
  font-weight: 900;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #d7edf1;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #31c5cf, #26b99a);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 9px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.active {
  color: var(--aqua-dark);
  border-color: var(--aqua);
}

.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-button {
  padding: 10px 13px;
  border-color: var(--line);
  color: var(--aqua-dark);
  background: #fff;
  font-weight: 800;
}

.pill-button.primary {
  color: #fff;
  background: linear-gradient(135deg, #48bcc8, #2f9ead);
  border-color: transparent;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: 0;
  color: var(--navy);
  background: rgba(255,255,255,.84);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

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

.agenda-layout {
  grid-template-columns: minmax(330px, .8fr) minmax(330px, .8fr);
  align-items: start;
}

.schedule.compact .slot {
  grid-template-columns: 54px minmax(0, 1fr);
}

.schedule.compact .slot .badge {
  display: none;
}

.dashboard-agenda-card .calendar {
  gap: 5px;
}

.dashboard-agenda-card .day {
  min-height: 30px;
  font-size: 12px;
}

.day {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.62);
}

.day.active {
  color: #fff;
  background: linear-gradient(135deg, #58c3d0, #2f9ead);
}

.day.pending-day {
  color: #7a5500;
  border-color: rgba(245, 166, 35, .5);
  background: #fff1ce;
}

.day.confirmed-day {
  color: #087d61;
  border-color: rgba(38, 185, 154, .45);
  background: #daf8ee;
}

.legend {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.pending {
  background: var(--yellow);
}

.legend-dot.ok {
  background: var(--green);
}

.icon-mini {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #0f8a68;
  background: #e5fbf4;
  font-weight: 900;
}

.icon-mini.danger {
  color: #b64040;
  background: #ffe4e4;
}

.schedule {
  display: grid;
  gap: 9px;
}

.slot {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.68);
}

.slot strong {
  color: var(--aqua-dark);
}

.chart-bars {
  display: flex;
  align-items: end;
  gap: 9px;
  height: 160px;
  padding-top: 12px;
}

.bar {
  flex: 1;
  min-width: 20px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #5ec8d4, #b9eff2);
}

.donut {
  --p: 72%;
  display: grid;
  place-items: center;
  width: 158px;
  height: 158px;
  border-radius: 50%;
  margin: 12px auto;
  background: conic-gradient(#2f9ead 0 42%, #26b99a 42% 67%, #f5a623 67% 82%, #e45656 82% 100%);
}

.donut::before {
  content: attr(data-label);
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  color: var(--navy);
  font-weight: 900;
  background: #fff;
  text-align: center;
}

.doc-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.doc-card {
  min-height: 176px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(238,250,252,.82)),
    url("assets/backgrounds/fondo_wellness.svg") center / cover;
}

.doc-card strong {
  display: block;
  color: var(--aqua-dark);
  text-transform: uppercase;
  font-size: 12px;
}

.doc-line {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: #d6e8ed;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) repeat(5, 74px);
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.toggle {
  width: 46px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: #c7d6dc;
  position: relative;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: .2s;
}

.toggle.on {
  background: var(--aqua-dark);
}

.toggle.on::after {
  left: 24px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 58, 70, .28);
  backdrop-filter: blur(12px);
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(237,251,253,.92)),
    url("assets/backgrounds/fondo_clean_medical.svg") center / cover;
  box-shadow: 0 30px 90px rgba(8, 61, 74, .26);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  padding: 18px;
}

.modal-note {
  margin: 12px 0 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 10;
  max-width: 360px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--navy);
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s;
}

.toast.show {
  opacity: 1;
  transform: none;
}

@media (max-width: 1280px) {
  .shell {
    grid-template-columns: 270px minmax(0, 1fr);
    padding: 18px;
  }

  .metrics,
  .dashboard-grid,
  .dashboard-main-row,
  .clinical-dashboard-grid,
  .wide-dashboard,
  .three-col,
  .doc-gallery,
  .patient-layout,
  .agenda-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 860px) {
  .shell {
    display: block;
    padding: 12px;
  }

  .sidebar {
    min-height: auto;
    margin-bottom: 14px;
  }

  .module-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-tabs {
    overflow-x: auto;
  }

  .topbar {
    overflow: hidden;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .search {
    min-width: 100%;
  }

  .utilitybar {
    width: 100%;
  }

  .utilitybar .search {
    flex: 1 1 auto;
    min-width: 0;
  }

  .metrics,
  .dashboard-grid,
  .dashboard-main-row,
  .clinical-dashboard-grid,
  .wide-dashboard,
  .two-col,
  .three-col,
  .doc-gallery,
  .form-grid,
  .patient-layout,
  .agenda-layout {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .view-header {
    flex-direction: column;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    max-width: 100%;
  }

  .patient-directory,
  .card:has(.table) {
    overflow-x: auto;
  }

  .contact-card,
  .document-row,
  .treatment-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .slot {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .slot .badge {
    justify-self: start;
  }

  .sidebar-collapsed .shell {
    display: block;
  }

  .sidebar-collapsed .sidebar {
    align-items: stretch;
  }

  .permission-row {
    grid-template-columns: 1fr repeat(3, 58px);
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 8px;
  }

  .sidebar,
  .topbar,
  .card,
  .metric-card {
    border-radius: 8px;
  }

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

  .patient-card {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .patient-photo {
    width: 70px;
    height: 70px;
    font-size: 22px;
  }

  .calendar {
    gap: 5px;
  }

  .day {
    min-height: 34px;
    font-size: 12px;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal-card {
    max-height: calc(100vh - 20px);
  }
}

@media (max-width: 920px) {
  .login-screen {
    grid-template-columns: 1fr;
    overflow: auto;
    align-items: start;
  }

  body:not(.authenticated) {
    overflow: auto;
  }

  .login-card {
    margin-top: 52px;
  }
}

@media (max-width: 640px) {
  .login-screen {
    padding: 18px;
  }

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

  .login-copy h1 {
    font-size: 38px;
  }
}
