:root {
  --app-ink: #16202a;
  --app-muted: #657384;
  --app-line: #d9e0e6;
  --app-nav: #173246;
  --app-accent: #1e7868;
  --app-surface: #fff;
  --app-band: #f4f7f8;
}

body.dark-mode,
body.dark-mode * {
  color-scheme: dark;
}

body.dark-mode {
  --ink: #eef4f2;
  --muted: #a9b8b6;
  --line: #31434a;
  --nav: #0c1720;
  --accent: #44b99f;
  --band: #101820;
  --paper: #17232b;
  --app-ink: #eef4f2;
  --app-muted: #a9b8b6;
  --app-line: #31434a;
  --app-nav: #0c1720;
  --app-accent: #44b99f;
  --app-surface: #17232b;
  --app-band: #101820;
  background: var(--band);
}

body.dark-mode .card,
body.dark-mode .panel,
body.dark-mode form,
body.dark-mode aside,
body.dark-mode .view,
body.dark-mode .pin-card,
body.dark-mode .doc-page,
body.dark-mode .profile-pill,
body.dark-mode .patient-card,
body.dark-mode .consult-card,
body.dark-mode .profile-card {
  color: var(--ink);
  background: var(--app-surface);
  border-color: var(--line);
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  color: var(--ink);
  background: #111c24;
  border-color: var(--line);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #9fb1b2;
}

body.dark-mode label,
body.dark-mode .hint,
body.dark-mode .empty,
body.dark-mode .field-help,
body.dark-mode .upload-note,
body.dark-mode .profile-meta,
body.dark-mode .task span,
body.dark-mode .activity span,
body.dark-mode .alert span,
body.dark-mode .message span,
body.dark-mode .presence-user span,
body.dark-mode .profile-pill span,
body.dark-mode .candidate-action,
body.dark-mode th,
body.dark-mode small {
  color: #c7d6d3 !important;
}

body.dark-mode .quick-links a,
body.dark-mode .app-links a,
body.dark-mode .status-item,
body.dark-mode .task,
body.dark-mode .activity,
body.dark-mode .alert,
body.dark-mode .message,
body.dark-mode .presence-user,
body.dark-mode .intake-card,
body.dark-mode .doctor-card,
body.dark-mode .doctor-shop,
body.dark-mode .asset-box,
body.dark-mode .patient-choice,
body.dark-mode .candidate-card {
  color: #eef4f2 !important;
  background: #1d2b34 !important;
  border-color: #3d525b !important;
}

body.dark-mode table,
body.dark-mode th,
body.dark-mode td {
  border-color: #3d525b !important;
}

body.dark-mode th {
  background: #22313a !important;
}

body.dark-mode .secondary {
  color: #d9fff4;
  background: #20313a;
  border-color: #4f6a72;
}

body.dark-mode .primary {
  color: #061512;
}

button,
.primary,
.secondary,
.app-links a,
.quick-links a,
.floating-actions a,
.patient-card,
.consult-card,
.profile-card {
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background-color .14s ease;
}

button:hover,
.primary:hover,
.secondary:hover,
.quick-links a:hover,
.floating-actions a:hover,
.patient-card:hover,
.consult-card:hover,
.profile-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(22, 32, 42, .12);
}

button:active,
.primary:active,
.secondary:active,
.app-links a:active,
.quick-links a:active,
.floating-actions a:active,
.patient-card:active,
.consult-card:active,
.profile-card:active {
  transform: translateY(1px) scale(.99);
  box-shadow: 0 4px 10px rgba(22, 32, 42, .1);
}

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  color: #fff;
  background: linear-gradient(90deg, #102736, #173246);
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.app-brand {
  color: #fff;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: .01em;
}

.app-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-toggle {
  padding: 9px 11px;
  color: rgba(255, 255, 255, .82);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 7px;
  font-size: .86rem;
  font-weight: 900;
}

.theme-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, .14);
}

.app-links a {
  padding: 9px 11px;
  color: rgba(255, 255, 255, .78);
  text-decoration: none;
  border-radius: 7px;
  font-size: .86rem;
  font-weight: 800;
}

.app-links a:hover,
.app-links a.active {
  color: #fff;
  background: rgba(255, 255, 255, .12);
}

@media (max-width: 720px) {
  .app-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-links {
    justify-content: flex-start;
  }
}

