/* mmead web — Apple-style layout in the Mjolnir Mead brand palette (matches mmead.co):
   slate navy #232a33, parchment cream #f1e6cf, gold #e3b04b; Cormorant headings, Inter body. */

@font-face { font-family: "Inter"; src: url("fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url("fonts/cormorant-600-latin.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url("fonts/cormorant-700-latin.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg: #232a33;              /* mmead.co background */
  --card: #2b333e;
  --card-2: #323b47;
  --raised: #3b4552;          /* mmead.co secondary surface */
  --text: #f1e6cf;            /* mmead.co foreground (parchment) */
  --muted: rgba(241, 230, 207, .68);
  --faint: rgba(241, 230, 207, .5);
  --line: rgba(241, 230, 207, .1);
  --line-strong: rgba(241, 230, 207, .2);
  --accent: #e3b04b;          /* mmead.co primary (gold) */
  --accent-strong: #d99c22;   /* mmead.co hover gold */
  --accent-soft: rgba(227, 176, 75, .15);
  --on-accent: #232a33;       /* navy text on gold buttons, as on mmead.co */
  --blue: #8fb8e6;
  --green: #9ccc84;
  --green-soft: rgba(156, 204, 132, .15);
  --red: #f08a7a;
  --red-soft: rgba(240, 138, 122, .14);
  --yellow: #e3b04b;
  --yellow-soft: rgba(227, 176, 75, .15);
  --gray-soft: rgba(241, 230, 207, .08);
  --nav-bg: rgba(35, 42, 51, .8);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .28);
  --radius: 18px;
  --radius-sm: 12px;
  --field: rgba(241, 230, 207, .06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --serif: "Cormorant", "Cormorant Garamond", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.47; letter-spacing: -.01em; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.005em; font-family: var(--serif); font-weight: 700; }
h1 { font-size: 40px; font-weight: 700; line-height: 1.08; }
h2 { font-size: 25px; font-weight: 700; }
h3 { font-size: 20px; font-weight: 700; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
.hidden { display: none !important; }

/* ── navigation ─────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 20; height: 52px; display: flex; align-items: center;
  gap: 28px; padding: 0 max(20px, calc((100vw - 1120px) / 2));
  background: var(--nav-bg); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-weight: 700; color: var(--text);
  font-size: 21px; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; display: block;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
.nav-links { display: flex; gap: 22px; flex: 1; }
.nav-links a { color: var(--muted); font-size: 14px; font-weight: 500; padding: 6px 0; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--text); }
.nav form { margin: 0; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.linkbtn:hover { color: var(--text); }

.tabbar { display: none; }
@media (max-width: 760px) {
  .nav { gap: 12px; }
  .nav-links { display: none; }
  .tabbar {
    display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--nav-bg); backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--faint); font-size: 10.5px; font-weight: 500; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--accent); }
  .tabbar svg { width: 24px; height: 24px; }
}

/* ── layout ─────────────────────────────────────────────────────────────── */
main { max-width: 1120px; margin: 0 auto; padding: 28px 20px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.calc-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; align-items: start; }
.calc-layout .inputs { position: sticky; top: 72px; }
@media (max-width: 980px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calc-layout { grid-template-columns: 1fr; }
  .calc-layout .inputs { position: static; }
}
@media (max-width: 760px) {
  main { padding: 18px 14px 28px; }
  h1 { font-size: 28px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── cards ──────────────────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .faint { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 18px 22px 0; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 26px 4px 10px; }

/* key/value rows inside result cards */
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.kv .n { display: block; color: var(--faint); font-size: 12.5px; font-weight: 400; text-align: right; }
.note { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }
.callout { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.callout.warn { background: var(--yellow-soft); color: var(--text); }
.callout.info { background: var(--accent-soft); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--muted); }

/* ── forms ──────────────────────────────────────────────────────────────── */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 2px 6px; }
/* Fields match mmead.co: navy fill, 1px #3b4552 border, 4px corners, 0.8rem padding. */
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background-color: var(--bg);
  border: 1px solid var(--raised); border-radius: 4px; padding: .8rem; min-height: 46px;
  outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none; color-scheme: dark;
}
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: rgba(241, 230, 207, .35); }
select {
  cursor: pointer; padding-right: 2.6rem;
  /* gold chevron */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23e3b04b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .95rem center; background-size: 12px 8px;
}
/* the opened list: solid navy + cream so options are always readable (Windows/Linux draw it from these) */
select option, select optgroup { background-color: var(--bg); color: var(--text); }
select option:checked { background-color: var(--raised); color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type="date"], input[type="datetime-local"] { min-height: 46px; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: invert(.85) sepia(.6) saturate(3) hue-rotate(5deg); cursor: pointer; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 46px; }
.input-suffix em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-style: normal; color: var(--faint); font-size: 14px; pointer-events: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit;
  font-size: 15px; font-weight: 500; border: 0; border-radius: 980px; padding: 9px 18px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font-weight: 600; transition: background .15s, transform .05s;
  white-space: nowrap; }
.btn:hover { background: var(--accent-strong); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.ghost { background: transparent; color: var(--accent); padding-left: 10px; padding-right: 10px; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger:hover { background: rgba(240, 138, 122, .24); }
.btn.small { font-size: 13px; padding: 6px 13px; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.icon-btn { background: none; border: 0; color: var(--faint); cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--red); background: var(--red-soft); }
form.inline { display: inline; margin: 0; }

/* segmented control */
.segmented { display: inline-flex; background: var(--gray-soft); border-radius: 10px; padding: 2px; gap: 2px; }
.segmented a, .segmented label { padding: 6px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  color: var(--text); cursor: pointer; white-space: nowrap; }
.segmented a:hover { text-decoration: none; }
.segmented a.on, .segmented input:checked + span { background: var(--raised); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.segmented label { position: relative; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented label { padding: 0; }
.segmented label span { display: block; padding: 6px 14px; border-radius: 8px; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 980px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.planned { background: var(--gray-soft); color: var(--muted); }
.pill.in_progress { background: var(--yellow-soft); color: var(--yellow); }
.pill.complete { background: var(--green-soft); color: var(--green); }
.pill.aborted { background: var(--red-soft); color: var(--red); }
.count { color: var(--faint); font-weight: 500; margin-left: 4px; }

/* ── batch list ─────────────────────────────────────────────────────────── */
.batch-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.batch-card { display: block; color: var(--text); background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; transition: transform .15s, box-shadow .15s; }
.batch-card:hover { text-decoration: none; transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 14px 32px rgba(0,0,0,.09); }
.batch-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.batch-card h3 { font-size: 18px; }
.batch-card .meta { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.batch-card .figures { display: flex; gap: 22px; margin-top: 16px; }
.batch-card .figures div { display: flex; flex-direction: column; }
.batch-card .figures b { font-size: 17px; font-variant-numeric: tabular-nums; }
.batch-card .figures span { font-size: 12px; color: var(--faint); }
.progress { height: 6px; background: var(--gray-soft); border-radius: 6px; overflow: hidden; margin-top: 14px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #f0c870, var(--accent));
  border-radius: 6px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* ── tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase;
  letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 650; border-top: 1px solid var(--line-strong); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--card-2); }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 22px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 22px; }

/* timeline (logbook) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 20px; bottom: 2px; width: 1px; background: var(--line-strong); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12.5px; color: var(--faint); display: flex; justify-content: space-between; }
.timeline p { margin: 3px 0 0; white-space: pre-wrap; }

/* ── chart ──────────────────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart .ref { stroke-width: 1.2; stroke-dasharray: 5 5; }
.chart .ref.og { stroke: var(--faint); }
.chart .ref.fg { stroke: var(--green); }
.chart .reflabel { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .garea { fill: var(--accent-soft); }
.chart .gline { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .gdot { fill: var(--card); stroke: var(--accent); stroke-width: 2.5; }
.chart .temp { fill: none; stroke: var(--blue); stroke-width: 1.5; stroke-dasharray: 2 4; opacity: .7; }
.chart .tdot { fill: var(--blue); opacity: .75; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* ── guide ──────────────────────────────────────────────────────────────── */
.phase { margin-top: 22px; }
.phase:first-child { margin-top: 0; }
.phase h3 { font-size: 15px; color: var(--accent); margin-bottom: 8px; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; }
.step b { display: block; font-weight: 600; }
.step span { color: var(--muted); font-size: 14px; }

/* ── calendar ───────────────────────────────────────────────────────────── */
.cal { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.cal th { text-align: center; }
.cal td { height: 104px; padding: 6px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; }
.cal td:last-child { border-right: 0; }
.cal .d { font-size: 13px; font-weight: 600; color: var(--muted); display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%; }
.cal .other .d { color: var(--line-strong); }
.cal .today .d { background: var(--accent); color: var(--on-accent); }
.cal .ev { display: block; font-size: 12px; font-weight: 500; padding: 2px 7px; border-radius: 6px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--gray-soft); color: var(--text); }
.cal .ev.batch { background: var(--accent-soft); color: var(--accent-strong); }
.cal .ev.honey_harvest { background: var(--yellow-soft); }
.cal .ev.reminder { background: rgba(143, 184, 230, .16); }
.cal .ev.ksuite { background: rgba(143, 184, 230, .18); color: var(--text); }
.cal .ev.schedule { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px rgba(227, 176, 75, .45); }
@media (max-width: 760px) {
  .cal td { height: 64px; padding: 3px; }
  .cal .ev { font-size: 0; height: 6px; padding: 0; border-radius: 3px; }
}

/* ── dialogs (sheets) ───────────────────────────────────────────────────── */
dialog { border: 0; padding: 0; background: var(--card); color: var(--text); border-radius: 22px;
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0, 0, 0, .32); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog[open] { animation: pop .22s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 6px; }
.sheet-body { padding: 10px 22px 22px; overflow-y: auto; max-height: calc(100vh - 140px); }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.close { background: var(--gray-soft); border: 0; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1; }
@media (max-width: 760px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92vh;
    padding-bottom: env(safe-area-inset-bottom); }
  dialog[open] { animation: up .28s cubic-bezier(.2, .9, .3, 1); }
  @keyframes up { from { transform: translateY(100%); } to { transform: none; } }
}

/* ── login ──────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 34px 30px; text-align: center; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 16px; display: block;
  box-shadow: 0 10px 30px rgba(37, 45, 51, .35); }
.login form { text-align: left; margin-top: 22px; }
.error { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* htmx loading state */
.htmx-request .results-body { opacity: .55; transition: opacity .2s; }
