:root {
  --ink: #17251f;
  --muted: #738078;
  --line: #e2e8e3;
  --paper: #ffffff;
  --canvas: #f4f7f3;
  --forest: #1f5945;
  --forest-dark: #183f32;
  --mint: #dff1e7;
  --lime: #a8c95d;
  --lime-soft: #eef5d9;
  --sand: #f4eee4;
  --danger: #b33a3a;
  --radius: 18px;
  --shadow: 0 12px 32px rgba(23, 51, 39, .07);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--canvas); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: clip; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

.topbar {
  height: 74px; padding: 0 max(24px, calc((100vw - 1240px) / 2)); background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(12px);
}
.brand { font-size: 21px; font-weight: 760; letter-spacing: -.7px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand > span:last-child span, .brand-static span { color: #628346; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: var(--forest); color: white; display: grid; place-items: center; }
.brand-mark svg { width: 27px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark.large { width: 58px; height: 58px; border-radius: 18px; }
.brand-mark.large svg { width: 39px; }
.desktop-nav { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.desktop-nav a { color: #617069; font-weight: 600; font-size: 14px; padding: 10px 16px; border-radius: 11px; }
.desktop-nav a:hover, .desktop-nav a.active { color: var(--forest); background: #eef4f0; }
.desktop-nav .nav-add { margin-left: 10px; background: var(--forest); color: white; padding-inline: 19px; box-shadow: 0 5px 14px rgba(31,89,69,.2); }
.desktop-nav .nav-add:hover { background: var(--forest-dark); color: white; }
.nav-add span { font-size: 18px; }
.logout-form { margin: 0 0 0 12px; padding-left: 12px; border-left: 1px solid var(--line); }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px; cursor: pointer; color: #718078; }
.icon-button:hover { background: #f0f3f1; color: var(--ink); }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.page-shell { max-width: 1240px; margin: 0 auto; padding: 40px 24px 80px; }
.mobile-nav { display: none; }

.page-shell, .login-card { animation: page-enter .2s ease-out both; }

.install-banner { position: fixed; right: 24px; bottom: 24px; z-index: 70; width: min(430px, calc(100vw - 32px)); display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px; background: rgba(255,255,255,.97); border: 1px solid #cfddd4; border-radius: 17px; padding: 12px; box-shadow: 0 18px 48px rgba(18,48,35,.2); backdrop-filter: blur(16px); }
.install-icon { width: 46px; height: 46px; border-radius: 12px; overflow: hidden; box-shadow: 0 3px 9px rgba(20,54,39,.15); }
.install-icon img { width: 100%; height: 100%; display: block; }
.install-banner strong { display: block; font-size: 13px; }
.install-banner p { margin: 2px 0 0; color: var(--muted); font-size: 10px; line-height: 1.35; }
.install-action { min-height: 38px; padding: 7px 12px; font-size: 11px; }
.install-close { width: 32px; height: 32px; border: 0; border-radius: 9px; background: transparent; color: #7d8a83; font-size: 22px; cursor: pointer; }
.install-close:hover { background: #f0f3f1; }

.page-heading { display: flex; justify-content: space-between; align-items: flex-end; margin: 0 0 28px; }
.page-heading h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.05; letter-spacing: -1.5px; margin: 5px 0 8px; }
.page-heading p { color: var(--muted); margin: 0; }
.eyebrow { font-size: 11px; letter-spacing: 1.8px; font-weight: 800; color: #789559 !important; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.button { border: 1px solid transparent; min-height: 45px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 19px; font-weight: 700; font-size: 14px; cursor: pointer; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--forest); color: white; box-shadow: 0 6px 16px rgba(31,89,69,.17); }
.button.primary:hover { background: var(--forest-dark); }
.button.secondary { background: white; color: var(--forest); border-color: #bdd0c4; }
.button.secondary:hover { background: #f2f7f4; }
.button.ghost { background: #f1f4f2; color: #536159; }
.button.danger { background: #fff; color: var(--danger); border-color: #e6bcbc; }
.button.danger:hover { background: #fff5f5; }
.button.wide { width: 100%; }
.back-link { display: inline-block; font-size: 14px; color: #64736b; margin-bottom: 22px; font-weight: 650; }
.back-link:hover { color: var(--forest); }
.hidden { display: none !important; }

.flash-stack { position: fixed; z-index: 80; top: 86px; right: 24px; width: min(420px, calc(100vw - 32px)); display: grid; gap: 8px; }
.flash { background: #fff; border: 1px solid var(--line); border-left: 4px solid #82908a; border-radius: 12px; box-shadow: 0 12px 30px rgba(20,40,31,.16); padding: 13px 16px; font-size: 14px; }
.flash-success { border-left-color: #5b9d68; }
.flash-error { border-left-color: #c15353; }
.flash-warning { border-left-color: #cf983b; }
.flash-created { border-left-color: #4a9a68; }
.flash.dismissing { animation: toast-out .35s ease forwards; }

.recognition-overlay { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 24px; background: rgba(15,42,31,.56); backdrop-filter: blur(9px); animation: overlay-in .24s ease both; }
.recognition-card { width: min(340px, 100%); border-radius: 25px; padding: 34px 27px 28px; text-align: center; background: rgba(255,255,255,.98); box-shadow: 0 28px 80px rgba(7,28,19,.32); animation: recognition-card-in .42s cubic-bezier(.2,.9,.25,1.15) both; }
.recognition-card strong { display: block; margin-top: 18px; font-size: 19px; letter-spacing: -.35px; }
.recognition-card p { min-height: 20px; margin: 5px 0 21px; color: var(--muted); font-size: 12px; }
.scan-frame { position: relative; width: 102px; height: 102px; margin: 0 auto; border-radius: 22px; overflow: hidden; color: var(--forest); background: linear-gradient(145deg, #eff7f2, #e1efe7); }
.scan-frame svg { width: 100%; height: 100%; padding: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.scan-frame > i { position: absolute; left: 10px; right: 10px; top: 12px; height: 2px; border-radius: 2px; background: #6fb28b; box-shadow: 0 0 14px 4px rgba(74,159,112,.38); animation: scan-line 1.45s ease-in-out infinite; }
.recognition-progress { display: block; height: 5px; border-radius: 9px; overflow: hidden; background: #e5ece8; }
.recognition-progress i { display: block; width: 42%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--forest), var(--lime)); animation: recognition-progress 1.4s ease-in-out infinite; }
.recognition-result .record-form { animation: recognition-result .5s cubic-bezier(.22,.8,.32,1) both; }
.recognition-result .record-form .field { opacity: 0; animation: field-reveal .36s ease forwards; }
.recognition-result .record-form .field:nth-child(2n) { animation-delay: .07s; }
.recognition-result .record-form .field:nth-child(3n) { animation-delay: .14s; }

.new-record-celebration { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; padding: 24px; background: rgba(239,247,242,.88); backdrop-filter: blur(12px); opacity: 0; transition: opacity .25s ease; pointer-events: none; }
.new-record-celebration.visible { opacity: 1; }
.new-record-celebration.leaving { opacity: 0; }
.celebration-card { text-align: center; transform: translateY(12px) scale(.92); transition: transform .45s cubic-bezier(.2,.95,.25,1.18); }
.new-record-celebration.visible .celebration-card { transform: translateY(0) scale(1); }
.celebration-card strong { display: block; margin-top: 20px; font-size: 23px; letter-spacing: -.6px; }
.celebration-card > span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.celebration-mark { position: relative; width: 112px; height: 112px; margin: 0 auto; }
.celebration-mark svg { position: relative; z-index: 2; width: 100%; height: 100%; fill: var(--forest); stroke: white; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 12px 17px rgba(31,89,69,.24)); }
.celebration-mark i { position: absolute; z-index: 1; left: 50%; top: 50%; width: 9px; height: 9px; border-radius: 50% 0 50% 0; background: var(--lime); opacity: 0; }
.new-record-celebration.visible .celebration-mark i { animation: leaf-burst .72s .18s cubic-bezier(.2,.8,.3,1) both; }
.celebration-mark i:nth-child(1) { --x: -72px; --y: -40px; transform: rotate(15deg); }
.celebration-mark i:nth-child(2) { --x: 66px; --y: -48px; transform: rotate(70deg); }
.celebration-mark i:nth-child(3) { --x: -82px; --y: 22px; transform: rotate(120deg); }
.celebration-mark i:nth-child(4) { --x: 78px; --y: 24px; transform: rotate(170deg); }
.celebration-mark i:nth-child(5) { --x: -44px; --y: 72px; transform: rotate(215deg); }
.celebration-mark i:nth-child(6) { --x: 46px; --y: 70px; transform: rotate(275deg); }

/* Login */
.login-page { background: var(--forest-dark); }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(28px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left)); overflow: hidden; position: relative; }
.login-wrap::before, .login-wrap::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 48% 52% 63% 37%; border: 1px solid rgba(255,255,255,.06); transform: rotate(20deg); }
.login-wrap::before { left: -260px; bottom: -200px; box-shadow: 0 0 0 70px rgba(255,255,255,.02), 0 0 0 140px rgba(255,255,255,.015); }
.login-wrap::after { right: -320px; top: -260px; }
.login-card { width: min(445px, 100%); background: white; padding: 48px; border-radius: 26px; position: relative; z-index: 1; box-shadow: 0 30px 80px rgba(5,20,14,.3); }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand-static { font-size: 26px; }
.login-copy { text-align: center; margin: 30px 0; }
.login-copy h1 { font-size: 28px; letter-spacing: -1px; margin: 0 0 5px; }
.login-copy p, .login-note { color: var(--muted); margin: 0; }
.login-form label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.password-field { position: relative; margin-bottom: 15px; }
.password-field input { width: 100%; height: 50px; padding: 0 48px 0 15px; border: 1px solid #d9e0db; border-radius: 12px; outline: none; }
.password-field input:focus { border-color: #78a18d; box-shadow: 0 0 0 3px rgba(70,124,97,.1); }
.reveal { position: absolute; right: 7px; top: 7px; width: 36px; height: 36px; border: 0; background: transparent; color: #8a9690; display: grid; place-items: center; cursor: pointer; }
.reveal svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.login-note { text-align: center; font-size: 11px; margin-top: 25px; }

/* Dashboard */
.period-panel { padding: 8px; margin-bottom: 22px; }
.period-form { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.segmented { display: flex; gap: 5px; background: #f1f4f2; padding: 4px; border-radius: 12px; }
.segmented button { background: transparent; border: 0; border-radius: 9px; padding: 8px 16px; font-weight: 650; font-size: 13px; color: #68766f; cursor: pointer; white-space: nowrap; }
.segmented button.active { background: white; color: var(--forest); box-shadow: 0 2px 7px rgba(23,51,39,.09); }
.custom-period { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.custom-period label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.custom-period label, .filters > * { min-width: 0; }
input[type="date"], input[type="datetime-local"] { color-scheme: light; }
.custom-period input, select { min-height: 40px; border: 1px solid #dbe2dd; border-radius: 9px; background: white; padding: 7px 10px; outline: none; }
.custom-period .button { min-height: 40px; padding: 7px 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.metric-card { background: white; border: 1px solid var(--line); border-radius: 16px; min-width: 0; padding: 21px 18px; display: flex; gap: 14px; align-items: center; box-shadow: 0 5px 18px rgba(22,52,39,.045); }
.metric-card span { color: var(--muted); font-size: 12px; display: block; line-height: 1.2; }
.metric-card strong { display: block; font-size: 28px; line-height: 1.1; margin-top: 5px; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.metric-icon { flex: 0 0 auto; width: 41px; height: 41px; border-radius: 12px; display: grid; place-items: center; }
.metric-icon svg, .type-icon svg, .history-icon svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.metric-icon.completion, .type-icon.completion, .history-icon.completion { color: #3d735c; background: #e5f1eb; }
.metric-icon.tree { color: #39734b; background: #e8f4e8; }
.metric-icon.shrub { color: #718c3d; background: #eff5df; }
.metric-icon.total { color: #8d6a35; background: var(--sand); }
.metric-icon.visit, .type-icon.visit, .history-icon.visit { color: #4e6f86; background: #e7eff3; }
.chart-panel, .aggregate-panel { padding: 24px; margin-bottom: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 22px; }
.panel-heading h2 { margin: 0 0 3px; font-size: 18px; letter-spacing: -.35px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.chart-legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted); }
.chart-legend span, .aggregate-stats span { display: flex; align-items: center; gap: 6px; }
.tree-dot, .shrub-dot { display: inline-block !important; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.tree-dot { background: #2f7657; }
.shrub-dot { background: var(--lime); }
.bar-chart { height: 230px; display: flex; align-items: stretch; overflow-x: auto; padding: 8px 3px 0; gap: 7px; scrollbar-width: thin; }
.bar-column { height: 100%; flex: 1 0 54px; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.bar-values { height: 180px; width: 100%; display: flex; align-items: end; justify-content: center; gap: 3px; border-bottom: 1px solid #dfe5e1; background: repeating-linear-gradient(to bottom, transparent, transparent 44px, #eef1ef 45px); }
.bar { width: min(14px, 36%); border-radius: 5px 5px 1px 1px; min-height: 3px; transition: height .4s ease; }
.bar.trees { background: #347659; }
.bar.shrubs { background: var(--lime); }
.bar-label { width: 100%; text-align: center; margin-top: 8px; color: #7c8982; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aggregate-heading { align-items: center; }
.group-form select { font-size: 12px; cursor: pointer; }
.aggregate-list { display: grid; }
.aggregate-row { padding: 17px 5px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #edf0ee; gap: 20px; }
.aggregate-row:first-child { border-top: 0; padding-top: 3px; }
.aggregate-date strong { display: block; font-size: 14px; }
.aggregate-date span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.aggregate-stats { display: flex; gap: 24px; font-size: 12px; color: #657269; }
.aggregate-stats b { color: var(--ink); font-size: 16px; }

/* Add and forms */
.narrow-page { max-width: 820px; margin: 0 auto; }
.form-page { max-width: 960px; margin: 0 auto; }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.type-card { background: white; border: 1px solid var(--line); padding: 27px; border-radius: var(--radius); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 17px; box-shadow: var(--shadow); transition: .2s ease; }
.type-card:hover { border-color: #a8c0b2; transform: translateY(-2px); box-shadow: 0 16px 38px rgba(23,51,39,.1); }
.type-icon, .history-icon { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; }
.type-card h2 { font-size: 18px; margin: 0 0 5px; }
.type-card p { font-size: 12px; line-height: 1.45; color: var(--muted); margin: 0; }
.type-card > b { color: #8c9992; }
.input-mode { width: fit-content; margin-bottom: 15px; }
.upload-panel { padding: 25px; }
.drop-zone { border: 1.5px dashed #aac0b3; background: #f8fbf9; min-height: 210px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; margin-bottom: 16px; text-align: center; transition: .18s; }
.drop-zone:hover { border-color: var(--forest); background: #f1f7f3; }
.drop-zone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop-zone strong { margin: 12px 0 3px; font-size: 15px; }
.drop-zone > span:last-of-type { color: var(--muted); font-size: 12px; }
.upload-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--mint); color: var(--forest); }
.upload-icon svg { width: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.selected-file { font-size: 12px; color: var(--forest); text-align: center; min-height: 18px; }
.privacy-note { text-align: center; color: #859188; font-size: 10px; margin: 12px 0 0; }
.record-form { padding: 28px; }
.form-section-heading { display: flex; gap: 12px; align-items: center; margin: 4px 0 19px; }
.form-section-heading:not(:first-of-type) { border-top: 1px solid #e8ece9; padding-top: 25px; margin-top: 27px; }
.form-section-heading > span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--mint); color: var(--forest); font-size: 10px; font-weight: 800; }
.form-section-heading h2 { font-size: 16px; margin: 0; }
.form-section-heading p { font-size: 11px; color: var(--muted); margin: 1px 0 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid.counts { max-width: 520px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 12px; font-weight: 700; color: #526058; }
.field > span b { color: #af4b4b; }
.field input, .field select, .field textarea, .filters input, .filters select { width: 100%; border: 1px solid #d8e0da; border-radius: 10px; background: white; min-height: 45px; padding: 10px 12px; outline: none; transition: .15s; }
.field input[type="date"], .field input[type="datetime-local"], .filters input[type="date"] { display: block; width: 100%; min-width: 0; max-width: 100%; inline-size: 100%; max-inline-size: 100%; overflow: hidden; }
.filter-date { min-width: 0; overflow: hidden; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus { border-color: #6e9e86; box-shadow: 0 0 0 3px rgba(68,120,94,.09); }
.field small { color: var(--muted); font-size: 10px; }
.field.emphasized input { border-color: #96b79e; background: #f9fcfa; }
.count-field > span { display: flex; align-items: center; gap: 7px; }
.count-field input { height: 62px; font-size: 26px; font-weight: 700; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #e8ece9; margin-top: 28px; padding-top: 22px; }
.duplicate-box { border: 1px solid #e3c6a1; background: #fffaf3; border-radius: 14px; padding: 17px; margin-bottom: 15px; display: flex; justify-content: space-between; gap: 15px; align-items: center; }
.duplicate-box p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.visit-form { max-width: 550px; margin: 0 auto; padding: 30px; }
.visit-symbol { display: grid; place-items: center; margin-bottom: 24px; }

/* Detail */
.detail-page { max-width: 1040px; margin: 0 auto; }
.detail-hero { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 25px; }
.detail-hero h1, .visit-detail h1 { font-size: 38px; letter-spacing: -1.2px; margin: 4px 0 5px; }
.detail-hero p:not(.eyebrow), .visit-detail > p:not(.eyebrow) { margin: 0; color: var(--muted); max-width: 620px; }
.detail-actions { display: flex; gap: 9px; align-items: center; }
.detail-actions form { margin: 0; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.detail-panel { padding: 28px; }
.detail-panel h2 { margin: 0 0 22px; font-size: 18px; }
.details-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; }
.details-list > div { padding: 15px 10px 15px 0; border-top: 1px solid #edf0ee; }
.details-list > div.full { grid-column: 1 / -1; }
.details-list dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 5px; }
.details-list dd { margin: 0; font-size: 14px; white-space: pre-wrap; }
.details-list .highlight dd { color: var(--forest); font-weight: 800; }
.detail-counts { display: grid; gap: 11px; }
.count-card { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 19px; box-shadow: var(--shadow); }
.count-card span { font-size: 11px; color: var(--muted); }
.count-card strong { display: block; font-size: 31px; margin-top: 3px; }
.count-card.tree { border-left: 4px solid #347659; }
.count-card.shrub { border-left: 4px solid var(--lime); }
.count-card.total { background: var(--forest); color: white; border: 0; }
.count-card.total span { color: rgba(255,255,255,.7); }
.visit-detail { padding: 48px 30px; text-align: center; }
.visit-detail .type-icon { margin: 0 auto 20px; }
.visit-detail .detail-actions { justify-content: center; margin-top: 28px; }

/* History */
.filters { padding: 13px; margin-bottom: 20px; display: grid; grid-template-columns: minmax(210px, 2fr) minmax(130px, .8fr) 145px 145px auto; gap: 9px; align-items: end; }
.search-field { position: relative; }
.search-field svg { position: absolute; left: 12px; top: 13px; width: 18px; fill: none; stroke: #89958f; stroke-width: 1.8; }
.filters .search-field input { padding-left: 39px; }
.filters select { min-height: 45px; }
.filter-date { display: flex; flex-direction: column; gap: 3px; }
.filter-date span { color: var(--muted); font-size: 9px; padding-left: 3px; }
.clear-filter { grid-column: 1 / -1; text-align: right; color: var(--danger); font-size: 11px; padding-right: 4px; }
.history-list { display: grid; gap: 10px; }
.history-card { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 17px 19px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 17px; box-shadow: 0 3px 12px rgba(23,51,39,.035); transition: .15s; }
.history-card:hover { border-color: #b4c8bc; transform: translateX(2px); }
.history-icon { width: 42px; height: 42px; border-radius: 12px; }
.history-icon svg { width: 21px; }
.history-title { display: flex; gap: 13px; align-items: center; }
.history-title strong { font-size: 15px; }
.history-title time { color: #708078; font-size: 11px; background: #f1f4f2; padding: 3px 7px; border-radius: 7px; }
.history-main { min-width: 0; }
.history-main p { margin: 3px 0 0; color: #536159; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-main small { display: block; color: #929d97; font-size: 10px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-counts { display: flex; gap: 12px; }
.history-counts span { display: flex; align-items: center; gap: 5px; color: #758179; font-size: 10px; }
.history-counts b { color: var(--ink); font-size: 14px; }
.history-arrow { color: #9ba59f; }
.empty-state { padding: 50px 25px; text-align: center; color: var(--muted); }
.empty-state > span { font-size: 35px; }
.empty-state h2 { color: var(--ink); font-size: 18px; margin: 10px 0 4px; }
.empty-state p { margin: 0 0 17px; font-size: 12px; }
.empty-state.compact { padding: 30px; box-shadow: none; }
.error-state { padding: 55px 30px; text-align: center; }
.error-symbol { width: 58px; height: 58px; margin: 0 auto 17px; display: grid; place-items: center; border-radius: 50%; color: #a16928; background: #fbefd9; font-size: 28px; font-weight: 800; }
.error-state h1 { margin: 0 0 8px; font-size: 27px; }
.error-state p { margin: 0 auto 24px; max-width: 470px; color: var(--muted); }
.error-actions { display: flex; justify-content: center; gap: 9px; }

@media (max-width: 960px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-card:nth-child(4), .metric-card:nth-child(5) { grid-column: span 1; }
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .filters .button { grid-column: 1 / -1; }
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .field.emphasized { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topbar { height: calc(62px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(17px, env(safe-area-inset-right)) 0 max(17px, env(safe-area-inset-left)); background: #fff; backdrop-filter: none; }
  .brand { font-size: 18px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand-mark svg { width: 24px; }
  .desktop-nav { display: none; }
  .logout-form { margin-left: auto; border: 0; padding: 0; }
  .page-shell { padding: 27px max(15px, env(safe-area-inset-right)) calc(35px + env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left)); }
  .mobile-nav { position: fixed !important; display: grid; grid-template-columns: 1fr 74px 1fr; align-items: center; inset: auto 0 0 0; z-index: 50; width: 100%; height: calc(64px + env(safe-area-inset-bottom)); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -7px 22px rgba(23,51,39,.08); backdrop-filter: none; -webkit-backdrop-filter: none; transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); will-change: transform; isolation: isolate; contain: layout; }
  .mobile-nav > a:not(.mobile-add) { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #849089; font-size: 10px; font-weight: 650; }
  .mobile-nav > a.active { color: var(--forest); }
  .mobile-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-add { width: 56px; height: 56px; background: var(--forest); color: white; border-radius: 18px; display: grid; place-items: center; margin: -26px auto 0; box-shadow: 0 8px 22px rgba(31,89,69,.3); font-size: 30px; }
  .desktop-only { display: none; }
  .page-heading { margin-bottom: 21px; }
  .page-heading h1 { font-size: 32px; }
  .dashboard-heading { align-items: center; }
  .period-panel { overflow-x: auto; }
  .period-form { min-width: 100%; flex-direction: column; align-items: stretch; }
  .period-tabs { width: 100%; }
  .period-tabs button { flex: 1; padding-inline: 8px; }
  .custom-period { flex-wrap: wrap; margin: 5px 0 0; }
  .custom-period label { flex: 1; }
  .custom-period input { width: 100%; }
  .custom-period .button { width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { padding: 16px 14px; gap: 10px; }
  .metric-card:first-child { grid-column: 1 / -1; }
  .metric-card strong { font-size: 25px; }
  .metric-icon { width: 37px; height: 37px; }
  .chart-panel, .aggregate-panel { padding: 19px 16px; }
  .panel-heading { flex-direction: column; }
  .bar-chart { height: 210px; }
  .bar-values { height: 160px; }
  .aggregate-heading { flex-direction: row; align-items: center; }
  .aggregate-row { align-items: flex-start; }
  .aggregate-stats { flex-direction: column; gap: 5px; align-items: flex-end; }
  .type-grid { grid-template-columns: 1fr; }
  .type-card { padding: 22px 18px; }
  .form-grid, .form-grid.three, .form-grid.counts { grid-template-columns: 1fr; }
  .field input, .field select, .field textarea, .filters input, .filters select { font-size: 16px; }
  .field input[type="date"], .field input[type="datetime-local"], .filters input[type="date"] { -webkit-appearance: none; appearance: none; width: -webkit-fill-available; min-width: 0 !important; max-width: 100% !important; }
  input[type="date"]::-webkit-date-and-time-value, input[type="datetime-local"]::-webkit-date-and-time-value { min-width: 0; text-align: left; }
  .field.emphasized { grid-column: auto; }
  .record-form, .upload-panel { padding: 20px 16px; }
  .input-mode { width: 100%; }
  .input-mode button { flex: 1; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .detail-hero { display: block; }
  .detail-hero .detail-actions { margin-top: 20px; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-counts { grid-template-columns: repeat(3, 1fr); order: -1; }
  .count-card { padding: 15px 11px; }
  .count-card strong { font-size: 25px; }
  .details-list { grid-template-columns: 1fr; }
  .details-list > div.full { grid-column: auto; }
  .filters { grid-template-columns: 1fr 1fr; padding: 11px; }
  .filters .search-field, .filters select, .filters .button { grid-column: 1 / -1; }
  .history-card { grid-template-columns: auto minmax(0, 1fr) auto; padding: 14px; gap: 12px; }
  .history-counts { grid-column: 2 / -1; }
  .history-arrow { grid-column: 3; grid-row: 1; }
  .login-card { padding: 36px 24px; }
  .flash-stack { top: calc(72px + env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); }
  .install-banner { right: max(12px, env(safe-area-inset-right)); bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)); grid-template-columns: auto 1fr auto; gap: 9px; }
  .install-banner .install-action { grid-column: 2 / -1; width: 100%; }
  .install-close { grid-column: 3; grid-row: 1; }
  .recognition-card { padding: 30px 22px 25px; }
  .error-actions { flex-direction: column; }
}

@media (display-mode: standalone) {
  html { background: var(--forest-dark); }
  body { overscroll-behavior-y: none; }
  .topbar { box-shadow: 0 2px 12px rgba(18,50,36,.06); }
}

@media (max-width: 420px) {
  .detail-counts { grid-template-columns: 1fr 1fr; }
  .count-card.total { grid-column: 1 / -1; }
  .detail-actions { align-items: stretch; flex-direction: column; }
  .detail-actions .button { width: 100%; }
  .aggregate-heading { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .page-shell, .login-card, .recognition-result .record-form, .recognition-result .record-form .field { animation: none !important; opacity: 1 !important; }
}

@keyframes page-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(18px); } }
@keyframes overlay-in { from { opacity: 0; } }
@keyframes recognition-card-in { from { opacity: 0; transform: translateY(18px) scale(.94); } }
@keyframes scan-line { 0%, 100% { transform: translateY(0); opacity: .65; } 50% { transform: translateY(76px); opacity: 1; } }
@keyframes recognition-progress { 0% { transform: translateX(-115%); } 55%, 100% { transform: translateX(245%); } }
@keyframes recognition-result { from { opacity: 0; transform: translateY(12px); } }
@keyframes field-reveal { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes leaf-burst { 0% { opacity: 0; translate: -50% -50%; scale: .5; } 35% { opacity: 1; } 100% { opacity: 0; translate: calc(-50% + var(--x)) calc(-50% + var(--y)); scale: 1.25; } }
