@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --page: #eaeff3;
  --surface: #f6f8fa;
  --card: #ffffff;
  --ink: #22303e;
  --text: #374553;
  --muted: #6b7a88;
  --soft: #8a96a1;
  --line: #dde4e9;
  --line-soft: #ebeff2;
  --brand: #4a6fa5;
  --brand-dark: #3a5a8c;
  --brand-soft: #eef2f7;
  --accent: #e0794f;
  --danger: #b23b2e;
  --danger-soft: #fbe3dc;
  --success: #2f8452;
  --success-soft: #e3f3e8;
  --warning: #9a6b14;
  --warning-soft: #fbf1de;
  --shadow: 0 18px 50px rgba(34, 48, 62, .10);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
}

body.auth-body {
  background: linear-gradient(180deg, #eff3f6 0%, var(--surface) 55%);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-dark);
}

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

.container,
.container-fluid {
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
}

.app-frame {
  width: 100%;
  min-height: 100vh;
  background: var(--surface);
}

.app-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.app-main {
  padding-top: 1rem;
  padding-bottom: 6.8rem;
}

.navbar {
  border-bottom: 1px solid rgba(221, 228, 233, .82);
  background: #ffffff;
  backdrop-filter: blur(10px);
}

.sticky-top {
  position: sticky;
  top: 0;
  z-index: 20;
}

.navbar .container-fluid,
.navbar-collapse,
.navbar-nav,
.d-flex,
.app-brand,
.nav-link,
.mobile-tab,
.auth-secure {
  display: flex;
}

.navbar .container-fluid {
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: .8rem;
  padding-bottom: .75rem;
}

.navbar-brand,
.app-brand {
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 10px 24px rgba(74, 111, 165, .28);
  flex: 0 0 auto;
}

.brand-logo {
  display: block;
  width: 178px;
  max-width: 44vw;
  height: auto;
  border-radius: 0;
  background: #fff;
}

.auth-brand-logo {
  display: block;
  width: min(320px, 100%);
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(34, 48, 62, .08);
}

.brand-mark svg,
.nav-icon,
.mobile-tab svg,
.quick-icon {
  display: block;
  flex: 0 0 auto;
}

.brand-subtitle {
  display: block;
  margin-top: .08rem;
  color: var(--soft);
  font-size: .76rem;
  font-weight: 600;
}

.navbar-collapse {
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.navbar-nav {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .25rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-link {
  align-items: center;
  gap: .45rem;
  min-height: 40px;
  border-radius: 12px;
  padding: .5rem .7rem;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 750;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--brand);
  background: var(--brand-soft);
}

.navbar-toggler {
  display: none;
}

.mobile-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .15rem;
  padding: .5rem .45rem calc(.5rem + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid #e9edf0;
  backdrop-filter: blur(10px);
}

.mobile-tab {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  min-height: 54px;
  border-radius: 14px;
  color: #9aa7b2;
  font-size: .68rem;
  font-weight: 800;
}

.mobile-tab.is-active {
  color: var(--brand);
  background: #f4f7fa;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.35rem;
}

.auth-panel {
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 2.2rem;
}

.auth-logo .brand-mark {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  margin-bottom: 1.15rem;
}

.auth-logo.has-image {
  margin-bottom: 1.6rem;
}

.auth-title {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.1;
  font-weight: 800;
}

.auth-copy {
  margin: .45rem 0 0;
  color: var(--muted);
  font-size: .92rem;
}

.auth-secure {
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: 1.55rem;
  color: var(--soft);
  font-size: .78rem;
  font-weight: 600;
}

.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  box-shadow: none;
}

.section-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 1rem;
}

.btn {
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font: inherit;
  font-weight: 800;
  padding: .58rem .95rem;
  text-align: center;
  background: #fff;
  color: var(--ink);
  line-height: 1.15;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px rgba(74, 111, 165, .24);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(224, 121, 79, .24);
}

.btn-outline-primary {
  border-color: var(--line-soft);
  color: var(--brand);
  background: #fff;
}

.btn-outline-secondary {
  border-color: var(--line);
  color: var(--muted);
  background: #fff;
}

.btn-sm {
  min-height: 36px;
  padding: .35rem .65rem;
  font-size: .85rem;
  border-radius: 11px;
}

.btn-lg {
  min-height: 54px;
  padding: .75rem 1.05rem;
  font-size: 1rem;
}

.w-100 {
  width: 100%;
}

.quick-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-grid .btn {
  min-height: 76px;
  flex-direction: column;
  background: #fff;
  color: var(--ink);
}

.quick-grid .btn:first-child,
.quick-grid .btn.is-emergency {
  grid-column: 1 / -1;
  min-height: 58px;
  flex-direction: row;
}