.pin-lock {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 39, 54, .92);
  backdrop-filter: blur(8px);
}

.pin-card {
  display: grid;
  gap: 14px;
  width: min(390px, 100%);
  padding: 24px;
  color: var(--app-ink);
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, .28);
}

.pin-card h2,
.pin-card p {
  margin: 0;
}

.pin-eyebrow {
  color: var(--app-muted);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pin-card label {
  display: grid;
  gap: 7px;
  color: var(--app-muted);
  font-size: .86rem;
  font-weight: 800;
}

.pin-card input {
  width: 100%;
  padding: 12px;
  color: var(--app-ink);
  border: 1px solid var(--app-line);
  border-radius: 6px;
  font: inherit;
  font-size: 1.2rem;
  letter-spacing: .18em;
}

.pin-card button {
  min-height: 42px;
  color: #fff;
  background: var(--app-accent);
  border: 1px solid var(--app-accent);
  border-radius: 6px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.pin-error {
  color: #a33a2f;
  font-size: .86rem;
  font-weight: 800;
}

/* CloudClinic polish layer: shared readability and responsive comfort. */
:root {
  --cc-radius: 10px;
  --cc-radius-sm: 7px;
  --cc-shadow: 0 14px 34px rgba(22, 32, 42, .08);
  --cc-shadow-soft: 0 8px 22px rgba(22, 32, 42, .06);
}

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(circle at 18% -12%, rgba(31, 123, 107, .1), transparent 28rem),
    linear-gradient(180deg, #f8fbfa 0%, var(--app-band, #f4f7f8) 54%, #edf4f2 100%) !important;
}

header:not(.letterhead),
.topbar {
  box-shadow: 0 12px 28px rgba(16, 39, 54, .14) !important;
}

.panel,
.card,
.view,
.login-card,
.search-panel,
.doctor-card,
.intake-shell,
form:not(#patientFlow):not(#userForm):not(#adminForm),
aside.panel,
.pin-card {
  border-radius: var(--cc-radius) !important;
  box-shadow: var(--cc-shadow) !important;
}

.card,
.panel,
.view,
.profile-pill,
.status-item,
.task,
.activity,
.alert,
.message,
.quick-links a,
.patient-card,
.consult-card,
.lead-card,
.profile-card,
.doctor-card,
.intake-card,
.candidate-card {
  border-color: rgba(217, 224, 230, .9) !important;
}

h1,
h2,
h3 {
  letter-spacing: 0 !important;
}

p,
.hint,
.field-help,
.dialog-help,
.empty,
.system-note {
  line-height: 1.55 !important;
}

label {
  line-height: 1.28 !important;
}

input,
select,
textarea {
  min-height: 42px;
  border-radius: var(--cc-radius-sm) !important;
  transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(31, 123, 107, .16) !important;
  border-color: rgba(31, 123, 107, .62) !important;
}

button,
.primary,
.secondary,
.quick-links a,
.app-links a,
.floating-actions a {
  border-radius: var(--cc-radius-sm) !important;
}

.primary {
  background: linear-gradient(180deg, #248b79, #1e7868) !important;
}

.secondary {
  background: rgba(255, 255, 255, .94) !important;
}

.tabs,
.profile-tabs {
  gap: 6px !important;
  scrollbar-width: thin;
}

.tab,
.profile-tab-btn,
.tab-btn {
  border-radius: 7px 7px 0 0 !important;
}

table {
  overflow: hidden;
  border-radius: 8px;
}

.floating-actions {
  z-index: 12;
}

@media (max-width: 760px) {
  body {
    background: linear-gradient(180deg, #edf7f5 0%, #f8fbfa 42%, #eef5f3 100%) !important;
  }

  .app-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 10px 12px;
  }

  .app-links {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 3px;
    scrollbar-width: thin;
  }

  .app-links a,
  .theme-toggle {
    flex: 0 0 auto;
    min-height: 38px;
  }

  main,
  .main-panel,
  .workspace {
    width: 100% !important;
  }

  .panel,
  .card,
  .view,
  form:not(#patientFlow):not(#userForm):not(#adminForm) {
    box-shadow: var(--cc-shadow-soft) !important;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  button,
  .primary,
  .secondary {
    min-height: 44px;
  }
}
