:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --ink: #15181b;
  --muted: #646b71;
  --line: #e3e1dc;
  --line-strong: #cfccc5;
  --brand: #1f5a4c;
  --brand-strong: #174538;
  --brand-ink: #ffffff;
  --brand-soft: #e6eeea;
  --accent: #b05a36;
  --accent-soft: #f5e9e2;
  --teal: #2c7a57;
  --teal-soft: #e3f0e8;
  --amber: #8f6210;
  --amber-soft: #f6eedb;
  --red: #b3372c;
  --red-soft: #f8e6e3;
  --tint-room: #eef2f0;
  --tint-cattery: #f1eef2;
  --tint-yard: #edf2e8;
  --tint-home: #f4f0e8;
  --shadow: 0 1px 2px rgb(21 24 27 / 0.04);
  --shadow-lg: 0 20px 50px -18px rgb(21 24 27 / 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111416;
    --surface: #181c1f;
    --surface-2: #20252a;
    --ink: #eef0ee;
    --muted: #9aa3a8;
    --line: #2a3035;
    --line-strong: #3a4248;
    --brand: #6fb39d;
    --brand-strong: #8cc7b3;
    --brand-ink: #0b1714;
    --brand-soft: #1b2a26;
    --accent: #e09272;
    --accent-soft: #33231c;
    --teal: #74c39c;
    --teal-soft: #1a2a22;
    --amber: #e0b462;
    --amber-soft: #2e2615;
    --red: #f08b7f;
    --red-soft: #351c19;
    --tint-room: #1b2321;
    --tint-cattery: #221f25;
    --tint-yard: #1d241a;
    --tint-home: #25211b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 20px 50px -18px rgb(0 0 0 / 0.7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
a { color: inherit; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.muted { color: var(--muted); }

/* ---------- Controls ---------- */

input, textarea, select {
  font: inherit;
  color: var(--ink);
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea { resize: vertical; min-height: 80px; }

.btn {
  font: 500 14px/1 var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--red); }
.btn.icon-only { width: 40px; padding: 0; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.small.icon-only { width: 34px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.fields { display: grid; gap: 14px; }
.fields.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .fields.two { grid-template-columns: 1fr; } }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.segmented button, .segmented label {
  font: 500 13px/1 var(--font);
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.segmented .active, .segmented label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}
.chip.accent { background: var(--brand-soft); color: var(--brand-strong); }
.chip.teal { background: var(--teal-soft); color: var(--teal); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.danger { background: var(--red-soft); color: var(--red); }

.avatar {
  --size: 40px;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 600 calc(var(--size) * 0.36) / 1 var(--font);
  letter-spacing: 0.02em;
  color: var(--tone-ink, var(--brand-strong));
  background: var(--tone, var(--brand-soft));
}
.avatar .icon { width: 50%; height: 50%; }
.avatar.sm { --size: 26px; }
.avatar.lg { --size: 64px; }

.mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}

/* ---------- Auth ---------- */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-hero {
  position: relative;
  overflow: hidden;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f2f4f2;
  background: #17352d;
}
.auth-hero .brand { color: #fff; }
.auth-hero .brand-mark { background: rgb(255 255 255 / 0.1); color: #fff; }
.auth-hero h1 { font-size: clamp(40px, 4.6vw, 64px); line-height: 1.02; max-width: 13ch; color: #fff; }
.auth-hero .lead { margin: 18px 0 0; max-width: 40ch; color: rgb(242 244 242 / 0.72); font-size: 16px; }
.auth-hero ul { list-style: none; padding: 0; margin: 36px 0 0; display: grid; gap: 14px; font-size: 15px; border-top: 1px solid rgb(255 255 255 / 0.12); padding-top: 24px; max-width: 44ch; }
.auth-hero li { display: flex; gap: 12px; align-items: flex-start; color: rgb(242 244 242 / 0.86); }
.auth-hero li .icon { color: #9fd0bd; margin-top: 2px; }
.auth-hero .fineprint { font-size: 13px; color: rgb(242 244 242 / 0.5); }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(420px, 100%); }
.auth-card h2 { font: 400 34px/1.1 var(--serif); letter-spacing: -0.01em; margin: 28px 0 6px; }
.auth-card form { margin-top: 0; }
.auth-card .btn.primary { width: 100%; min-height: 46px; font-size: 15px; margin-top: 6px; }
.pw { position: relative; display: block; }
.pw input { padding-right: 48px; }
.pw-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 36px; height: 36px; border: none; border-radius: 6px; background: transparent;
  color: var(--muted); display: grid; place-items: center; cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }
.pw-toggle[aria-pressed="true"] { color: var(--brand); }
.link-btn { justify-self: center; border: none; background: none; color: var(--brand); font: 500 14px/1 var(--font); padding: 6px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.notice { max-width: 1160px; margin: 20px auto -12px; padding: 0 44px; }
.notice > div { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--amber-soft); color: var(--amber); font-size: 14px; }
.notice .btn { margin-left: auto; }
@media (max-width: 860px) { .notice { padding: 0 16px; margin: 14px auto -6px; } }
.legal-note { font-size: 12.5px; color: var(--muted); margin: 0; text-align: center; }
.legal-note a { color: var(--brand); }
.form-error { color: var(--red); font-size: 14px; min-height: 1.5em; margin: 0; }

.kind-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind-choice label {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kind-choice input { position: absolute; opacity: 0; }
.kind-choice .icon { color: var(--brand); margin-bottom: 6px; }
.kind-choice b { font-size: 14.5px; font-weight: 600; }
.kind-choice small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.kind-choice label:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 24px 20px 28px; min-height: auto; }
  .auth-hero ul, .auth-hero .fineprint { display: none; }
  .auth-hero h1 { margin-top: 28px; font-size: 38px; }
}

/* ---------- Shell ---------- */

.brand { display: flex; align-items: center; gap: 10px; font: 600 18px/1 var(--font); letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; }
.brand-mark .icon { width: 18px; height: 18px; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.sidebar .brand { padding: 0 8px; }
.nav { display: grid; gap: 2px; }
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand-strong); }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.biz { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.biz b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.biz small { color: var(--muted); font-size: 12px; }

.sync {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--teal);
  background: var(--teal-soft);
}
.sync.waiting { background: var(--amber-soft); color: var(--amber); }
.sync.offline { background: var(--surface-2); color: var(--muted); }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sync.waiting .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }

.mobile-head { display: none; }
.tabbar { display: none; }

.view-wrap { min-width: 0; }
.view { padding: 40px 44px 64px; max-width: 1160px; width: 100%; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.view-head h1 { font-size: clamp(34px, 4vw, 46px); line-height: 1; }
.view-head p { margin: 8px 0 0; color: var(--muted); }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-head {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .mobile-head .brand { font-size: 17px; }
  .mobile-head .brand-mark { width: 28px; height: 28px; }
  .tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 6px 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
  }
  .tabbar a.active { color: var(--brand); }
  .tabbar .badge { position: absolute; top: 0; left: calc(50% + 6px); margin: 0; }
  .view { padding: 22px 16px calc(96px + env(safe-area-inset-bottom)); }
  .view-head { margin-bottom: 20px; }
}

/* ---------- Cards ---------- */

.stat, .pet, .doses, .panel, .stay-row, .plan {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Today ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat { padding: 14px 16px; display: flex; flex-direction: column-reverse; gap: 4px; }
.stat b { display: block; font: 600 28px/1.1 var(--font); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.dark b { color: var(--brand); }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; } .stat b { font-size: 24px; } }

.who-card {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  padding: 16px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
}
.who-card p { margin: 0; flex: 1 1 220px; font-weight: 500; }
.who-card form { display: flex; gap: 8px; flex: 1 1 280px; }

.pets { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
@media (max-width: 420px) { .pets { grid-template-columns: 1fr; } }

.pet { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.pet-head { display: flex; gap: 12px; align-items: center; }
.pet-head h2 { font-size: 17px; line-height: 1.2; }
.pet-head .sub { color: var(--muted); font-size: 13px; }
.pet-head .chip { margin-left: auto; align-self: flex-start; }
.notes { display: grid; gap: 6px; }
.note-line { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; line-height: 1.45; margin: 0; }
.note-line .icon { margin-top: 1px; color: var(--muted); }
.note-line.warn { background: var(--red-soft); color: var(--red); padding: 8px 10px; border-radius: var(--radius-sm); font-weight: 500; }
.note-line.warn .icon { color: var(--red); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 500 13px/1 var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.quick button:hover { background: var(--surface-2); }
.quick .icon { width: 17px; height: 17px; color: var(--muted); }
.quick button.done { background: var(--teal-soft); border-color: transparent; color: var(--teal); }
.quick button.done .icon { color: var(--teal); }
@media (max-width: 420px) { .quick button { flex-direction: column; gap: 4px; padding: 8px 4px; font-size: 12px; } }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.timeline li { display: grid; grid-template-columns: 44px 1fr; gap: 10px; font-size: 13.5px; padding: 6px 0; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; padding-top: 1px; }
.timeline .what { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.timeline .what b { font-weight: 500; }
.timeline .what .icon { color: var(--muted); }
.timeline .detail { color: var(--muted); }
.timeline .pending { color: var(--amber); font-size: 12px; font-weight: 500; }
.timeline .bad { color: var(--red); font-weight: 500; }
.timeline-empty { color: var(--muted); font-size: 13px; margin: 0; padding: 4px 0; }

.pet-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; }
.pet-foot .row-actions { flex-wrap: wrap; justify-content: flex-end; }

.empty {
  text-align: center;
  padding: 56px 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
}
.empty .mark { width: 48px; height: 48px; margin: 0 auto; border-radius: 50%; }
.empty .mark .icon { width: 22px; height: 22px; }
.empty h2 { font-size: 18px; margin: 14px 0 6px; }
.empty p { color: var(--muted); margin: 0 auto 18px; max-width: 42ch; }

.pet-link { all: unset; cursor: pointer; display: block; width: 100%; min-width: 0; box-sizing: border-box; border-radius: 6px; }
.pet-head .pet-link { flex: 1 1 auto; width: auto; }
.pet-link:hover h2, .pet-link:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.pet-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.entry-btn { all: unset; cursor: pointer; display: block; border-radius: 6px; }
.entry-btn:hover .what b { text-decoration: underline; text-underline-offset: 3px; }
.entry-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.timeline .who { color: var(--muted); font-size: 12px; margin-left: auto; }
.timeline li.voided .what b, .timeline li.voided .detail { text-decoration: line-through; color: var(--muted); }

fieldset.plain { border: none; margin: 0; padding: 0; min-width: 0; display: grid; gap: 14px; }
fieldset.plain[disabled] input, fieldset.plain[disabled] select, fieldset.plain[disabled] textarea { background: var(--surface-2); color: var(--ink); opacity: 1; }
fieldset.plain[disabled] button { display: none; }
fieldset.plain[disabled] .vacc-edit .line { grid-template-columns: 1fr 160px; }
.vacc-edit { display: grid; gap: 8px; }
.vacc-edit .line { display: grid; grid-template-columns: 1fr 160px 34px; gap: 8px; align-items: center; }
.vacc-edit .line.expired input[type="date"] { border-color: var(--red); color: var(--red); }
.booklet { display: grid; gap: 8px; }
.booklet img { display: block; max-width: 100%; max-height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; }
.revisions:empty { display: none; }
.dlg-title-pet { display: inline-flex; align-items: center; gap: 10px; }

.members { list-style: none; margin: 0; padding: 0; display: grid; }
.member { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 150px auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.member:first-child { border-top: none; }
.member.inactive { opacity: 0.6; }
.member-who { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.member-who b { font-weight: 500; }
.member-who > span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.member > .chip:not(:empty) + select { grid-column: 4; }
.member select { padding: 7px 10px; }
@media (max-width: 640px) { .member { grid-template-columns: auto 1fr; } .member > :nth-child(n + 3) { grid-column: 2; justify-self: start; } }

.col-place { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--amber-soft); }
.chip-btn:hover { box-shadow: inset 0 0 0 1px var(--amber); }
.chip-btn .chip { background: var(--surface); }

.compare { display: grid; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; font-size: 13.5px; }
.compare-head, .compare-row { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 12px; padding: 8px 12px; }
.compare-head { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.compare-row + .compare-row { border-top: 1px solid var(--line); }
.compare-row > span:first-child { color: var(--muted); }
.compare-row b { font-weight: 500; }
.compare-row.changed { background: color-mix(in srgb, var(--amber-soft) 60%, transparent); }
.compare-row.changed b { color: var(--amber); }
.compare-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.compare-list small { display: block; color: var(--muted); margin-bottom: 4px; }
.compare-list p { margin: 0; }
@media (max-width: 560px) { .compare-head, .compare-row { grid-template-columns: 1fr 1fr; } .compare-head > :first-child, .compare-row > :first-child { grid-column: 1 / -1; } }

.import-table { display: grid; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; font-size: 13.5px; max-height: 50vh; overflow-y: auto; }
.import-row { display: grid; grid-template-columns: 56px minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; padding: 8px 12px; align-items: start; }
.import-row + .import-row { border-top: 1px solid var(--line); }
.import-row.head { background: var(--surface-2); color: var(--muted); font-weight: 500; position: sticky; top: 0; }
.import-row b { font-weight: 500; }
.import-row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.import-row.duplicate, .import-row.error { color: var(--muted); }
@media (max-width: 560px) { .import-row { grid-template-columns: 40px 1fr; } .import-row > :nth-child(n + 3) { grid-column: 2; } }

/* ---------- Doses ---------- */

.doses { padding: 6px 6px 8px; margin-bottom: 20px; }
.doses.has-late { border-color: color-mix(in srgb, var(--red) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 55%, transparent); }
.doses-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 12px 8px; }
.doses-head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.doses-head h2 .icon { color: var(--muted); }
.doses ul { list-style: none; margin: 0; padding: 0; display: grid; }
.dose { display: grid; grid-template-columns: 52px auto minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 12px; border-radius: var(--radius-sm); }
.dose + .dose { box-shadow: 0 -1px 0 var(--line); }
.dose time { font: 600 15px/1 var(--font); font-variant-numeric: tabular-nums; }
.dose-what { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; line-height: 1.3; }
.dose-what b { font-weight: 500; }
.dose-what span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dose-actions { display: flex; gap: 6px; }
.dose.late { background: var(--red-soft); box-shadow: none; }
.dose.late time { color: var(--red); }
.dose.due { background: var(--amber-soft); box-shadow: none; }
.dose.done, .dose.skipped { color: var(--muted); }
.dose.done time, .dose.skipped time { color: var(--muted); font-weight: 500; }
.dose.later .dose-actions .btn.primary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
@media (max-width: 560px) {
  .dose { grid-template-columns: 46px auto minmax(0, 1fr); }
  .dose > .chip, .dose-actions { grid-column: 2 / -1; justify-self: start; }
}

.dose-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.dose-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.dose-pill.done { background: var(--teal-soft); color: var(--teal); }
.dose-pill.late { background: var(--red); color: #fff; }
.dose-pill.due { background: var(--amber-soft); color: var(--amber); }

.evening {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}
.evening.all-sent { border-left-color: var(--teal); }
.evening .mark { background: var(--accent-soft); color: var(--accent); width: 38px; height: 38px; border-radius: 50%; }
.evening.all-sent .mark { background: var(--teal-soft); color: var(--teal); }
.evening div { flex: 1 1 200px; }
.evening b { font-size: 15px; font-weight: 600; }
.evening p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

.btn.postcard-cta { border-color: var(--brand); color: var(--brand); }

.med-edit { display: grid; gap: 8px; }
.med-edit .line { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr 34px; gap: 8px; align-items: center; }
@media (max-width: 560px) { .med-edit .line { grid-template-columns: 1fr 1fr 34px; } .med-edit .line input:first-child { grid-column: 1 / -1; } }

/* ---------- Postcard ---------- */

.pc { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.pc-photo img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.pc-nophoto { display: grid; place-items: center; gap: 10px; padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; background: var(--surface-2); }
.pc-body { padding: 16px 18px 18px; display: grid; gap: 12px; }
.pc-day { font: 400 22px/1.1 var(--serif); }
.pc-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.pc-lines li { padding-left: 14px; position: relative; }
.pc-lines li::before { content: ""; position: absolute; left: 0; top: 0.6em; width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
.pc-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.pc-thumbs button { width: 60px; height: 60px; padding: 0; border-radius: var(--radius-sm); overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.pc-thumbs button.active { border-color: var(--brand); }
.pc-thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Floor plan ---------- */

.occupancy { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.meter { flex: 1 1 200px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; max-width: 280px; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.occupancy b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; margin-left: auto; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid var(--line-strong); }

.plan {
  --row: 58px;
  --gap: 10px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: var(--row);
  gap: var(--gap);
  padding: 14px;
  background: radial-gradient(circle, var(--line-strong) 0.8px, transparent 1.2px) 0 0 / 20px 20px, var(--surface);
  min-height: 300px;
}
.plan.editing { outline: 1.5px dashed var(--brand); outline-offset: 3px; }

.room {
  position: relative;
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  background: var(--tint);
  border: 1px solid var(--line-strong);
  transition: box-shadow 0.15s;
}
.room[data-kind="room"] { --tint: var(--tint-room); }
.room[data-kind="cattery"] { --tint: var(--tint-cattery); }
.room[data-kind="yard"] { --tint: var(--tint-yard); }
.room[data-kind="home"] { --tint: var(--tint-home); }
.room-head { display: flex; align-items: center; gap: 8px; }
.room-head .icon { color: var(--muted); }
.room-head h3 { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-head .count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; overflow: auto; scrollbar-width: thin; padding: 2px; margin: -2px; }

.slot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 3px 10px 3px 3px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
  font-weight: 500;
  max-width: 100%;
  color: var(--ink);
}
.slot .label { color: var(--muted); font-weight: 400; }
.slot .names { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .stack { display: flex; }
.slot .stack .avatar + .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.slot.free { background: transparent; border-style: dashed; padding-left: 10px; color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; }
.slot.free:hover { border-color: var(--brand); color: var(--brand); }
.slot.partial .cap { color: var(--teal); }
.slot .cap { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.room-tools { position: absolute; top: 8px; right: 8px; display: none; gap: 4px; }
.plan.editing .room-tools { display: flex; }
.plan.editing .room-head .count { display: none; }
.plan.editing .room { cursor: grab; border-color: color-mix(in srgb, var(--brand) 50%, var(--line-strong)); }
.plan.editing .room.dragging { cursor: grabbing; box-shadow: var(--shadow-lg); z-index: 3; opacity: 0.94; }
.room-tools button { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.resize {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 18px;
  height: 18px;
  display: none;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 0 55%, var(--brand) 55% 61%, transparent 61% 72%, var(--brand) 72% 78%, transparent 78%);
}
.plan.editing .resize { display: block; }
.plan.editing .room.blocked { box-shadow: 0 0 0 2px var(--red); }

.plan-hint { color: var(--muted); font-size: 13px; margin: 12px 2px 0; display: flex; gap: 8px; align-items: center; }

@media (max-width: 860px) {
  .plan { display: flex; flex-direction: column; padding: 10px; }
  .plan .room { grid-area: auto !important; }
  .plan.editing .room { cursor: default; }
  .plan.editing .resize { display: none; }
  .legend { margin-left: 0; }
}

/* ---------- Stays ---------- */

.stay-list { display: grid; gap: 8px; }
.stay-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
}
.stay-row h3 { font-size: 15px; }
.stay-row .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stay-row .dates { font-size: 13.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.progress { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.row-actions { display: flex; gap: 4px; }
@media (max-width: 760px) {
  .stay-row { grid-template-columns: auto 1fr auto; row-gap: 10px; }
  .stay-row .col-dates { grid-column: 2 / 4; grid-row: 2; }
  .stay-row .col-place { grid-column: 2 / 4; grid-row: 3; }
  .stay-row .row-actions { grid-column: 3; grid-row: 1; }
}

.place-picker { display: grid; gap: 12px; }
.place-group h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.place-group .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.place-group label {
  position: relative;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  background: var(--surface);
}
.place-group input { position: absolute; opacity: 0; }
.place-group label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); box-shadow: 0 0 0 1px var(--brand); }
.place-group label.taken { opacity: 0.45; cursor: not-allowed; text-decoration: line-through; }

/* ---------- Settings ---------- */

.panel { padding: 22px; margin-bottom: 16px; max-width: 640px; }
.panel h2 { font-size: 16px; margin-bottom: 4px; }
.panel > p { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.panel .fields { margin-bottom: 16px; }

/* ---------- Dialogs ---------- */

dialog {
  border: 1px solid var(--line);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog.wide { width: min(700px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(15 18 20 / 0.45); }
dialog[open] { animation: rise 0.18s ease-out; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
dialog form { display: flex; flex-direction: column; max-height: inherit; }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 4px; }
.dlg-head h2 { font-size: 17px; flex: 1; }
.dlg-body { padding: 14px 20px; overflow: auto; display: grid; gap: 18px; grid-auto-rows: max-content; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.dlg-foot .spacer { margin-right: auto; }
.section-title { font: 600 11.5px/1 var(--font); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 4px 0 -6px; }

.photo-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
}
.photo-drop:hover { border-color: var(--brand); color: var(--brand); }
.photo-drop input { display: none; }
.photo-drop img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; }
.toggle { display: flex; align-items: center; gap: 12px; font-size: 14px; cursor: pointer; }
.toggle input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--line-strong); border: none; position: relative; padding: 0; flex: none; cursor: pointer; transition: background 0.15s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.2); transition: transform 0.15s; }
.toggle input:checked { background: var(--brand); }
.toggle input:checked::after { transform: translateX(16px); }
.toggle span { display: inline-flex; align-items: center; gap: 6px; }

.place-edit { display: grid; gap: 8px; }
.place-edit .line { display: grid; grid-template-columns: 1fr 88px 34px; gap: 8px; align-items: center; }

@media (max-width: 860px) {
  dialog, dialog.wide {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
    max-height: 92dvh;
  }
  dialog[open] { animation: sheet 0.22s ease-out; }
  .dlg-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
@keyframes sheet { from { transform: translateY(100%); } }

/* ---------- Toast ---------- */

.toasts { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.2s ease-out;
}
.toast.error { background: var(--red); color: #fff; }
@media (max-width: 860px) { .toasts { bottom: calc(88px + env(safe-area-inset-bottom)); } }

.loading { display: grid; place-items: center; min-height: 100dvh; color: var(--brand); animation: pulse 1.2s infinite; }
.loading .icon { width: 32px; height: 32px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