.quick-grid .btn:first-child {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.quick-grid .btn.is-emergency {
  background: #fdf1ee;
  border-color: #f3c2b4;
  color: var(--danger);
}

.form-control,
.form-select {
  min-height: 52px;
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: .68rem .85rem;
  background: #fff;
  color: var(--ink);
  outline: none;
}

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

.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(74, 111, 165, .12);
}

.form-label {
  display: block;
  color: #42505d;
  font-size: .82rem;
  font-weight: 800;
  margin-bottom: .38rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--brand);
}

.small-muted {
  color: var(--muted);
  font-size: .92rem;
}

.metric-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  min-height: 118px;
  padding: 1rem;
}

.metric-card.is-wide {
  grid-column: 1 / -1;
  min-height: 150px;
  padding: 1.25rem;
}

.metric-label {
  color: var(--soft);
  font-size: .78rem;
  font-weight: 800;
}

.metric-value {
  margin-top: .45rem;
  color: var(--ink);
  font-size: .98rem;
  font-weight: 800;
}

.pain-score {
  margin-top: .25rem;
  color: var(--accent);
  font-size: 2.8rem;
  line-height: 1;
  font-weight: 800;
}

.pain-score span {
  color: #b7c0c8;
  font-size: 1.1rem;
}

.status-alert {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1rem;
  background: var(--danger-soft);
  border: 1.5px solid #f3c2b4;
  border-radius: 18px;
  color: #9a3b22;
}

.status-alert strong {
  display: block;
  font-size: .92rem;
}

.status-alert span {
  color: #a9543a;
  font-size: .8rem;
}

.badge-soft {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .28rem .72rem;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: .75rem;
  font-weight: 800;
}

.app-screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.screen-title {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.15;
  font-weight: 800;
}

.screen-subtitle {
  margin-top: .18rem;
  color: var(--soft);
  font-size: .84rem;
  font-weight: 600;
}

.section-label {
  color: #42505d;
  font-size: .85rem;
  font-weight: 800;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.record-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .75rem;
}

.record-card {
  display: block;
  padding: 1rem 1.1rem;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  text-align: left;
}

.record-card:hover {
  color: inherit;
  border-color: #d8e1e8;
  box-shadow: 0 10px 26px rgba(34, 48, 62, .06);
}

.record-card.is-alert {
  background: #fdf1ee;
  border-color: #f3c2b4;
}

.record-top,
.record-row,
.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}

.record-title {
  color: var(--ink);
  font-size: .96rem;
  font-weight: 800;
}

.record-meta {
  color: var(--soft);
  font-size: .78rem;
  font-weight: 600;
}

.record-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: .75rem;
}

.stat-mini {
  color: var(--soft);
  font-size: .78rem;
  font-weight: 650;
}

.stat-mini strong {
  display: block;
  margin-top: .1rem;
  color: var(--text);
  font-size: .9rem;
  font-weight: 800;
}

.stat-mini.is-pain strong {
  color: #b05a2a;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .75rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 10px;
  padding: .35rem .65rem;
  background: #f2f5f7;
  color: #5b6873;
  font-size: .73rem;
  font-weight: 750;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .28rem .7rem;
  background: #edf1f4;
  color: #5b6873;
  font-size: .72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-pill.is-active {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.is-good {
  background: var(--success-soft);
  color: var(--success);
}

.icon-tile {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  background: var(--brand-soft);
  flex: 0 0 auto;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .95rem 1rem;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
}

.menu-item-title {
  flex: 1;
  color: var(--ink);
  font-size: .92rem;
  font-weight: 800;
}

.chevron {
  color: #c4cbd1;
  font-size: 1.35rem;
  line-height: 1;
}

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: .75rem;
}

.timeline-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: .28rem;
}

.timeline-line {
  width: 2px;
  flex: 1;
  background: #e5eaed;
}

.timeline-body {
  padding-bottom: 1rem;
}

.calendar-shell {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 1rem;
}

.calendar-head {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .35rem;
  margin-bottom: .45rem;
}

.calendar-weekday {
  color: var(--soft);
  text-align: center;
  font-size: .75rem;
  font-weight: 800;
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .35rem;
}

.calendar-cell {
  min-height: 58px;
  border: 1px solid #eef2f4;
  border-radius: 13px;
  padding: .45rem .3rem;
  text-align: center;
  background: #f9fbfc;
}

.calendar-cell.is-empty {
  visibility: hidden;
}

.calendar-cell strong {
  display: block;
  color: var(--ink);
  font-size: .85rem;
}

.calendar-cell small {
  display: block;
  margin-top: .12rem;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 800;
}

.report-preview {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  background: #e7ecf1;
  font-size: 1rem;
  font-weight: 850;
}

