:root {
  --bg: #081b2d;
  --bg-alt: #102b44;
  --surface: #123456;
  --surface-soft: #1c4f7d;
  --panel: #ffffff;
  --panel-alt: #f3f8ff;
  --line: rgba(18, 59, 99, 0.12);
  --primary: #1c6fcb;
  --primary-dark: #1453a3;
  --primary-light: #eaf4ff;
  --accent: #d5ebff;
  --text: #10253d;
  --muted: #59718e;
  --success: #1b7bc3;
  --warning: #f0b429;
  --danger: #d75d5d;
  --radius: 18px;
  --shadow: 0 18px 45px rgba(17, 47, 80, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: linear-gradient(180deg, #edf8f5, #f4f7f6 40%, #edf5f9);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

a { color: inherit; text-decoration: none; }

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

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  background: linear-gradient(135deg, #0a1f34 0%, #123b67 42%, #0d2e4d 100%);
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 12px 24px rgba(10, 31, 52, 0.18);
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 76px;
  gap: 20px;
}

.brand {
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

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

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.92rem;
  color: rgba(255,255,255,0.85);
}

.nav-links a:hover {
  color: white;
}

.page-shell {
  padding: 42px 0 64px;
}

.card {
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 30px;
  padding: 30px;
  background: linear-gradient(135deg, rgba(28,111,203,0.1), rgba(213,235,255,0.25), rgba(242,247,255,0.9));
  border: 1px solid rgba(20,83,163,0.12);
  border-radius: 28px;
  margin-bottom: 28px;
  box-shadow: 0 24px 60px rgba(17, 47, 80, 0.08);
}

.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary-dark);
  background: rgba(28,111,203,0.1);
  padding: 8px 12px;
  border-radius: 999px;
}

.hero h1 {
  font-size: clamp(2.1rem, 4vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.06em;
  margin: 18px 0 16px;
}

.lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0;
}

.hero-points {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.mini-stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.mini-stat strong {
  display: block;
  font-size: 1.8rem;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.login-box {
  padding: 30px 26px;
  background: rgba(255,255,255,0.96);
  border-radius: 24px;
  border: 1px solid rgba(20,83,163,0.1);
  box-shadow: 0 22px 60px rgba(18, 36, 33, 0.12);
}

.login-box h2,
.section-title h2,
.section-title h3 {
  margin-top: 0;
}

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

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

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(18, 59, 99, 0.1);
}

.section-title h2,
.section-title h3,
.section-title h4 {
  margin: 0;
  letter-spacing: -0.04em;
  color: var(--text);
}

.section-title h2 {
  font-size: clamp(1.6rem, 2vw, 2.2rem);
}

.section-title h3 {
  font-size: 1.2rem;
}

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

.field label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  background: linear-gradient(180deg, #ffffff, #f6fbff);
  border: 1px solid rgba(18, 59, 99, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(16, 37, 61, 0.03);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(28,111,203,0.12);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--small {
  padding: 10px 14px;
  font-size: 0.82rem;
}

.btn--secondary {
  background: linear-gradient(135deg, #2b7de9, #1b62c6);
}

.btn--ghost {
  background: transparent;
  border: 1px solid rgba(28,111,203,0.3);
  color: var(--primary-dark);
}

.btn--danger {
  background: linear-gradient(135deg, var(--danger), #b44343);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(12, 51, 87, 0.04), rgba(28, 111, 203, 0.08));
  box-shadow: 0 10px 22px rgba(16, 37, 61, 0.06);
}

.quick-actions .btn {
  min-width: 155px;
  box-shadow: 0 12px 18px rgba(28, 111, 203, 0.12);
}

.quick-actions--compact {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.quick-actions--compact .btn {
  min-width: auto;
  box-shadow: none;
}

.section-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.summary-card {
  padding: 22px 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
}

.summary-card .label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.8rem, 2vw, 2.4rem);
  color: var(--primary-dark);
}

.content-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  align-items: start;
}

.list-panel,
.detail-panel,
.patient-panel,
.history-panel {
  padding: 24px;
  border-radius: 22px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.patient-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.patient-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f7fbfa);
}

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

.patient-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.action-dropdown {
  position: relative;
}

.action-dropdown summary {
  list-style: none;
  cursor: pointer;
}

.action-dropdown summary::-webkit-details-marker {
  display: none;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  display: flex;
  flex-direction: column;
  min-width: 220px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
  z-index: 20;
}

.dropdown-menu a {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
}

.dropdown-menu a:hover {
  background: var(--panel-alt);
  color: var(--primary-dark);
}

.new-patient-panel {
  display: block;
  margin-top: 20px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
}

.new-patient-panel summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  font-weight: 800;
  color: var(--primary-dark);
}

.new-patient-panel summary::-webkit-details-marker {
  display: none;
}

.new-patient-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.new-patient-panel .details-body {
  padding: 22px 20px 20px;
}

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

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

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-weight: 600;
}

.alert--success {
  background: rgba(27,123,195,0.1);
  border: 1px solid rgba(27,123,195,0.24);
  color: var(--success);
}

.alert--error {
  background: rgba(215,93,93,0.08);
  border: 1px solid rgba(215,93,93,0.2);
  color: var(--danger);
}

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

.kv-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-alt);
}

