:root {
  color-scheme: light dark;
  --background: #f5f3ec;
  --surface: #ffffff;
  --text: #17352f;
  --muted: #536a64;
  --primary: #27574d;
  --primary-text: #ffffff;
  --border: #c9d3cd;
  --accent: #dcebe4;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.app-header, main, footer {
  width: min(100% - 32px, 720px);
  margin-inline: auto;
}

.app-header { padding: 32px 0 18px; }
.eyebrow { color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 6px 0 4px; font-size: clamp(2rem, 9vw, 3.1rem); line-height: 1.05; }
.app-header p { margin: 0; color: var(--muted); }

main { display: grid; gap: 16px; flex: 1; }
section { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 22px; box-shadow: 0 8px 30px rgb(20 52 45 / .06); }
.empty-state { text-align: center; }
.illustration { display: grid; place-items: center; margin: 0 auto 12px; width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--primary); font-size: 1.8rem; font-weight: 900; }
h2 { margin: 0 0 8px; font-size: 1.25rem; }
.empty-state p { color: var(--muted); line-height: 1.5; margin: 0 auto 18px; max-width: 34rem; }
button { min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--primary); color: var(--primary-text); font: inherit; font-weight: 750; cursor: pointer; }
button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #d28c20; outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .72; }
.empty-state small { display: block; margin-top: 8px; color: var(--muted); }
.device-note label { display: block; color: var(--muted); font-weight: 650; margin-bottom: 7px; }
textarea { width: 100%; min-height: 72px; resize: vertical; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--background); color: var(--text); font: inherit; }
.secondary { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.compact { min-height: 44px; padding-inline: 13px; }
.section-heading, .recipe-card-heading, .dialog-heading, .form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading { margin-bottom: 16px; }
.section-heading h2, .recipe-card h3 { margin: 0; }
.recipe-list { display: grid; gap: 12px; }
.recipe-card { border: 1px solid var(--border); border-radius: 15px; padding: 16px; background: var(--background); }
.recipe-card h3 { font-size: 1.1rem; }
.recipe-card p { margin: 7px 0 0; }
.recipe-quantity { color: var(--primary); font-weight: 800; }
.recipe-meta { color: var(--muted); font-size: .92rem; }
.recipe-note-text { line-height: 1.4; }
.appointment-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.appointment-actions button { min-width: 0; padding-inline: 9px; }
.appointment-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.appointment-item { border-top: 1px solid var(--border); padding-top: 10px; }
.appointment-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.appointment-date { font-weight: 750; }
.appointment-detail { color: var(--muted); font-size: .9rem; }
.appointment-edit { min-height: 44px; flex: 0 0 auto; }

dialog { width: min(calc(100% - 24px), 560px); max-height: calc(100dvh - 24px); overflow: auto; border: 1px solid var(--border); border-radius: 20px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgb(0 0 0 / .3); }
dialog::backdrop { background: rgb(5 22 18 / .68); }
dialog form { padding: 22px; }
.dialog-heading { margin-bottom: 20px; }
.dialog-heading h2 { margin-bottom: 0; }
.icon-button { width: 48px; padding: 0; font-size: 1.6rem; }
form > label, #custom-therapy-field label, #quantity-field label { display: block; color: var(--muted); font-weight: 700; margin: 14px 0 7px; }
input:not([type="radio"]), select { width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--background); color: var(--text); font: inherit; }
.quantity-choices { margin-top: 18px; }
.group-label { color: var(--muted); font-weight: 700; margin: 0 0 8px; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.choice + .choice { margin-top: 6px; }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); }
.optional { font-weight: 400; }
.form-actions { justify-content: flex-end; margin-top: 20px; }
#recipe-status, #appointment-status { min-height: 1.2em; margin: 10px 0 0; }
[hidden] { display: none !important; }
.note-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
[role="status"] { color: var(--muted); font-size: .9rem; }
footer { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 22px 0 28px; color: var(--muted); font-size: .82rem; }
.offline-dot { width: 9px; height: 9px; border-radius: 50%; background: #278056; }

@media (min-width: 760px) {
  .app-header { padding-top: 58px; }
  main { grid-template-columns: 1.25fr .75fr; align-items: start; }
}

@media (max-width: 420px) {
  .section-heading { align-items: flex-start; }
  .form-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #10231f;
    --surface: #18322c;
    --text: #f1f6f3;
    --muted: #b8cbc4;
    --primary: #91d2bd;
    --primary-text: #10231f;
    --border: #416058;
    --accent: #244a40;
  }
}