.quick-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.quick-section {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.pain-picker {
  display: flex;
  gap: .38rem;
  overflow-x: auto;
  padding: .15rem .05rem .3rem;
}

.pain-picker label {
  position: relative;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.choice-grid label {
  display: flex;
  position: relative;
}

.choice-grid.is-even {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-grid.is-even label {
  min-width: 0;
}

.choice-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-chip {
  width: 100%;
  min-height: 42px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem .85rem;
  background: #fff;
  color: var(--text);
  font-size: .84rem;
  font-weight: 800;
  cursor: pointer;
}

.pain-picker .choice-chip {
  width: 34px;
  height: 42px;
  padding: 0;
  flex: 0 0 auto;
}

.choice-input:checked + .choice-chip {
  border-color: var(--brand);
  background: #e4ecf5;
  color: var(--ink);
}

.choice-input:focus-visible + .choice-chip {
  outline: 3px solid rgba(74, 111, 165, .22);
  outline-offset: 2px;
}

.medication-choice {
  justify-content: flex-start;
  min-height: 58px;
  padding: .8rem 1rem;
  text-align: left;
}

.medication-choice strong,
.medication-choice small {
  display: block;
}

.medication-choice strong {
  color: var(--ink);
  font-size: .92rem;
}

.medication-choice small {
  margin-top: .12rem;
  color: var(--soft);
  font-size: .78rem;
  font-weight: 650;
}

.btn:disabled {
  cursor: not-allowed;
  background: #edf0f2;
  border-color: #edf0f2;
  color: #b4bcc3;
  box-shadow: none;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--swatch, #ccd5dd);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

.photo-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border: 1.5px dashed #cfd8df;
  border-radius: 16px;
  background: #fff;
  color: var(--soft);
  text-align: center;
  font-size: .9rem;
  font-weight: 800;
  cursor: pointer;
}

.photo-drop input {
  display: none;
}

.pain-low { background: var(--success-soft); }
.pain-mid { background: var(--warning-soft); }
.pain-high { background: #fbe7dd; }

.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -.5rem;
  margin-right: -.5rem;
}

.row > * {
  width: 100%;
  padding-left: .5rem;
  padding-right: .5rem;
}

.g-2 { gap: .5rem 0; }
.g-3 { gap: 1rem 0; }
.col-6 { width: 50%; }
.col-12 { width: 100%; }

.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.text-end { text-align: right; }
.fw-semibold { font-weight: 750; }
.h3 { font-size: 1.35rem; line-height: 1.15; font-weight: 800; }
.h5 { font-size: 1.05rem; line-height: 1.2; font-weight: 800; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.me-auto { margin-right: auto; }
.ms-2 { margin-left: .5rem; }
.p-2 { padding: .5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.35rem; }
.py-2 { padding-top: .5rem; padding-bottom: .5rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.gap-2 { gap: .5rem; }
.h-100 { height: 100%; }
.border-top { border-top: 1px solid var(--line-soft); }

.alert {
  border-radius: 16px;
  margin-bottom: 1rem;
  padding: .85rem 1rem;
  font-weight: 700;
}

.alert-danger {
  background: #ffe3e3;
  color: #842029;
}

.alert-success {
  background: #dcfce7;
  color: #14532d;
}

.table-responsive {
  overflow-x: auto;
}

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

.table th,
.table td {
  border-bottom: 1px solid var(--line-soft);
  padding: .85rem .55rem;
  text-align: left;
}

.table th {
  color: var(--soft);
  font-size: .76rem;
  font-weight: 800;
}

.align-middle td,
.align-middle th {
  vertical-align: middle;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
}

.calendar-day {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: .18rem;
}

.calendar-day strong {
  font-size: 1rem;
}

.calendar-day small {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 767px) {
  .brand-logo {
    width: 142px;
    max-width: 52vw;
  }

  .navbar-nav {
    display: none;
  }

  .navbar-collapse {
    flex: 0 0 auto;
  }

  .navbar .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .app-main {
    padding-left: .85rem;
    padding-right: .85rem;
  }

  .table-responsive {
    font-size: .9rem;
  }

  .hide-mobile {
    display: none;
  }
}

@media (min-width: 768px) {
  body {
    background: var(--page);
  }

  .app-frame {
    max-width: 1220px;
    margin: 0 auto;
    box-shadow: var(--shadow);
  }

  .app-main {
    padding: 1.25rem 1.5rem 2.25rem;
  }

  .mobile-tabs {
    display: none;
  }

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

  .metric-card.is-wide {
    grid-column: span 2;
  }

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

  .quick-grid .btn:first-child,
  .quick-grid .btn.is-emergency {
    grid-column: auto;
  }

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

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

  .app-screen {
    gap: 1.25rem;
  }

  .col-md-2 { width: 16.6667%; }
  .col-md-3 { width: 25%; }
  .col-md-4 { width: 33.3333%; }
  .col-md-5 { width: 41.6667%; }
  .col-md-6 { width: 50%; }
  .col-md-8 { width: 66.6667%; }
}

@media (min-width: 1040px) {
  .navbar .container-fluid {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .app-main {
    padding-left: 2rem;
    padding-right: 2rem;
  }

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

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