.kv-item span {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.kv-item strong {
  display: block;
  margin-top: 5px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  display: block;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #ffffff, #f5faf9);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.history-item--link:hover {
  transform: translateY(-1px);
  border-color: rgba(28, 111, 203, 0.4);
  box-shadow: 0 8px 18px rgba(28, 111, 203, 0.08);
}

.history-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-item h4 {
  margin: 0;
  font-size: 1.05rem;
}

.history-item .date {
  color: var(--muted);
  font-size: 0.85rem;
}

.history-item__action {
  margin-top: 10px;
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-box {
  display: grid;
  gap: 16px;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fbfdfc;
}

.detail-card label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.doctor-preview {
  text-align: center;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f5faf9);
}

.doctor-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff, #eefaf3);
  box-shadow: 0 12px 28px rgba(22, 62, 52, 0.08);
}

.doctor-header h3,
.doctor-header p {
  margin: 0;
}

.doctor-header h3 {
  font-size: 1.6rem;
  letter-spacing: -0.04em;
}

.doctor-header p {
  color: var(--muted);
  margin-top: 4px;
}

.doctor-logo {
  display: block;
  max-width: 160px;
  max-height: 140px;
  object-fit: contain;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--line);
  padding: 8px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(20,83,163,0.12);
}

.login-brand h3,
.login-brand p {
  margin: 0;
}

.login-brand p {
  color: var(--muted);
  font-size: 0.88rem;
}

@media print {
  body {
    background: white;
    color: black;
    font-size: 11.5pt;
    margin: 0.35cm;
  }

  .container {
    width: 100%;
    max-width: none;
  }

  .topbar,
  .nav-links,
  .btn,
  .alert,
  .quick-actions,
  .doctor-preview .btn,
  .print-actions {
    display: none !important;
  }

  .page-shell {
    padding-top: 0;
    padding-bottom: 0;
  }

  .hero,
  .card,
  .list-panel,
  .detail-panel,
  .patient-panel,
  .history-panel,
  .doctor-header,
  .summary-card,
  .patient-item,
  .history-item,
  .detail-card,
  .kv-item {
    box-shadow: none !important;
    border: 1px solid #d8dfe0;
    background: white !important;
    break-inside: avoid;
  }

  .doctor-header {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  .doctor-logo {
    max-width: 90px;
    max-height: 68px;
    padding: 6px;
  }

  .doctor-header h3 {
    font-size: 16pt;
  }

  .section-title {
    margin-bottom: 8px;
    gap: 8px;
  }

  .section-title h2,
  .section-title h3,
  .section-title h4 {
    margin-bottom: 0;
  }

  .detail-box,
  .history-list,
  .kv-grid,
  .content-grid,
  .section-row,
  .patient-list {
    gap: 8px !important;
  }

  .detail-card,
  .kv-item,
  .history-item,
  .patient-item,
  .summary-card {
    padding: 8px 10px !important;
  }

  .history-item header {
    margin-bottom: 6px;
  }

  .detail-box {
    display: grid;
    gap: 8px;
  }

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

  .history-item,
  .kv-item,
  .detail-card,
  .patient-item {
    break-inside: avoid;
  }
}

@media (max-width: 860px) {
  .hero,
  .content-grid,
  .section-row,
  .form-row,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    flex-direction: column;
    justify-content: center;
    padding: 14px 0;
  }

  .nav-links {
    justify-content: center;
    flex-wrap: wrap;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
