:root {
  --ink: #173126;
  --muted: #66766d;
  --paper: #f5f6ef;
  --panel: #ffffff;
  --forest: #123d2a;
  --leaf: #347352;
  --lime: #b8da7c;
  --blue: #82b8bc;
  --coral: #db7862;
  --amber: #e5b84f;
  --line: #dfe5da;
  --shadow: 0 14px 40px rgba(26, 56, 40, .07);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100vh; margin: 0; background: linear-gradient(180deg, #f8f9f3 0, var(--paper) 45%); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  gap: 34px;
  min-height: 72px;
  padding: 10px max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(223, 229, 218, .85);
  background: rgba(248, 249, 243, .88);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  background: var(--forest);
  color: white;
  font-family: Georgia, serif;
  font-size: 24px;
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .08em; font-size: 14px; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.desktop-nav { display: flex; flex: 1; gap: 8px; }
.desktop-nav a { padding: 10px 13px; border-radius: 12px; color: #42564b; font-size: 14px; }
.desktop-nav a:hover { background: #e9eee4; color: var(--forest); }
.text-button, .link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--leaf);
  cursor: pointer;
}

.page { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 100px; }
.hero-row, .detail-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 34px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 5vw, 58px); font-weight: 500; line-height: 1.02; letter-spacing: -.035em; }
h2 { margin-bottom: 16px; font-size: 20px; }
h3 { margin-bottom: 7px; font-size: 18px; }
.eyebrow { margin-bottom: 9px; color: var(--leaf); font-size: 12px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.lead { max-width: 720px; color: var(--muted); font-size: 18px; line-height: 1.55; }
.muted { color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--leaf); font-size: 14px; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 700;
}
.button.primary { background: var(--forest); color: #fff; box-shadow: 0 8px 22px rgba(18, 61, 42, .18); }
.button.primary:hover { background: #0a2e1e; }
.button.secondary { border-color: #b8c8bc; background: #fff; color: var(--forest); }
.button.quiet { background: #e9eee4; color: var(--forest); }
.button.danger { border-color: #efc7be; background: #fff4f1; color: #9a3f2d; }
.button.wide { width: 100%; }

.dashboard-section { margin-top: 42px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading > div { display: flex; align-items: center; gap: 10px; }
.section-heading h2 { margin: 0; }
.section-heading a { color: var(--leaf); font-size: 14px; }
.section-dot { width: 10px; height: 10px; border-radius: 50%; }
.section-dot.lime { background: var(--lime); }
.section-dot.blue { background: var(--blue); }
.section-dot.coral { background: var(--coral); }
.section-dot.amber { background: var(--amber); }
.count { display: grid; min-width: 28px; height: 28px; place-items: center; border-radius: 20px; background: #e8ede3; font-size: 13px; }
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.plan-card, .fact-card, .product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 5px 20px rgba(26, 56, 40, .035);
}
.plan-card:hover, .product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); transition: .18s ease; }
.plan-card > a, .fact-card > a { display: block; padding: 20px; }
.plan-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.plan-card-top time { color: var(--muted); font-size: 14px; }
.plan-card p { margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.status-pill, .chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: #edf2e7;
  color: #315744;
  font-size: 11px;
  font-weight: 750;
}
.status-completed { background: #dcebdc; color: #28613c; }
.status-transferred { background: #e7eef0; color: #3d6570; }
.status-skipped { background: #f2e8e3; color: #885343; }
.status-pill.warning, .chip.warning { background: #fff0c8; color: #7b5611; }
.muted-pill { background: #e8e8e8; color: #5a5a5a; }
.mixture-line { display: flex; flex-wrap: wrap; gap: 5px; }
.mixture-line span { padding: 5px 8px; border-radius: 8px; background: #f2f5ef; color: #4e6155; font-size: 12px; }
.empty-state { display: flex; min-height: 150px; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 24px; border: 1px dashed #cbd6c9; border-radius: var(--radius); color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }
.empty-state.compact { min-height: 90px; }
.fact-card.warning { border-color: #ead59e; background: #fffbef; }
.fact-card span { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }

.calendar-toolbar { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--leaf); font-size: 14px; }
.calendar-scroll { overflow-x: auto; padding-bottom: 8px; }
.calendar-grid { display: grid; min-width: 860px; grid-template-columns: repeat(7, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--line); }
.weekday { padding: 12px; background: #eaf0e6; color: var(--muted); text-align: center; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.calendar-day { min-height: 130px; padding: 9px; background: #fff; }
.calendar-day.outside { background: #f2f4ef; color: #9aa69f; }
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--leaf); }
.day-number { display: grid; width: 26px; height: 26px; place-items: center; margin-bottom: 7px; border-radius: 50%; font-size: 13px; }
.today .day-number { background: var(--forest); color: white; }
.day-plans { display: grid; gap: 5px; }
.calendar-event { display: block; padding: 6px 7px; border-left: 3px solid var(--leaf); border-radius: 7px; background: #eef4ea; font-size: 10px; }
.calendar-event strong, .calendar-event span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event span { margin-top: 2px; color: var(--muted); }
.calendar-event.status-completed { border-color: #66a77c; background: #edf7ef; }
.calendar-event.status-transferred, .calendar-event.status-skipped { opacity: .56; }

.narrow-page { width: min(680px, 100%); margin: 0 auto; }
.narrow-page.wide-form { width: min(900px, 100%); }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 4px 18px rgba(26, 56, 40, .035); }
.stack-form { display: grid; gap: 18px; }
.stack-form > div, .field-wrap { display: grid; gap: 7px; }
.stack-form label, .field-wrap > label { font-size: 13px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cdd7cf;
  border-radius: 11px;
  outline: 0;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(52, 115, 82, .12); }
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 18px; accent-color: var(--leaf); }
.stack-form ul { margin: 0; padding: 0; list-style: none; }
.stack-form ul li { display: flex; align-items: center; gap: 7px; margin: 5px 0; }
.stack-form ul li label { display: flex; align-items: center; gap: 7px; font-weight: 500; }
.form-actions, .sticky-actions { display: flex; gap: 10px; }
.sticky-actions { position: sticky; z-index: 10; bottom: 14px; justify-content: flex-end; padding: 12px; border: 1px solid rgba(223,229,218,.9); border-radius: 16px; background: rgba(248,249,243,.92); backdrop-filter: blur(12px); }
.form-section h2 { margin-bottom: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 24px; }
.field-description, .field-groups, .field-weather_comment, .field-notes { grid-column: 1 / -1; }
.mixture-forms { display: grid; gap: 12px; margin: 20px 0 12px; }
.mixture-form { padding: 16px; border: 1px solid #dce4db; border-radius: 15px; background: #f9faf6; }
.mixture-fields { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.delete-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; color: #8c4a3c; }
.remove-mixture { margin-top: 10px; color: #8c4a3c; }
.dose-hint { min-height: 17px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.warning-text { color: #a35f13; font-weight: 700; }
.errorlist, .error-text { margin: 4px 0 0; color: #a23f2e; font-size: 13px; }

.detail-head { align-items: flex-start; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 18px; }
.detail-head .chips { margin: 8px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mixture-summary { display: grid; }
.mixture-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.mixture-summary-row:last-child { border-bottom: 0; }
.mixture-summary-row strong, .mixture-summary-row span { display: block; }
.mixture-summary-row span { margin-top: 4px; color: var(--muted); font-size: 13px; }
.dose { flex: 0 0 auto; padding: 9px 11px; border-radius: 10px; background: #eef3ea; text-align: right; font-weight: 750; }
.dose small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.dose-warning { background: #fff0c8; color: #7b5611; }
.action-stack { display: grid; gap: 9px; margin-top: 22px; }
.weather-panel dl { margin: 0 0 20px; }
.weather-panel dl div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.weather-panel dt { color: var(--muted); }
.weather-panel dd { margin: 0; font-weight: 700; text-align: right; }

.filter-bar { display: grid; grid-template-columns: minmax(240px, 1fr) 220px auto; gap: 10px; margin-bottom: 22px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.filter-bar.multi { grid-template-columns: repeat(5, 1fr) auto; }
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.product-card { display: block; padding: 22px; }
.product-card h2 { margin: 16px 0 8px; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.product-card p { min-height: 48px; color: var(--muted); line-height: 1.5; }
.norm-card { display: grid; gap: 5px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.norm-card:last-child { border-bottom: 0; }
.norm-card .norm-main { color: var(--forest); font-family: Georgia, serif; font-size: 24px; }
.norm-card small { color: var(--muted); }
.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row strong, .list-row span { display: block; }
.list-row span { margin-top: 4px; color: var(--muted); font-size: 13px; }
.list-row.archived { opacity: .52; }
.row-actions { display: flex; gap: 14px; color: var(--leaf); font-size: 14px; }
.timeline { display: grid; gap: 12px; }
.timeline-item { display: grid; grid-template-columns: 70px 1fr; gap: 20px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.timeline-item > time { text-align: center; }
.timeline-item > time strong, .timeline-item > time span { display: block; }
.timeline-item > time strong { font-family: Georgia, serif; font-size: 36px; font-weight: 500; }
.timeline-item > time span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.timeline-item h2 { margin: 10px 0 5px; }
.timeline-item p { color: var(--muted); }

.login-shell { display: grid; min-height: calc(100vh - 190px); place-items: center; }
.login-card { width: min(460px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 28px; background: #fff; box-shadow: var(--shadow); }
.login-card h1 { font-size: 44px; }
.login-card .stack-form { margin-top: 26px; }
.messages { display: grid; gap: 8px; margin-bottom: 20px; }
.message { padding: 12px 15px; border-radius: 12px; background: #e5efe5; color: #2f5b3d; }
.message.error { background: #fff0ed; color: #8f3f30; }
.message.warning { background: #fff4d7; color: #785817; }
.mobile-nav { display: none; }

@media (max-width: 860px) {
  .desktop-nav { display: none; }
  .topbar { min-height: 62px; padding: 8px 18px; }
  .topbar > form { margin-left: auto; }
  .page { width: min(100% - 24px, 720px); padding: 30px 0 100px; }
  .hero-row, .detail-head { align-items: flex-start; }
  .card-grid, .product-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .filter-bar, .filter-bar.multi { grid-template-columns: repeat(2, 1fr); }
  .mobile-nav {
    position: fixed;
    z-index: 50;
    right: 10px;
    bottom: 10px;
    left: 10px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    min-height: 66px;
    padding: 6px;
    border: 1px solid rgba(208, 219, 207, .9);
    border-radius: 22px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 15px 45px rgba(16, 52, 35, .18);
    backdrop-filter: blur(16px);
  }
  .mobile-nav a { display: grid; place-items: center; gap: 2px; color: var(--muted); font-size: 10px; }
  .mobile-nav a span { font-size: 21px; line-height: 1; }
  .mobile-nav .add { width: 48px; height: 48px; justify-self: center; border-radius: 17px; background: var(--forest); color: white; font-size: 30px; box-shadow: 0 8px 20px rgba(18, 61, 42, .25); }
}

@media (max-width: 600px) {
  h1 { font-size: 38px; }
  .brand small { display: none; }
  .hero-row, .detail-head { display: grid; gap: 18px; margin-bottom: 24px; }
  .hero-row .button, .detail-head .button { width: 100%; }
  .card-grid, .product-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; border-radius: 17px; }
  .form-grid, .mixture-fields { grid-template-columns: 1fr; }
  .field-description, .field-groups, .field-weather_comment, .field-notes { grid-column: auto; }
  .sticky-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .mixture-summary-row { align-items: flex-start; }
  .filter-bar, .filter-bar.multi { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 52px 1fr; padding: 17px; }
  .timeline-item > time strong { font-size: 30px; }
  .list-row { align-items: flex-start; }
  .row-actions { flex-direction: column; align-items: flex-end; }
  .login-card { padding: 26px; border-radius: 22px; }
}
