:root {
  --ink: #17211b;
  --muted: #6f7b73;
  --paper: #f5f2e9;
  --card: #fffdf7;
  --green: #2f6d4f;
  --green-soft: #dce9de;
  --orange: #de7847;
  --line: #dcd9cf;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, select, input { font: inherit; }

.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 48px; }
.hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 32px; }
.hero-actions { display: flex; align-items: center; gap: 10px; }
#install-app { background: var(--ink); color: white; }
.eyebrow, .label { margin: 0 0 10px; font-size: 11px; font-weight: 800; letter-spacing: .18em; color: var(--green); }
h1 { margin: 0; max-width: 760px; font-family: Georgia, serif; font-size: clamp(30px, 4vw, 46px); font-weight: 500; line-height: 1.12; letter-spacing: -.03em; }
.lede { margin: 10px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid #b9cfbd; border-radius: 999px; color: var(--green); background: var(--green-soft); font-weight: 700; white-space: nowrap; }
.status-pill span { width: 8px; height: 8px; border-radius: 50%; background: #3b9b66; box-shadow: 0 0 0 5px rgba(59,155,102,.12); }

.toolbar { margin-top: 24px; padding: 14px 0; display: grid; grid-template-columns: 1fr 1fr auto; gap: 24px; align-items: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.toolbar p { margin: 0; }
.toolbar .label { margin-bottom: 5px; color: var(--muted); }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.toolbar-actions button { white-space: nowrap; }
.value { font-weight: 700; }
button, select { border: 1px solid var(--ink); border-radius: 999px; background: transparent; color: var(--ink); padding: 12px 18px; cursor: pointer; }
button:hover { background: var(--ink); color: white; }
button:disabled { opacity: .5; cursor: wait; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e3ebdf, var(--paper) 55%); }
.login-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 30px; background: var(--card); box-shadow: 0 24px 80px rgba(23,33,27,.12); }
.login-card img { width: 64px; height: 64px; margin-bottom: 26px; border-radius: 16px; }
.login-card h1 { font-size: 50px; }
.login-card > p:not(.eyebrow, .login-error) { margin: 18px 0 28px; color: var(--muted); line-height: 1.6; }
.login-card label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.login-card input { width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--ink); }
.login-card button { width: 100%; margin-top: 12px; background: var(--ink); color: white; }
.login-error { min-height: 20px; margin: 12px 0 0; color: #9c3c2e; font-size: 13px; }

.range-panel { margin: 22px 0 0; padding: 26px; display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr); gap: 30px; align-items: center; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,253,247,.72); }
.range-panel h2 { font-size: 30px; }
.range-panel p { margin-bottom: 0; }
#range-caption { margin-top: 8px; color: var(--muted); font-size: 14px; }
.range-actions { min-width: 0; }
.preset-group { display: flex; gap: 7px; padding: 6px; border-radius: 999px; background: #ebe7dc; }
.preset-group button { flex: 1; padding: 9px 12px; border-color: transparent; white-space: nowrap; }
.preset-group button:hover, .preset-group button.active { border-color: var(--ink); background: var(--ink); color: white; }
.custom-range { display: flex; align-items: end; gap: 9px; margin-top: 12px; }
.custom-range label { flex: 1; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.custom-range input { width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); }
.custom-range button { padding: 10px 16px; }
.range-help { margin: 9px 6px 0 !important; color: var(--muted); font-size: 11px; }

.notice { min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.notice.error { color: #9c3c2e; }
.loader { width: 20px; height: 20px; border: 2px solid #cad0c9; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.summary { margin: 16px 0 24px; display: flex; flex-wrap: wrap; gap: 20px; }
.summary article { display: flex; align-items: baseline; gap: 6px; }
.summary strong { font-size: 18px; font-weight: 700; }
.summary span { color: var(--muted); font-size: 13px; }

.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 20px; }
h2 { margin: 0; font-family: Georgia, serif; font-size: 32px; font-weight: 500; }
.section-heading select { min-width: 180px; background: var(--card); }
.device-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.device-card { padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: 0 12px 30px rgba(31, 42, 34, .04); }
.device-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.device-card h3 { margin: 4px 0 5px; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.device-card p { margin: 0; color: var(--muted); }
.state { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #a6aaa7; }
.state.online::before { background: #3b9b66; }
.metadata { margin-top: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.metadata dt { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.metadata dd { margin: 5px 0 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }
.view-details { width: 100%; margin-top: 22px; background: var(--ink); color: white; }
.view-details:hover { background: var(--green); border-color: var(--green); }
.empty { grid-column: 1 / -1; padding: 56px; text-align: center; border: 1px dashed var(--line); border-radius: 22px; color: var(--muted); }

.detail-panel { margin-top: 24px; padding: 24px; border-radius: 24px; background: #e7e2d5; }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.detail-heading p { margin: 7px 0 0; color: var(--muted); }
.detail-actions { display: flex; align-items: center; gap: 10px; }
.unit-toggle { display: flex; padding: 4px; border-radius: 999px; background: rgba(255,255,255,.68); }
.unit-toggle button { min-width: 52px; padding: 8px 13px; border-color: transparent; }
.unit-toggle button:hover, .unit-toggle button.active { border-color: var(--ink); background: var(--ink); color: white; }
.fact-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 28px 0; }
.fact { padding: 17px; border-radius: 16px; background: rgba(255,255,255,.62); }
.fact span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.fact strong { overflow-wrap: anywhere; font-size: 14px; }
.detail-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.data-card { padding: 22px; border-radius: 20px; background: var(--card); }
.data-card.wide { grid-column: 1 / -1; }
.analytics-card { overflow: hidden; }
.card-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-heading h3 { margin: 0; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.card-heading span { color: var(--muted); font-size: 12px; }
.timeline { display: grid; }
.timeline-event { border-top: 1px solid var(--line); }
.timeline-event:first-child { border-top: 0; }
.timeline-event summary { display: grid; grid-template-columns: 150px minmax(180px, 1fr) auto auto 18px; gap: 16px; align-items: center; padding: 15px 0; cursor: pointer; list-style: none; }
.timeline-event summary::-webkit-details-marker { display: none; }
.timeline-event summary:hover .timeline-title { color: var(--green); }
.timeline-time { color: var(--muted); font-size: 13px; }
.timeline-title { font-weight: 750; }
.timeline-pet { color: var(--green); font-size: 13px; font-weight: 700; }
.weight-badge { padding: 6px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 800; white-space: nowrap; }
.event-toggle { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .18s ease; }
.timeline-event[open] .event-toggle { transform: rotate(225deg); }
.event-detail { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 0 0 18px 166px; }
.event-detail div { padding: 12px; border-radius: 12px; background: #f0ede4; }
.event-detail span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.event-detail strong { font-size: 12px; overflow-wrap: anywhere; }
.chart-wrap { position: relative; width: 100%; height: 320px; }
.chart-empty { height: 100%; display: grid; place-items: center; border-radius: 16px; background: #f0ede4; color: var(--muted); }
.interaction-hint { margin: -8px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.history-status { margin: 12px 0; color: var(--muted); font-size: 12px; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #9b6a21; outline-offset: 3px; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.calendar-weekdays { margin-bottom: 7px; }
.calendar-weekdays span { padding: 0 6px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.calendar-day { min-width: 0; min-height: 92px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #f5f2e9; text-align: left; }
.calendar-day:hover { background: #c8ddcc; color: var(--ink); }
.calendar-day.selected { outline: 3px solid var(--ink); outline-offset: -3px; }
.calendar-day.blank { border-color: transparent; background: transparent; }
.calendar-day span, .calendar-day small { display: block; color: var(--muted); font-size: 10px; }
.calendar-day strong { display: block; margin: 9px 0 5px; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.calendar-day.level-1 { background: #e7f0e7; }
.calendar-day.level-2 { background: #cee2d1; }
.calendar-day.level-3 { background: #9fc5aa; }
.calendar-day.level-4 { border-color: var(--green); background: var(--green); color: white; }
.calendar-day.level-4 span, .calendar-day.level-4 small { color: rgba(255,255,255,.72); }
.calendar-legend { display: flex; align-items: center; gap: 7px; margin: 14px 0 0; color: var(--muted); font-size: 11px; }
.calendar-legend span { width: 10px; height: 10px; border-radius: 3px; background: var(--green); }
.calendar-legend .legend-selected { margin-left: 10px; background: transparent; border: 2px solid var(--ink); }
.day-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.day-heading h3 { margin: 0; font-family: Georgia, serif; font-size: 26px; font-weight: 500; }
.time-zone-label { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.day-navigation { display: flex; gap: 8px; }
.day-navigation button { padding: 8px 12px; min-width: 44px; min-height: 44px; }
.day-stats { display: flex; gap: 32px; margin: 22px 0 14px; }
.day-stats span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.day-stats strong { font-size: 24px; font-weight: 650; }
.visit-note { color: var(--muted); font-size: 12px; line-height: 1.6; }
.day-visits { display: grid; gap: 8px; margin-top: 18px; }
.visit-row { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 16px; width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 16px; text-align: left; background: #f7f4ed; }
.visit-row:hover, .visit-row.selected { border-color: var(--green); background: #e5eee4; color: var(--ink); }
.visit-row.selected { box-shadow: inset 3px 0 var(--green); }
.visit-time { font-size: 14px; font-weight: 650; }
.visit-description strong { display: block; font-size: 14px; }
.visit-description small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.visit-weight { font-size: 16px; color: var(--green); white-space: nowrap; }
.day-empty { padding: 24px; text-align: center; color: var(--muted); background: #f7f4ed; border-radius: 14px; font-size: 14px; }
.secondary-details { grid-column: 1 / -1; border-radius: 20px; background: rgba(255,255,255,.5); overflow: hidden; }
.secondary-details > summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; cursor: pointer; list-style: none; }
.secondary-details > summary::-webkit-details-marker { display: none; }
.secondary-details > summary::after { content: "+"; display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-size: 20px; }
.secondary-details[open] > summary::after { content: "−"; }
.secondary-details > summary span:first-child { display: grid; gap: 4px; }
.secondary-details > summary strong { font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.secondary-details > summary small, .secondary-details > summary > span:last-of-type { color: var(--muted); font-size: 12px; }
.secondary-content { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 14px 14px; }
.secondary-content .wide { grid-column: 1 / -1; }
.stack-list { display: grid; gap: 10px; }
.stack-item { padding: 13px; border-radius: 13px; background: #f0ede4; }
.stack-item strong { display: block; margin-bottom: 4px; font-size: 14px; }
.stack-item span { color: var(--muted); font-size: 12px; }

.pets-section { margin-top: 64px; }
.pet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.pet-card { display: grid; grid-template-columns: 72px 1fr; gap: 18px; align-items: center; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.pet-avatar { width: 72px; height: 72px; object-fit: cover; border-radius: 50%; background: var(--green-soft); }
.pet-card h3 { margin: 0 0 4px; font-family: Georgia, serif; font-size: 26px; font-weight: 500; }
.pet-card p { margin: 3px 0; color: var(--muted); font-size: 13px; }

@media (max-width: 700px) {
  .shell { padding-top: 20px; }
  .hero { flex-direction: column; }
  .hero-actions { width: 100%; justify-content: space-between; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar button { grid-column: 1 / -1; }
  .toolbar-actions { grid-column: 1 / -1; }
  .toolbar-actions button { flex: 1; }
  .range-panel { grid-template-columns: 1fr; padding: 20px; }
  .preset-group { display: grid; grid-template-columns: 1fr 1fr; border-radius: 18px; }
  .custom-range { align-items: stretch; flex-direction: column; }
  .device-grid { grid-template-columns: 1fr; }
  .detail-columns, .pet-grid { grid-template-columns: 1fr; }
  .fact-row { grid-template-columns: 1fr 1fr; }
  .timeline-event summary { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .timeline-time, .timeline-title, .timeline-pet { grid-column: 1; }
  .weight-badge { grid-column: 2; grid-row: 1 / span 2; }
  .event-toggle { grid-column: 2; justify-self: end; }
  .event-detail { grid-template-columns: 1fr 1fr; padding-left: 0; }
  .calendar-weekdays, .calendar-grid { gap: 4px; }
  .calendar-day { min-height: 78px; padding: 7px; }
  .calendar-day strong { font-size: 22px; }
  .calendar-day small { display: none; }
  .detail-panel { padding: 14px; margin-inline: -8px; }
  .data-card { padding: 18px 14px; }
  .card-heading { align-items: flex-start; flex-direction: column; gap: 6px; margin-bottom: 18px; }
  .card-heading h3 { font-size: 25px; }
  .chart-wrap { height: 280px; }
  .visit-row { grid-template-columns: 1fr auto; gap: 7px 12px; padding: 14px; }
  .visit-time { grid-column: 1; }
  .visit-description { grid-column: 1; grid-row: 2; }
  .visit-weight { grid-column: 2; grid-row: 1 / span 2; }
  .day-heading h3 { font-size: 23px; }
  .calendar-day span { font-size: 9px; }
  .calendar-day { padding: 6px 4px; }
  .detail-heading { flex-direction: column; }
  .detail-actions { width: 100%; justify-content: space-between; }
  .secondary-content { grid-template-columns: 1fr; }
  .secondary-content .wide { grid-column: auto; }
  .section-heading { align-items: flex-start; gap: 20px; flex-direction: column; }
}

