:root {
  --bg: #f5f7fb;
  --bg-soft: #edf3f8;
  --panel: #ffffff;
  --panel-alt: #f8fafc;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0f9f7a;
  --text: #111827;
  --muted: #64748b;
  --border: #d8e0ea;
  --border-soft: #edf1f6;
  --danger: #dc2626;
  --warning: #c27803;
  --sidebar: #0f172a;
  --sidebar-2: #17324d;
  --shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html {
  width: 100%;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(237, 243, 248, 0.78), rgba(245, 247, 251, 0.92)),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
  max-width: 100%;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

button {
  overflow-wrap: anywhere;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.primary-btn:hover,
.action-btn:hover,
.logout-btn:hover,
.menu-toggle:hover {
  transform: translateY(-1px);
}

.primary-btn:active,
.action-btn:active,
.logout-btn:active,
.menu-toggle:active {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(160deg, rgba(15, 159, 122, 0.12), transparent 42%),
    linear-gradient(135deg, #f8fbff 0%, #e7eff8 100%);
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(216, 224, 234, 0.9);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(10px);
}

.login-card {
  padding: 34px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand h1,
.login-brand h2,
.brand h1 {
  margin: 0;
  letter-spacing: 0;
}

.login-brand h2 {
  font-size: 1.55rem;
  line-height: 1.15;
}

.login-brand h1 {
  font-size: 1.55rem;
  line-height: 1.15;
}

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

.login-card form {
  display: grid;
  gap: 16px;
}

.login-card .primary-btn {
  margin-top: 4px;
}

.full-width-btn {
  width: 100%;
}

.app-shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 268px;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  flex: 0 0 268px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(23, 50, 77, 0.98) 100%);
  color: white;
  padding: 22px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 22px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand > div:nth-child(2) {
  flex: 1;
}

.brand-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--primary);
  overflow: hidden;
  box-shadow: 0 12px 26px rgba(15, 159, 122, 0.24);
}

.brand-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand-icon .icon {
  width: 23px;
  height: 23px;
  stroke-width: 2.4;
}

.brand h1 {
  font-size: 1.08rem;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.brand p {
  color: rgba(255, 255, 255, 0.64);
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  cursor: pointer;
}

.menu-toggle .close-icon {
  display: none;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 12px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  padding: 12px 13px;
  text-align: left;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  overflow-wrap: anywhere;
  overflow: hidden;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.13);
  color: white;
  box-shadow: none;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.nav-link:not(.active):hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}

.content {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 38px);
  overflow: hidden;
}

.view {
  display: none;
  max-width: 1480px;
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin: 0 0 24px;
  padding: 18px 0;
  background: rgba(245, 247, 251, 0.9);
  border-bottom: 1px solid rgba(216, 224, 234, 0.7);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar h2 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-pill,
.logout-btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 800;
}

.logout-btn,
.primary-btn,
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.header-pill {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  padding: 0 14px;
  box-shadow: var(--shadow-soft);
  color: var(--muted);
}

.logout-btn {
  border: 1px solid rgba(37, 99, 235, 0.16);
  background: #eef5ff;
  color: var(--primary-dark);
  padding: 0 14px;
  cursor: pointer;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  position: relative;
  min-height: 122px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.stat-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: color-mix(in srgb, currentColor 12%, white);
}

