:root {
  --primary: #00afc4;
  --primary-dark: #007d92;
  --navy: #052f40;
  --ink: #061e2a;
  --muted: #526a75;
  --bg: #f2f6f7;
  --card: #ffffff;
  --line: #b6d2da;
  --line-strong: #86b7c3;
  --success: #10a66f;
  --warning: #f0a202;
  --danger: #d94b4b;
  --shadow: 0 18px 38px rgba(6, 30, 42, .16);
  --radius: 20px;
}
* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: hidden; }
body { margin: 0; max-width: 100%; overflow-x: hidden; font-family: "Trebuchet MS", "Segoe UI", sans-serif; color: var(--ink); background: radial-gradient(circle at top left, #d8f8fc 0, transparent 34%), linear-gradient(135deg, #f2f6f7, #eaf4f6 58%, #ffffff); }
a { color: var(--primary-dark); text-decoration: none; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 280px; background: linear-gradient(180deg, #09394a, #041f2a); color: white; padding: 24px; position: fixed; top: 0; bottom: 0; left: 0; z-index: 10; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; margin-bottom: 28px; }
.brand.center { justify-content: center; color: var(--navy); }
.brand-mark { width: 44px; height: 44px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 14px; background: url("../img/brand/kaminar-mark.svg") center/contain no-repeat; color: transparent; font-size: 0; overflow: hidden; box-shadow: 0 10px 24px rgba(0, 125, 146, .22); }
.brand-logo { display: block; width: min(320px, 100%); height: auto; }
.brand small { display: block; color: #a9f8ff; letter-spacing: 4px; font-size: 11px; }
.nav-list { display: grid; gap: 7px; padding-bottom: 112px; max-height: calc(100vh - 128px); overflow-y: auto; scrollbar-width: thin; }
.nav-section { display: block; margin: 16px 0 6px; padding: 10px 12px; color: #fff; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 900; border-radius: 14px; border: 1px solid rgba(255,255,255,.12); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.nav-section-day { background: linear-gradient(135deg, rgba(22,184,199,.34), rgba(22,184,199,.08)); }
.nav-section-clinic { background: linear-gradient(135deg, rgba(104,217,190,.30), rgba(104,217,190,.07)); }
.nav-section-admin { background: linear-gradient(135deg, rgba(122,166,255,.28), rgba(122,166,255,.07)); }
.nav-list a { color: #d8f9fb; padding: 10px 14px 10px 18px; border-radius: 14px; margin-left: 8px; }
.nav-list a:hover, .nav-list a.active { background: rgba(255,255,255,.12); color: white; }
.sidebar-footer { position: absolute; left: 24px; right: 24px; bottom: 18px; background: linear-gradient(180deg, rgba(8,39,52,0), #082734 28%); padding-top: 22px; }
.main-content { margin-left: 280px; width: calc(100% - 280px); padding: 24px; }
.topbar { height: 76px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: var(--radius); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.topbar-user { text-align: right; display: grid; }
.content-card { margin-top: 22px; background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); overflow-x: hidden; }
.menu-toggle { display: none; border: 0; background: var(--primary); color: white; border-radius: 12px; padding: 10px 12px; }
.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 { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 10px 25px rgba(6,30,42,.08); }
.metric { min-height: 112px; position: relative; overflow: hidden; }
.metric:after { content: ""; position: absolute; width: 90px; height: 90px; right: -24px; bottom: -26px; border-radius: 50%; background: rgba(22,184,199,.12); }
.metric strong { display: block; font-size: 32px; color: var(--navy); }
.metric span, .muted { color: var(--muted); }
.btn { border: 0; border-radius: 14px; padding: 11px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #04d1dc); color: white; }
.btn-dark { background: var(--navy); color: white; }
.btn-outline { border: 1px solid rgba(255,255,255,.35); color: inherit; background: transparent; }
.btn-light { background: #e2f7fa; color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.full { width: 100%; }
form .field, .field { display: grid; gap: 7px; margin-bottom: 14px; }
label { font-weight: 700; color: var(--navy); }
input, select, textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 13px; font: inherit; background: #fbfeff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0,175,196,.18); border-color: var(--primary); background: #ffffff; }
input::placeholder, textarea::placeholder { color: #8da2ab; opacity: .55; }
textarea { min-height: 110px; resize: vertical; }
table { width: 100%; border-collapse: collapse; background: white; border-radius: 16px; overflow: hidden; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--navy); background: #e3f5f8; }
.badge { display: inline-block; border-radius: 999px; padding: 5px 10px; background: #e2f7fa; color: var(--primary-dark); font-size: 12px; font-weight: 800; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.alert { padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; }
.alert-success { background: #e8fff5; color: #08794f; }
.alert-error { background: #fff0f0; color: #9b2929; }
.alert-info { background: #eafaff; color: #086679; }
.quick-fab { position: fixed; right: 28px; bottom: 28px; z-index: 1200; display: grid; justify-items: end; gap: 10px; pointer-events: none; }
.quick-fab-main { width: 62px; height: 62px; border: 0; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #58dce4); color: white; font-size: 34px; line-height: 1; font-weight: 900; box-shadow: 0 18px 38px rgba(22,184,199,.36); cursor: pointer; pointer-events: auto; transition: transform .18s ease, background .18s ease; }
.quick-fab.open .quick-fab-main { transform: rotate(45deg); background: linear-gradient(135deg, #0b6073, var(--primary-dark)); }
.quick-fab-menu { display: grid; gap: 10px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
.quick-fab.open .quick-fab-menu { opacity: 1; transform: translateY(0); pointer-events: auto; }
.quick-fab-item { display: grid; grid-template-columns: auto 52px; gap: 10px; align-items: center; justify-content: end; color: inherit; }
.quick-fab-label { background: #172832; color: #fff; border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 900; box-shadow: 0 8px 18px rgba(5,22,32,.22); white-space: nowrap; transform: translateX(8px); opacity: 0; transition: .14s ease; }
.quick-fab.open .quick-fab-label, .quick-fab-item:hover .quick-fab-label { transform: translateX(0); opacity: 1; }
.quick-fab-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #10b7ca, #42d5df); color: #fff; font-size: 14px; font-weight: 900; box-shadow: 0 12px 28px rgba(22,184,199,.30); border: 3px solid rgba(255,255,255,.78); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(440px, 100%); background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 28px; padding: 30px; box-shadow: var(--shadow); }
.small { font-size: 13px; }
.landing { background: #f7fdfe; }
.hero { min-height: 680px; padding: 24px clamp(18px, 5vw, 70px); background: radial-gradient(circle at 80% 20%, #bdfaff, transparent 28%), linear-gradient(135deg, #eafcfd, #ffffff 58%); }
.public-nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 36px; align-items: center; padding: 70px 0 40px; }
.hero h1 { font-size: clamp(36px, 6vw, 72px); line-height: .95; margin: 0 0 18px; color: var(--navy); letter-spacing: -2px; }
.hero p { font-size: 20px; color: #4e6975; }
.hero-panel { background: white; border: 1px solid var(--line); border-radius: 30px; padding: 24px; box-shadow: var(--shadow); }
.section { padding: 58px clamp(18px, 5vw, 70px); }
.section h2 { font-size: clamp(28px, 4vw, 44px); color: var(--navy); margin: 0 0 16px; }
.print-sheet { max-width: 900px; margin: 20px auto; background: white; padding: 28px; border: 1px solid #ddd; }
.patient-link, .patient-name a, .rx-patient-link, .rep-patient-link { color: var(--navy); font-weight: 650; text-decoration: none; }
.patient-link:hover, .patient-name a:hover, .rx-patient-link:hover, .rep-patient-link:hover { color: var(--primary-dark); text-decoration: underline; text-underline-offset: 3px; }
@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .print-sheet { border: 0; box-shadow: none; max-width: none; margin: 0; }
  @page { size: A5 landscape; margin: 10mm; }
}
@media (max-width: 900px) {
  .app-shell { display: block; min-height: 100vh; }
  .sidebar { width: min(86vw, 320px); transform: translateX(-105%); transition: .25s; z-index: 1500; padding: 18px; pointer-events: none; visibility: hidden; }
  .sidebar.open { transform: translateX(0); pointer-events: auto; visibility: visible; }
  body.sidebar-open { overflow: hidden; }
  .sidebar-footer { left: 18px; right: 18px; }
  .nav-list { max-height: calc(100vh - 118px); padding-bottom: 120px; }
  .main-content { margin-left: 0; width: 100%; padding: 12px; }
  .menu-toggle { display: inline-flex; }
  .grid-2, .grid-3, .grid-4, .hero-grid { grid-template-columns: 1fr; }
  .topbar { height: auto; min-height: 64px; padding: 12px; align-items: center; border-radius: 18px; }
  .topbar > div:first-of-type { min-width: 0; }
  .topbar strong, .topbar .muted { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48vw; }
  .topbar-user { font-size: 13px; max-width: 38vw; }
  .topbar-user span, .topbar-user small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .content-card { margin-top: 12px; padding: 14px; border-radius: 18px; }
  .public-nav { flex-direction: column; align-items: flex-start; }
  .quick-fab { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .quick-fab-main { width: 58px; height: 58px; }
  .quick-fab-item { grid-template-columns: auto 48px; }
  .quick-fab-icon { width: 48px; height: 48px; }
  .quick-fab:not(.open) .quick-fab-item { pointer-events: none !important; visibility: hidden !important; }
  .quick-fab.open .quick-fab-item { pointer-events: auto !important; visibility: visible !important; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .brand { margin-bottom: 18px; }
  .brand-mark { width: 40px; height: 40px; font-size: 22px; }
  .nav-section { margin-top: 12px; padding: 9px 11px; }
  .nav-list a { margin-left: 4px; padding: 11px 12px; }
  .btn { width: auto; min-height: 44px; padding: 10px 13px; border-radius: 13px; }
  .actions .btn { flex: 1 1 auto; }
  input, select, textarea { min-height: 44px; padding: 10px 12px; border-radius: 13px; }
  textarea { min-height: 92px; }
  .card { padding: 14px; border-radius: 16px; }
  .metric { min-height: 92px; }
  .metric strong { font-size: 26px; }
  table { display: block; overflow-x: auto; white-space: nowrap; border-radius: 14px; -webkit-overflow-scrolling: touch; }
  th, td { padding: 10px; }
  .quick-fab { right: 12px!important; bottom: calc(12px + env(safe-area-inset-bottom))!important; gap: 8px!important; }
  .quick-fab-menu { gap: 8px!important; }
  .quick-fab-item { grid-template-columns: minmax(0, auto) 46px!important; gap: 8px!important; max-width: calc(100vw - 24px); }
  .quick-fab-label { max-width: 190px; overflow: hidden; text-overflow: ellipsis; padding: 8px 10px!important; font-size: 12px!important; }
  .quick-fab-icon { width: 46px!important; height: 46px!important; border-width: 2px!important; }
  .quick-fab-main { width: 56px!important; height: 56px!important; font-size: 30px!important; touch-action: manipulation; }
  .hero { min-height: auto; padding: 18px; }
  .hero-grid { padding: 36px 0 24px; }
  .hero h1 { letter-spacing: -1px; }
  .hero-panel { padding: 18px; border-radius: 22px; }
}

/* Global visual system - Option B: clean medical SaaS */
body.app-body {
  --primary: #00a8d6;
  --primary-dark: #007fa5;
  --navy: #061522;
  --ink: #07131c;
  --muted: #687682;
  --bg: #f7fafb;
  --card: #ffffff;
  --line: #dce8ef;
  --line-strong: #c7d9e4;
  --success: #19a878;
  --warning: #f2a51a;
  --danger: #d94b4b;
  --shadow: 0 8px 24px rgba(0, 27, 45, .07);
  --radius: 20px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

body.app-body .app-shell {
  background: var(--bg);
}

body.app-body .sidebar {
  width: 300px;
  padding: 0;
  background: #020d17;
  border-right: 1px solid #d8e4ec;
  box-shadow: none;
  color: #eaf4f8;
}

body.app-body .brand {
  height: 78px;
  margin: 0;
  padding: 0 22px;
  border-bottom: 1px solid #162330;
  gap: 13px;
}

body.app-body .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background-color: #06324c;
  box-shadow: none;
}

body.app-body .brand b {
  color: #ffffff;
  font-size: 18px;
  letter-spacing: .2px;
  font-weight: 750;
}

body.app-body .brand small {
  color: #8fb4c6;
  letter-spacing: 2.6px;
  font-size: 11px;
}

body.app-body .nav-list {
  padding: 18px 12px 128px;
  gap: 6px;
  max-height: calc(100vh - 78px);
}

body.app-body .nav-section {
  margin: 18px 14px 7px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: #7f98a7;
  font-size: 10px;
  letter-spacing: 1.25px;
  line-height: 1;
}

body.app-body .nav-list a {
  margin-left: 0;
  padding: 13px 16px;
  border-radius: 12px;
  color: #eaf4f8;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -.15px;
}

body.app-body .nav-list a:hover,
body.app-body .nav-list a.active {
  background: #062f49;
  color: #00bfff;
  font-weight: 650;
}

body.app-body .sidebar-footer {
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 22px;
  border-top: 1px solid #162330;
  background: linear-gradient(180deg, rgba(2,13,23,0), #020d17 24%);
}

body.app-body .sidebar-footer .btn {
  width: 100%;
  border-color: #314554;
  color: #eaf4f8;
}

body.app-body .main-content {
  margin-left: 300px;
  width: calc(100% - 300px);
  padding: 0;
  background: var(--bg);
}

body.app-body .topbar {
  height: 72px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  background: #fbfdff;
  padding: 0 28px;
  backdrop-filter: none;
}

body.app-body .topbar strong {
  color: var(--ink);
  font-size: 20px;
  letter-spacing: -.2px;
  font-weight: 650;
}

body.app-body .topbar .muted {
  color: var(--muted);
  font-weight: 650;
}

body.app-body .topbar-user {
  position: relative;
  padding-left: 50px;
  min-height: 42px;
  justify-content: center;
}

body.app-body .topbar-user:before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #dff6ff;
  box-shadow: inset 0 0 0 1px rgba(0,168,214,.06);
}

body.app-body .topbar-user:after {
  content: "K";
  position: absolute;
  left: 0;
  top: 50%;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  color: var(--primary);
  font-weight: 900;
  font-size: 13px;
}

body.app-body .topbar-user span {
  color: var(--ink);
  font-weight: 600;
}

body.app-body .topbar-user small {
  color: var(--primary-dark);
  font-weight: 600;
}

body.app-body .content-card {
  margin: 0;
  padding: 30px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

body.app-body .card,
body.app-body .metric,
body.app-body .content-card > form,
body.app-body .content-card > section:not(.hc-compact):not(.hc-picker),
body.app-body .content-card > div:not(.alert):not(.hc-history) {
  border-color: var(--line);
  box-shadow: var(--shadow);
}

body.app-body .card {
  border-radius: 20px;
  padding: 20px;
}

body.app-body .metric {
  min-height: 112px;
  background: #ffffff;
}

body.app-body .metric:after {
  background: rgba(0,168,214,.09);
}

body.app-body .metric strong {
  color: var(--ink);
  font-size: 30px;
}

body.app-body .btn {
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: -.1px;
}

body.app-body .btn-primary {
  background: #00a8d6;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(0, 168, 214, .18);
}

body.app-body .btn-dark {
  background: #061522;
  color: #ffffff;
}

body.app-body .btn-light {
  background: #e7f8fb;
  color: #007e91;
}

body.app-body .btn-danger {
  background: #dc4b4b;
}

body.app-body input,
body.app-body select,
body.app-body textarea {
  border-color: var(--line);
  border-radius: 13px;
  background: #fbfdfe;
  color: var(--ink);
}

body.app-body input:focus,
body.app-body select:focus,
body.app-body textarea:focus {
  outline: 2px solid rgba(0, 168, 214, .14);
  border-color: var(--primary);
}

body.app-body input::placeholder,
body.app-body textarea::placeholder {
  color: #8796a2;
  opacity: .46;
}

body.app-body label {
  color: var(--ink);
  font-weight: 600;
}

body.app-body table {
  border-radius: 18px;
  box-shadow: none;
}

body.app-body th {
  background: #eef7fa;
  color: #536774;
  font-size: 12px;
  text-transform: none;
}

body.app-body td {
  border-bottom-color: var(--line);
}

body.app-body .badge {
  background: #e4fbff;
  color: #007e91;
  font-weight: 700;
}

body.app-body .alert {
  border-radius: 14px;
  border: 1px solid transparent;
}

body.app-body .alert-success {
  background: #eafff5;
  border-color: #b9f0d9;
}

body.app-body .alert-error {
  background: #fff1f1;
  border-color: #ffd1d1;
}

body.app-body .quick-fab-main,
body.app-body .quick-fab-icon {
  background: linear-gradient(135deg, #00a8d6, #3fd8e2) !important;
  box-shadow: 0 14px 30px rgba(0, 168, 214, .28) !important;
}

body.app-body .quick-fab.open .quick-fab-main {
  background: linear-gradient(135deg, #061522, #07334b) !important;
}

body.app-body .quick-fab-label {
  background: #061522 !important;
  border-radius: 8px !important;
}

@media (max-width: 900px) {
  body.app-body .sidebar {
    width: min(86vw, 320px);
    padding: 0;
  }

  body.app-body .brand {
    padding: 0 18px;
  }

  body.app-body .nav-list {
    max-height: calc(100vh - 78px);
    padding: 16px 12px 128px;
  }

  body.app-body .sidebar-footer {
    left: 0;
    right: 0;
    padding: 16px 18px;
  }

  body.app-body .main-content {
    margin-left: 0;
    width: 100%;
    padding: 0;
  }

  body.app-body .topbar {
    min-height: 66px;
    height: auto;
    padding: 11px 14px;
    border-radius: 0;
  }

  body.app-body .menu-toggle {
    display: inline-flex;
    background: #00a8d6;
    color: #ffffff;
    border-radius: 12px;
    min-height: 42px;
  }

  body.app-body .content-card {
    padding: 16px 12px 22px;
  }
}

@media (max-width: 760px) {
  body.app-body {
    font-size: 14px;
  }

  body.app-body .topbar strong {
    font-size: 15px;
  }

  body.app-body .topbar .muted {
    font-size: 13px;
  }

  body.app-body .topbar-user {
    padding-left: 0;
    min-height: auto;
    max-width: 40vw;
  }

  body.app-body .topbar-user:before,
  body.app-body .topbar-user:after {
    display: none;
  }

  body.app-body .content-card {
    padding-left: 10px;
    padding-right: 10px;
  }

  body.app-body th,
  body.app-body td {
    padding: 10px;
  }
}
