:root {
  color-scheme: light;
  --bg: #f4ede4;
  --bg-soft: #efe2d2;
  --surface: rgba(255, 249, 243, 0.94);
  --surface-strong: #fffaf5;
  --surface-muted: #eadcca;
  --line: rgba(113, 84, 58, 0.14);
  --line-strong: rgba(113, 84, 58, 0.24);
  --text: #3e2f24;
  --muted: #8f745d;
  --accent: #6f4e37;
  --accent-soft: #b68f6b;
  --accent-ghost: #e7d6c3;
  --danger: #ab6b55;
  --success: #6f8a61;
  --shadow: 0 20px 60px rgba(75, 52, 34, 0.10);
  --shadow-soft: 0 12px 28px rgba(75, 52, 34, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, 'SF Pro Text', Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(202, 170, 136, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(140, 104, 77, 0.14), transparent 20%),
    linear-gradient(180deg, #f8f2eb 0%, #f1e7da 46%, #ede1d3 100%);
  color: var(--text);
}

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

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}

.window-panel {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 22px 20px;
  margin-bottom: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  margin: 6px 0 0;
  font-size: clamp(28px, 4vw, 34px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.topbar-copy {
  margin: 10px 0 0;
  max-width: 560px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 15px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7a5a43 0%, #624632 100%);
  color: #fff8f2;
  box-shadow: 0 10px 24px rgba(98, 70, 50, 0.22);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  padding: 8px;
  border-radius: 22px;
  background: rgba(255, 249, 243, 0.76);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.report-toolbar {
  margin-bottom: 14px;
}

.report-period-card {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 245, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.report-body {
  display: grid;
  gap: 14px;
}

.report-summary-intro {
  display: grid;
  gap: 4px;
  margin-bottom: 2px;
}

#app {
  display: grid;
  gap: 16px;
}

.card {
  padding: 20px;
}

.card-title {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-grid,
.report-grid,
.record-preview,
.settings-grid {
  display: grid;
  gap: 12px;
}

.metric-grid,
.report-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.metric-grid-dashboard .metric-box:first-child {
  background: linear-gradient(135deg, #7b5941 0%, #5d4030 100%);
  color: #fff9f4;
  border-color: rgba(89, 60, 40, 0.12);
}

.metric-box-primary {
  background: linear-gradient(135deg, #7b5941 0%, #5d4030 100%);
  color: #fff9f4;
  border-color: rgba(89, 60, 40, 0.12);
}

.metric-box-primary .subtle {
  color: rgba(255, 248, 242, 0.76);
}

.metric-box-primary .metric-label {
  color: rgba(255, 248, 242, 0.84);
}

.metric-grid-dashboard .metric-box:first-child .subtle {
  color: rgba(255, 248, 242, 0.76);
}

.clinic-grid {
  grid-template-columns: 1fr;
}

.metric-box,
.clinic-card,
.record-row,
.report-row,
.settings-box {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.metric-box strong,
.report-number,
.big-number {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.metric-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--muted);
}

.metric-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.report-metric-box strong {
  font-size: 28px;
}

.metric-box-primary .metric-title {
  color: #fff9f4;
}

.subtle {
  color: var(--muted);
}

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

.section-copy {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.section-badge {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e2cfbb;
  color: var(--accent);
  font-weight: 800;
}

.section-badge.is-muted {
  background: #e8ddd1;
  color: #8d725a;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #efe2d4;
  color: #7b5b46;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.hero-logo {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7b5941 0%, #5d4030 100%);
  color: #fff9f4;
  box-shadow: 0 14px 28px rgba(100, 71, 51, 0.20);
}

.hero-logo span {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.clinic-section {
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--line);
}

.clinic-section-active {
  background: rgba(255, 251, 246, 0.85);
}

.clinic-section-archived {
  background: rgba(239, 230, 219, 0.66);
}

.clinic-card.is-archived {
  background: rgba(245, 239, 232, 0.95);
}

.empty-state {
  display: grid;
  gap: 6px;
  min-height: 110px;
  align-content: center;
}

.empty-state strong {
  font-size: 16px;
  letter-spacing: -0.01em;
}

.actions,
.inline-actions,
.clinic-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn,
.nav-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent-ghost);
  color: var(--accent);
  padding: 11px 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.btn:hover,
.nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(111, 78, 55, 0.12);
}

.nav-btn {
  position: relative;
  background: transparent;
  color: var(--muted);
}

.btn:active,
.nav-btn:active,
.btn.is-pressed {
  transform: translateY(0);
}

.btn.is-disabled,
.btn:disabled {
  opacity: 0.55;
  box-shadow: none;
  transform: none;
}

.btn-primary,
.nav-btn.is-active {
  background: linear-gradient(180deg, #7b5941 0%, #644733 100%);
  color: #fff8f3;
}

.nav-btn.is-active {
  box-shadow: 0 14px 28px rgba(100, 71, 51, 0.22);
}

.btn-danger {
  background: #f0ddd2;
  color: #8d5746;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.field-inline {
  width: min(240px, 100%);
  max-width: 100%;
  min-width: 0;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 250, 245, 0.96);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: inset 0 1px 2px rgba(63, 46, 33, 0.04);
}

.field-inline input {
  min-width: 0;
  max-width: 100%;
}

.field input[type='date'],
.field input[type='month'] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid rgba(111, 78, 55, 0.16);
  border-color: rgba(111, 78, 55, 0.34);
}

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

.card-form .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field-wide,
.actions-wide {
  grid-column: 1 / -1;
}

.card-hero {
  position: relative;
  overflow: hidden;
}

.card-onboarding {
  background: linear-gradient(135deg, rgba(255, 251, 246, 0.98) 0%, rgba(244, 232, 219, 0.94) 100%);
}

.card-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(195, 163, 132, 0.18) 0%, transparent 44%);
  pointer-events: none;
}

.report-row-clinic {
  background: linear-gradient(180deg, rgba(255, 250, 245, 0.98), rgba(246, 236, 225, 0.92));
}

.report-row-record {
  background: rgba(255, 252, 248, 0.98);
}

.hidden {
  display: none !important;
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(63, 46, 33, 0.28);
  backdrop-filter: blur(6px);
  padding: 18px;
  display: grid;
  align-items: end;
}

.sheet-panel {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px;
}

.report-list,
.clinic-list,
.rate-list,
.record-list {
  display: grid;
  gap: 10px;
}

.row-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #efe2d4;
  color: #7b5b46;
  font-size: 12px;
  font-weight: 700;
}

.message {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  font-weight: 600;
}

.message.error {
  color: #6f3f30;
  background: #f5dfd6;
}

.message.ok {
  color: #4f6546;
  background: #e2ecdb;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
  }

  .header-brand {
    align-items: flex-start;
  }

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

  .nav-btn {
    width: 100%;
  }

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

@media (max-width: 520px) {
  .metric-grid,
  .report-grid,
  .top-nav {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card,
  .sheet-panel,
  .topbar {
    padding: 16px;
  }
}