.stat-icon .icon {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.stat-card span {
  display: block;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.accent-blue { color: #2563eb; }
.accent-green { color: #0f9f7a; }
.accent-purple { color: #7c3aed; }
.accent-orange { color: #c27803; }

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

.panel,
.form-card,
.table-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

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

.date-wise-list {
  max-height: 330px;
  overflow: auto;
  padding-right: 4px;
}

.panel {
  padding: 17px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel-header h3,
.section-header h3 {
  margin: 0;
  font-size: 1.04rem;
  letter-spacing: 0;
}

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

.report-controls {
  flex-wrap: wrap;
}

.report-table {
  margin-top: 18px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.list-item strong {
  display: block;
  margin-bottom: 3px;
}

.list-item small {
  color: var(--muted);
}

.form-card {
  padding: 18px;
  margin-bottom: 18px;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #475569;
  font-size: 0.86rem;
  font-weight: 800;
}

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

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.form-actions .primary-btn {
  margin-top: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b7c6d7;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.setup-preview {
  position: sticky;
  top: 96px;
}

.clinic-preview-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--panel-alt);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px;
}

.clinic-logo-preview {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  color: var(--primary);
}

.clinic-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.clinic-preview-card strong {
  display: block;
  font-size: 1.08rem;
  margin-bottom: 4px;
}

.clinic-preview-card small,
.clinic-preview-card p {
  color: var(--muted);
}

.clinic-preview-card p {
  margin: 10px 0 0;
  line-height: 1.5;
}

.logo-upload-panel {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px dashed #b8c7d9;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f6f9fd);
}

.logo-upload-preview {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  color: var(--primary);
  box-shadow: inset 0 0 0 6px #f8fafc;
}

.logo-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-upload-copy {
  display: grid;
  gap: 7px;
}

.logo-upload-copy strong {
  color: var(--text);
  font-size: 1rem;
}

.logo-upload-copy span {
  color: var(--muted);
  font-size: 0.88rem;
}

.logo-upload-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.upload-btn,
.ghost-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 0 13px;
  font-size: 0.86rem;
  font-weight: 900;
  cursor: pointer;
}

.upload-btn {
  border: none;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-dark);
}

.ghost-btn {
  border: 1px solid var(--border);
  background: #ffffff;
  color: #475569;
}

.ghost-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.appointment-controls,
.filter-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.filter-btn {
  min-height: 36px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #475569;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-dark);
}

.appointment-date-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.appointment-date-controls label {
  width: 150px;
}

.filter-field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.report-filter-controls .filter-field-grid {
  grid-template-columns: repeat(3, minmax(140px, 1fr));
}

.doctor-filter-controls .filter-field-grid {
  grid-template-columns: repeat(3, minmax(140px, 1fr));
}

.filter-count {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.doctor-analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.doctor-metric-card {
  min-height: 108px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 15px;
  box-shadow: var(--shadow-soft);
}

.doctor-metric-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.doctor-metric-card strong {
  font-size: 1.45rem;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

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

.doctor-detail-panel {
  margin-bottom: 14px;
}

.doctor-detail-list {
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.doctor-detail-item {
  align-items: flex-start;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.primary-btn {
  min-height: 42px;
  margin-top: 16px;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

.primary-btn .icon {
  width: 17px;
  height: 17px;
  stroke-width: 2.4;
}

.primary-btn:hover {
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.table-card {
  overflow: hidden;
}

table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
}

thead {
  background: #f8fafc;
}

th,
td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

th {
  color: #475569;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  color: #243041;
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

tbody tr:hover {
  background: #fbfdff;
}

.appointments-table th:nth-child(1),
.appointments-table th:nth-child(2) {
  width: 17%;
}

.appointments-table th:nth-child(3),
.appointments-table th:nth-child(4),
.appointments-table th:nth-child(5) {
  width: 10%;
}

.appointments-table th:nth-child(6) {
  width: 15%;
}

.appointments-table th:nth-child(7) {
  width: 21%;
}

.patients-table th:nth-child(1),
.patients-table th:nth-child(5) {
  width: 20%;
}

.patients-table th:nth-child(2),
.patients-table th:nth-child(3) {
  width: 8%;
}

.patients-table th:nth-child(4),
.patients-table th:nth-child(6) {
  width: 14%;
}

.patients-table th:nth-child(7) {
  width: 16%;
}

.doctors-table th:nth-child(1),
.doctors-table th:nth-child(2) {
  width: 15%;
}

.doctors-table th:nth-child(3) {
  width: 9%;
}

.doctors-table th:nth-child(4) {
  width: 9%;
}

.doctors-table th:nth-child(5),
.doctors-table th:nth-child(6),
.doctors-table th:nth-child(7) {
  width: 8%;
}

.doctors-table th:nth-child(8) {
  width: 12%;
}

.doctors-table th:nth-child(9) {
  width: 16%;
}

.billing-table th:nth-child(1) {
  width: 22%;
}

.billing-table th:nth-child(2),
.billing-table th:nth-child(3),
.billing-table th:nth-child(5) {
  width: 13%;
}

.billing-table th:nth-child(4) {
  width: 15%;
}

.billing-table th:nth-child(6) {
  width: 24%;
}

.toolbar-row {
  margin-bottom: 16px;
}

.toolbar-row input {
  width: min(390px, 100%);
  background: #ffffff;
}

.action-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 8px;
  padding: 0 11px;
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}

.patients-table .action-btn,
.appointments-table .action-btn,
.doctors-table .action-btn {
  min-width: 82px;
}

.action-btn .icon {
  width: 15px;
  height: 15px;
  stroke-width: 2.4;
}

.action-btn.delete {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

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

.action-btn.invoice {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-dark);
}

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

.action-btn.edit {
  background: rgba(15, 159, 122, 0.1);
  color: #047857;
}

.action-btn.edit:hover {
  background: #0f9f7a;
  color: #ffffff;
}

.table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.billing-actions {
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.billing-edit-delete-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.billing-actions .action-btn {
  min-width: 82px;
}

.billing-invoice-btn {
  min-width: 92px;
}

.chart-box {
  min-height: 220px;
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 18px 4px 24px;
  overflow: hidden;
}

.chart-bar {
  flex: 1;
  min-width: 6px;
  min-height: 40px;
  position: relative;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, #38bdf8 0%, var(--primary) 100%);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

.chart-bar::before {
  content: attr(data-label);
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: normal;
}

select.badge,
.status-select {
  width: 100%;
  max-width: 160px;
  border: none;
  cursor: pointer;
  outline: none;
}

.badge.paid,
.badge.completed,
.badge.checked-in {
  background: rgba(15, 159, 122, 0.12);
  color: #08745a;
}

.badge.pending,
.badge.scheduled {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary-dark);
}

.badge.cancelled {
  background: rgba(220, 38, 38, 0.11);
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(430px, 100%);
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  background: #ffffff;
  border: 1px solid rgba(216, 224, 234, 0.9);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  animation: modalIn 0.18s ease-out;
}

.modal-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary-dark);
  font-weight: 900;
  font-size: 1.05rem;
}

.modal-card.danger .modal-icon {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}

.modal-card.success .modal-icon {
  background: rgba(15, 159, 122, 0.12);
  color: #08745a;
}

.modal-card h3 {
  margin: 2px 0 8px;
  font-size: 1.2rem;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.modal-btn {
  min-height: 40px;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
}

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

.modal-btn.secondary {
  background: #eef4ff;
  color: var(--text);
}

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

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1100;
  display: grid;
  gap: 10px;
  width: min(340px, calc(100vw - 32px));
}

.toast {
  display: grid;
  gap: 3px;
  background: #ffffff;
  border: 1px solid var(--border-soft);
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  animation: toastIn 0.2s ease-out;
}

.toast strong {
  color: var(--text);
}

.toast span {
  color: var(--muted);
  font-size: 0.92rem;
}

.toast.danger {
  border-left-color: var(--danger);
}

.toast.leaving {
  animation: toastOut 0.2s ease-in forwards;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (max-width: 1100px) {
  .sidebar {
    width: 236px;
    flex-basis: 236px;
  }

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

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

@media (max-width: 920px) {
  .app-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .sidebar {
    position: relative;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 0;
    flex-basis: auto;
    padding: 16px;
    border-right: none;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  }

  .brand {
    max-width: 100%;
    padding-bottom: 14px;
    margin-bottom: 0;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .sidebar.nav-open .menu-toggle .menu-icon {
    display: none;
  }

  .sidebar.nav-open .menu-toggle .close-icon {
    display: inline-block;
  }

  .nav {
    display: grid;
    grid-template-columns: 1fr;
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transform: translateY(-6px);
    transition: max-height 0.22s ease, opacity 0.18s ease, transform 0.18s ease, padding 0.18s ease;
  }

  .sidebar.nav-open .nav {
    max-height: min(78vh, 620px);
    overflow-y: auto;
    padding-top: 14px;
    padding-bottom: 8px;
    opacity: 1;
    transform: translateY(0);
  }

  .nav-link {
    justify-content: flex-start;
    text-align: left;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 8px;
  }

  .nav-link.active {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: none;
  }

  .nav-link:not(.active):hover {
    box-shadow: none;
  }

  .content {
    padding: 18px;
  }

  .topbar {
    position: relative;
    margin: 0 0 18px;
    align-items: flex-start;
  }

  .panel-grid,
  .form-grid,
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .appointment-controls,
  .filter-controls {
    grid-template-columns: 1fr;
  }

  .appointment-date-controls label {
    flex: 1 1 150px;
  }

  .filter-field-grid,
  .doctor-filter-controls .filter-field-grid,
  .report-filter-controls .filter-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .setup-preview {
    position: static;
  }

  .modal-card {
    grid-template-columns: 1fr;
  }

  .toast-stack {
    right: 16px;
    bottom: 16px;
  }
}

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

  .login-card {
    border-radius: 14px;
  }

  .login-card {
    padding: 24px;
  }

  .content {
    padding: 16px;
  }

  .topbar {
    margin: 0 0 16px;
    padding: 0 0 16px;
  }

  .stats-grid,
  .panel-grid,
  .form-grid {
    gap: 12px;
  }

  .stat-card {
    min-height: 106px;
    padding: 15px;
  }

  .panel,
  .form-card {
    padding: 14px;
  }

  .table-card {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
  }

  tbody tr:hover {
    background: var(--panel);
  }

  td {
    min-height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border-soft);
    word-break: break-word;
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  td .action-btn,
  td .status-select {
    margin-left: auto;
  }

  td .table-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  td .billing-actions {
    min-width: 0;
  }

  .billing-table td[data-label="Action"] {
    align-items: flex-start;
    flex-direction: column;
  }

  .billing-table td[data-label="Action"]::before {
    flex: 0 0 auto;
  }

  .billing-table td[data-label="Action"] .billing-actions {
    align-self: stretch;
    justify-content: flex-end;
    width: 100%;
  }
}

@media (max-width: 620px) {
  .login-card {
    padding: 24px;
  }

  .topbar,
  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-pill,
  .logout-btn {
    flex: 1;
    justify-content: center;
  }

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

  .nav {
    overflow: hidden;
  }

  .nav-link {
    justify-content: flex-start;
    text-align: left;
  }

  .stat-card strong {
    font-size: 1.7rem;
  }

  .billing-actions {
    gap: 6px;
  }

  .billing-actions .action-btn {
    min-width: 74px;
    padding: 0 8px;
  }

  .billing-invoice-btn {
    min-width: 86px;
  }

  .list-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .list-item > span,
  .list-item .badge {
    align-self: flex-start;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .appointment-date-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .appointment-date-controls label,
  .filter-field-grid,
  .filter-btn,
  .form-actions .primary-btn,
  .form-actions .ghost-btn {
    width: 100%;
  }

  .filter-field-grid,
  .doctor-filter-controls .filter-field-grid,
  .report-filter-controls .filter-field-grid {
    grid-template-columns: 1fr;
  }

  .doctor-analytics-grid {
    grid-template-columns: 1fr;
  }

  .modal-btn {
    width: 100%;
  }

  .logo-upload-panel {
    grid-template-columns: 1fr;
  }

  .logo-upload-preview {
    width: 100%;
    height: 120px;
  }

  .logo-upload-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .login-card {
    padding: 20px;
  }

  .login-brand,
  .brand {
    gap: 10px;
  }

  .login-brand h1 {
    font-size: 1.55rem;
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 10px;
  }

  .topbar h2 {
    font-size: 1.45rem;
  }

  .header-actions {
    gap: 8px;
  }

  .header-pill,
  .logout-btn,
  .primary-btn {
    min-height: 40px;
    font-size: 0.86rem;
  }

  .form-card,
  .panel,
  .stat-card {
    border-radius: 12px;
  }

  input,
  select,
  textarea {
    min-height: 40px;
    padding: 9px 10px;
  }

  td {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    gap: 6px;
  }

  td::before {
    flex-basis: auto;
  }

  td .action-btn,
  td .status-select {
    width: 100%;
    margin-left: 0;
  }

  .toast-stack {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}
