﻿:root {
    --bg-forest: #133226;
    --bg-leaf: #244f3a;
    --panel: rgba(247, 252, 248, 0.94);
    --panel-strong: rgba(255, 255, 255, 0.96);
    --line: rgba(33, 74, 57, 0.12);
    --ink-strong: #132018;
    --ink-body: #355244;
    --ink-soft: #6c8378;
    --success: #2e8b57;
    --warning: #df8b2d;
    --danger: #d95d39;
    --info: #2f7fe9;
    --neutral: #7b8c84;
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    background:
        radial-gradient(circle at 0% 0%, rgba(255, 233, 184, 0.35), transparent 34%),
        radial-gradient(circle at 100% 0%, rgba(103, 173, 122, 0.28), transparent 30%),
        linear-gradient(180deg, #f6efe1 0%, #edf5ef 34%, #e6f0eb 100%);
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    color: var(--ink-strong);
}

button, input, select { font: inherit; }
button { border: none; background: none; cursor: pointer; }

input, select {
    width: 100%;
    border: 1px solid rgba(34, 69, 54, 0.16);
    border-radius: 16px;
    padding: 14px 15px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink-strong);
}

input:focus, select:focus {
    outline: none;
    border-color: rgba(39, 124, 81, 0.55);
    box-shadow: 0 0 0 4px rgba(67, 151, 104, 0.12);
}

.app-shell {
    position: relative;
    min-height: 100vh;
    max-width: 520px;
    margin: 0 auto;
    padding: 18px 14px calc(110px + env(safe-area-inset-bottom));
    overflow: hidden;
}

.ambient {
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(28px);
    opacity: 0.7;
}

.ambient-a {
    width: 240px;
    height: 240px;
    top: -60px;
    right: -40px;
    background: rgba(241, 181, 71, 0.23);
}

.ambient-b {
    width: 220px;
    height: 220px;
    left: -40px;
    bottom: 90px;
    background: rgba(74, 152, 100, 0.22);
}

.app-header, .section-card, .hero-card, .bottom-dock, .sheet-panel, .toast {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.app-header {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
    padding: 22px 20px;
    background: linear-gradient(160deg, rgba(21, 55, 40, 0.93), rgba(32, 74, 55, 0.86));
    border-radius: 30px;
    color: #f3f8f4;
    box-shadow: 0 24px 48px rgba(11, 30, 21, 0.18);
}

.eyebrow {
    margin: 0 0 8px;
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.72;
}

.app-header h1, .section-head h2, .section-head h3 {
    margin: 0;
    letter-spacing: -0.03em;
}

.app-header h1 { font-size: 29px; line-height: 1.12; }
.subtitle, .hero-text, .section-note {
    margin: 10px 0 0;
    font-size: 14px;
    line-height: 1.65;
}

.subtitle { color: rgba(244, 248, 245, 0.82); }
.hero-text, .section-note { color: var(--ink-body); }

.header-state {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
}

.status-line { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.08);
}
.status-dot.is-online { background: #7ae582; }
.status-dot.is-offline { background: #ff8f70; }
.header-state small { color: rgba(244, 248, 245, 0.74); }

.app-main { position: relative; z-index: 2; }
.screen { display: flex; flex-direction: column; gap: 16px; }
.home-screen,
.video-screen,
.trend-screen,
.admin-screen {
    min-width: 0;
}
.hero-card, .section-card {
    border-radius: 28px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.48);
    box-shadow: 0 14px 32px rgba(18, 46, 31, 0.08);
}
.hero-card { padding: 20px; }
.section-card { padding: 18px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-head h2, .section-head h3 { font-size: 21px; line-height: 1.2; color: var(--ink-strong); }
.section-head span { font-size: 12px; color: var(--ink-soft); text-align: right; }
.hero-head { align-items: flex-start; }
.hero-pills, .summary-strip, .action-row, .segmented-row, .field-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.pill, .ghost-chip, .metric-state, .severity-chip, .record-tag, .segment-chip, .ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pill, .ghost-chip {
    padding: 9px 12px;
    border-radius: 999px;
    font-size: 12px;
}
.pill.success { background: rgba(68, 145, 97, 0.16); color: #225e3f; }
.pill.warning { background: rgba(223, 139, 45, 0.15); color: #9b5c14; }
.pill.neutral, .ghost-chip, .ghost-button, .segment-chip, .segmented-mini button { background: rgba(31, 71, 53, 0.08); color: var(--ink-body); }

.quick-grid, .metric-grid, .stats-row, .status-grid { display: grid; gap: 10px; }
.quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; }
.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }

.quick-tile, .metric-card, .stat-card, .status-box, .detail-card, .timeline-row, .record-row, .control-row, .log-item {
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.quick-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    padding: 15px 14px;
    border-radius: 22px;
    text-align: left;
}

.quick-icon, .dock-icon { font-size: 18px; line-height: 1; color: var(--bg-leaf); }
.metric-card {
    display: flex;
    gap: 12px;
    padding: 14px;
    border-radius: 22px;
}
.metric-icon {
    width: 38px;
    height: 38px;
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(36, 79, 58, 0.12), rgba(74, 152, 100, 0.18));
    color: var(--bg-leaf);
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.metric-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.metric-label, .stat-card span, .stat-card small, .summary-item span, .status-box span, .record-main span, .timeline-row span, .log-item span, .field span {
    color: var(--ink-soft);
    font-size: 12px;
}
.metric-value { font-size: 24px; line-height: 1; letter-spacing: -0.04em; }
.metric-value small { font-size: 11px; margin-left: 4px; color: var(--ink-soft); }
.metric-state, .severity-chip, .record-tag {
    width: fit-content;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.state-success { background: rgba(68, 145, 97, 0.14); color: #266545; }
.state-warning { background: rgba(223, 139, 45, 0.14); color: #a56419; }
.state-danger { background: rgba(217, 93, 57, 0.14); color: #af4320; }
.state-info { background: rgba(47, 127, 233, 0.14); color: #2158a8; }
.state-muted { background: rgba(123, 140, 132, 0.14); color: var(--neutral); }
.severity-danger { background: rgba(217, 93, 57, 0.16); color: #af4320; }
.severity-warning { background: rgba(223, 139, 45, 0.16); color: #a56419; }
.severity-success { background: rgba(68, 145, 97, 0.16); color: #266545; }
.severity-neutral { background: rgba(123, 140, 132, 0.15); color: var(--neutral); }

.media-card, .video-stage {
    overflow: hidden;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(24, 38, 29, 0.88), rgba(41, 66, 52, 0.78));
}
.video-notice {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 241, 214, 0.92), rgba(255, 247, 232, 0.96));
    border: 1px solid rgba(223, 139, 45, 0.28);
}
.video-notice strong {
    font-size: 13px;
    color: #9b5c14;
}
.video-notice span {
    font-size: 13px;
    line-height: 1.6;
    color: #7b5a24;
}
.media-card img, .video-stage img { display: block; width: 100%; object-fit: contain; }
.media-card img { max-height: 340px; }
.video-stage { min-height: 220px; }
.video-stage img { min-height: 220px; object-fit: cover; }
.hidden-canvas { display: none; }
.empty-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    padding: 18px;
    min-height: 140px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(247, 251, 248, 0.92), rgba(234, 243, 237, 0.96));
    border: 1px dashed rgba(42, 81, 62, 0.18);
    color: var(--ink-body);
}
.empty-card.compact { min-height: 96px; }
.video-empty { min-height: 220px; }
.summary-strip, .detail-list, .record-list, .timeline-list, .control-stack, .log-list, .sheet-body { display: flex; flex-direction: column; gap: 10px; }
.summary-strip { margin-top: 14px; flex-direction: row; flex-wrap: wrap; }
.summary-item, .stat-card, .status-box { padding: 14px; border-radius: 20px; display: flex; flex-direction: column; gap: 6px; }
.summary-item { flex: 1 1 100px; min-width: 96px; background: rgba(255, 255, 255, 0.78); border: 1px solid var(--line); }
.summary-item strong, .status-box strong, .timeline-row em, .stat-card strong { font-size: 16px; }
.stat-card strong { font-size: 20px; }
.detail-card, .record-row, .timeline-row, .control-row, .log-item { padding: 14px; border-radius: 20px; }
.detail-top, .record-row, .timeline-row, .control-row, .log-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-top { margin-bottom: 10px; }
.detail-card p { margin: 0 0 6px; color: var(--ink-body); font-size: 13px; line-height: 1.6; }
.record-main, .timeline-row > div, .control-copy, .log-item div, .field { display: flex; flex-direction: column; gap: 6px; }
.timeline-row em, .log-item em { font-style: normal; font-weight: 700; }
.field { width: 100%; }
.switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--line);
    color: var(--ink-body);
    font-size: 13px;
    font-weight: 600;
}
.switch-row { min-height: 52px; cursor: pointer; }
.switch-row > span { flex: 1; min-width: 0; line-height: 1.5; }
.switch-row input.theme-switch {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    order: 2;
    flex: 0 0 52px;
    width: 52px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(33, 74, 57, 0.2);
    border-radius: 999px;
    background: #d7e2db;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.switch-row input.theme-switch::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: var(--panel-strong);
    box-shadow: 0 2px 5px rgba(19, 50, 38, 0.2);
    transition: transform 0.2s ease;
}
.switch-row input.theme-switch:checked {
    background: linear-gradient(150deg, var(--bg-leaf), var(--success));
    border-color: var(--success);
}
.switch-row input.theme-switch:checked::before { transform: translateX(22px); }
.switch-row input.theme-switch:focus-visible {
    outline: 2px solid var(--success);
    outline-offset: 3px;
}
.switch-row input.theme-switch:disabled { opacity: 0.5; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) {
    .switch-row input.theme-switch,
    .switch-row input.theme-switch::before { transition: none; }
}
.boxed { margin-top: 4px; }
.action-row { margin-top: 14px; }
.action-button {
    flex: 1 1 120px;
    padding: 14px 16px;
    border-radius: 18px;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.action-button:disabled { opacity: 0.55; cursor: not-allowed; }
.action-button.primary { color: #f8fcf9; background: linear-gradient(150deg, #265a41, #3b8f63); }
.action-button.secondary { color: #fff7f2; background: linear-gradient(150deg, #ba6d1e, #df8b2d); }
.action-button.tertiary { color: #fff5f2; background: linear-gradient(150deg, #c65434, #e27b58); }

.admin-rule-card, .admin-agronomy-card, .admin-ai-card { min-width: 0; }
.crop-profile-list {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-bottom: 14px;
}
.crop-profile-chip {
    display: flex;
    min-width: min(100%, 210px);
    flex: 1 1 210px;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 17px;
    color: var(--ink-strong);
    background: var(--panel-strong);
    text-align: left;
}
.crop-profile-chip span { color: var(--ink-soft); font-size: 11px; }
.crop-profile-chip.active { border-color: rgba(46, 139, 87, 0.5); box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.1); }
.crop-editor {
    padding: 14px 0;
    margin-bottom: 14px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.crop-ranges { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.weather-context-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.58);
}
.weather-grid { margin-top: 12px; }
.weather-provider-form { align-items: flex-end; margin: 4px 0 10px; }
.weather-provider-form .field { flex: 1 1 230px; }
.weather-provider-form .rule-add-action { min-height: 42px; }
.weather-worker-note { margin: 11px 2px 0; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.weather-worker-note strong { color: var(--ink-body); }
.crop-assessment-card { padding: 14px; margin-top: 14px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255, 255, 255, 0.58); }
.assessment-count { padding: 6px 9px; border-radius: 999px; color: #27603f; background: rgba(46, 139, 87, 0.12); font-size: 11px; font-weight: 700; }
.crop-assessment-list { display: flex; flex-direction: column; gap: 9px; }
.crop-assessment-row { padding: 11px 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel-strong); }
.crop-assessment-row > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crop-assessment-row span { color: var(--ink-soft); font-size: 11px; }
.crop-assessment-row p { margin: 6px 0 0; line-height: 1.5; }
.crop-assessment-row.assessment-low, .crop-assessment-row.assessment-high { border-color: rgba(223, 139, 45, 0.36); background: rgba(255, 246, 225, 0.66); }
.crop-trend-card { padding: 14px; margin-top: 14px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255, 255, 255, 0.58); }
.crop-trend-head { align-items: flex-start; }
.crop-trend-windows { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.crop-trend-windows .active { color: white; border-color: transparent; background: var(--accent); }
.crop-trend-coverage { margin: 10px 0; color: var(--ink-soft); font-size: 12px; }
.crop-trend-coverage.warning { color: #8b551d; }
.crop-trend-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.crop-trend-metric { padding: 11px 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel-strong); }
.crop-trend-title, .crop-trend-stats { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.crop-trend-title span, .crop-trend-stats, .crop-trend-metric small { color: var(--ink-soft); font-size: 11px; }
.crop-trend-metric svg { display: block; width: 100%; height: 82px; margin: 6px 0; }
.crop-trend-band { fill: rgba(46, 139, 87, 0.13); }
.crop-trend-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.crop-trend-empty { display: grid; min-height: 82px; place-items: center; color: var(--ink-soft); font-size: 11px; }
.environment-anomaly-list { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.environment-anomaly-row { padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-strong); }
.environment-anomaly-row > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.environment-anomaly-row span { color: var(--ink-soft); font-size: 11px; }
.environment-anomaly-row p { margin: 7px 0 0; line-height: 1.55; }
.environment-anomaly-row.severity-critical { border-color: rgba(217, 93, 57, 0.38); background: rgba(255, 239, 234, 0.68); }
.environment-anomaly-row.severity-warning { border-color: rgba(223, 139, 45, 0.36); background: rgba(255, 246, 225, 0.66); }
.ai-status-grid { margin-top: 12px; }
.status-pill { padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-pill.ok { color: #27603f; background: rgba(46, 139, 87, 0.12); }
.status-pill.warning { color: #8b551d; background: rgba(223, 139, 45, 0.15); }
.ai-key-note { margin: 11px 2px; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.ai-advice-card { padding: 14px; margin-top: 14px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255, 255, 255, 0.62); }
.ai-advice-card.risk-high, .ai-advice-card.risk-critical { border-color: rgba(217, 93, 57, 0.4); background: rgba(255, 239, 234, 0.66); }
.ai-advice-card.risk-medium { border-color: rgba(223, 139, 45, 0.36); background: rgba(255, 246, 225, 0.66); }
.ai-summary { margin: 12px 0; font-weight: 700; line-height: 1.65; }
.ai-advice-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ai-advice-columns > div { padding: 11px 12px; border-radius: 15px; background: var(--panel-strong); }
.ai-advice-columns ul { margin: 7px 0 0; padding-left: 18px; color: var(--ink-body); line-height: 1.6; }
.ai-history-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.ai-history-row { padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-strong); }
.ai-history-row > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink-soft); font-size: 11px; }
.ai-history-row em { padding: 3px 7px; border-radius: 999px; font-style: normal; font-weight: 700; }
.ai-history-row em.success { color: #27603f; background: rgba(46, 139, 87, 0.12); }
.ai-history-row em.failed { color: #9b3d28; background: rgba(217, 93, 57, 0.12); }
.ai-history-row p { margin: 6px 0 0; line-height: 1.5; }
.rule-safety-notice {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 13px 15px;
    margin-bottom: 14px;
    border: 1px solid rgba(223, 139, 45, 0.24);
    border-radius: 18px;
    color: #7f4e17;
    background: rgba(255, 238, 203, 0.58);
}
.rule-safety-notice span, .rule-safety-notice strong { font-size: 13px; line-height: 1.55; }
.execution-arm-banner button { align-self: flex-start; }
.execution-arm-banner.execution-armed {
    border-color: rgba(178, 34, 34, 0.4);
    color: #8c1a1a;
    background: rgba(255, 218, 218, 0.58);
}
.emergency-stop-banner button { align-self: flex-start; }
.emergency-stop-banner.emergency-stop-active {
    border-color: rgba(178, 34, 34, 0.45);
    color: #8c1a1a;
    background: rgba(255, 205, 205, 0.65);
}
.rule-list, .rule-editor, .rule-action-list, .rule-event-list, .rule-result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rule-list { margin-bottom: 14px; }
.rule-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--ink-strong);
    background: var(--panel-strong);
    text-align: left;
}
.rule-list-item.active { border-color: rgba(46, 139, 87, 0.5); box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.1); }
.rule-list-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 4px; }
.rule-list-copy small { overflow: hidden; color: var(--ink-soft); text-overflow: ellipsis; white-space: nowrap; }
.rule-version { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; color: #27603f; background: rgba(46, 139, 87, 0.12); font-size: 11px; }
.rule-version.running { color: #895112; background: rgba(223, 139, 45, 0.16); }
.rule-version.executing { color: #8c1a1a; background: rgba(178, 34, 34, 0.12); }
.rule-editor { padding-top: 14px; border-top: 1px solid var(--line); }
.rule-editor-title, .rule-subhead, .rule-node-head, .rule-result-head, .rule-event-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.rule-subsection, .rule-safety-panel, .rule-result, .rule-event-list {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.58);
}
.rule-subhead { margin-bottom: 12px; }
.rule-subhead > div:first-child { display: flex; flex-direction: column; gap: 3px; }
.rule-subhead small, .rule-inline-field span, .rule-event-row span { color: var(--ink-soft); font-size: 11px; }
.rule-root-actions, .rule-node-actions, .rule-action-palette { display: flex; flex-wrap: wrap; gap: 7px; }
.rule-root-actions button, .rule-node-actions button, .rule-action-palette button, .rule-add-action {
    padding: 7px 10px;
    border-radius: 12px;
    color: #285c42;
    background: rgba(46, 139, 87, 0.1);
    font-size: 12px;
}
.rule-root-actions button:disabled, .rule-node-actions button:disabled, .rule-remove:disabled { opacity: 0.42; cursor: not-allowed; }
.rule-node {
    min-width: 0;
    padding: 11px;
    border: 1px solid rgba(38, 90, 65, 0.13);
    border-radius: 16px;
    background: rgba(247, 252, 248, 0.9);
}
.rule-node-group { border-left: 4px solid rgba(46, 139, 87, 0.55); }
.rule-node-not { border-left: 4px solid rgba(223, 139, 45, 0.64); }
.rule-children { display: flex; flex-direction: column; gap: 8px; margin: 9px 0; }
.rule-inline-field { display: flex; min-width: 0; flex: 1 1 140px; flex-direction: column; gap: 5px; }
.rule-inline-field input, .rule-inline-field select { min-height: 39px; padding: 9px 10px; border-radius: 12px; }
.rule-node-head .rule-inline-field { max-width: 270px; }
.rule-comparison-grid, .rule-action-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    align-items: end;
}
.rule-remove { padding: 7px 9px; border-radius: 11px; color: #a8442c; background: rgba(217, 93, 57, 0.1); font-size: 12px; }
.rule-root-actions .rule-remove { color: #a8442c; background: rgba(217, 93, 57, 0.1); }
.comparison-remove { min-height: 39px; }
.rule-action-row { padding: 11px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-strong); }
.rule-action-row .rule-remove { min-height: 39px; }
.rule-safety-panel summary { cursor: pointer; color: var(--ink-strong); font-weight: 700; }
.rule-safety-panel[open] summary { margin-bottom: 12px; }
.rule-result { display: flex; flex-direction: column; gap: 8px; }
.rule-result.matched { border-color: rgba(223, 139, 45, 0.42); background: rgba(255, 238, 203, 0.44); }
.rule-result.not-matched { border-color: rgba(46, 139, 87, 0.3); background: rgba(226, 244, 233, 0.55); }
.rule-result p, .rule-result small { margin: 0; line-height: 1.55; }
.rule-result small { color: var(--ink-soft); }
.rule-result-actions span { padding: 8px 10px; border-radius: 12px; background: rgba(31, 71, 53, 0.07); font-size: 12px; }
.rule-event-list > strong { margin-bottom: 2px; }
.rule-event-row { padding-top: 8px; border-top: 1px solid var(--line); }
.rule-event-row em { font-size: 12px; font-style: normal; }
.rule-background-button { color: var(--ink-body); background: rgba(31, 71, 53, 0.09); }
.rule-background-button.active { color: #fff; background: linear-gradient(150deg, #8b5a20, #c77b23); }
.rule-category-field { flex: 1 1 100%; gap: 7px; }
.rule-category-options { display: flex; flex-wrap: wrap; gap: 7px; }
.rule-category-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--panel-strong); font-size: 12px; cursor: pointer;
}
.rule-category-chip input { min-height: 0; width: auto; margin: 0; }
.rule-category-chip-custom {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 10px; border: 1px dashed rgba(223, 139, 45, 0.55); border-radius: 999px;
    background: rgba(255, 238, 203, 0.4); font-size: 12px;
}
.rule-category-remove { border: none; background: none; font-size: 14px; line-height: 1; cursor: pointer; color: #a8442c; padding: 0 2px; }
.rule-category-add { display: flex; gap: 7px; }
.rule-category-add input { flex: 1 1 auto; min-height: 36px; padding: 8px 10px; border-radius: 12px; }
.rule-category-add button { min-height: 36px; padding: 8px 14px; border-radius: 12px; }
.rule-category-hint { margin: 0; font-size: 11px; color: var(--ink-soft); }
.ghost-button, .segment-chip { padding: 8px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.segment-chip.active, .segmented-mini button.active, .dock-item.active {
    background: linear-gradient(150deg, rgba(38, 90, 65, 0.96), rgba(61, 138, 97, 0.88));
    color: #f4f8f5;
}
.segmented-mini { display: flex; gap: 10px; }
.segmented-mini button { min-width: 52px; padding: 10px 14px; border-radius: 14px; font-weight: 700; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-muted { color: var(--neutral); }
.log-success { color: var(--success); }
.log-error { color: var(--danger); }
.log-info { color: var(--info); }
.admin-content-fieldset { display: contents; min-width: 0; margin: 0; padding: 0; border: 0; }
.warning-note { color: var(--warning); font-weight: 700; }
.trend-chart { display: block; width: 100%; height: 260px; border-radius: 22px; background: rgba(255, 255, 255, 0.52); }
.trend-grid line { stroke: rgba(68, 104, 86, 0.14); stroke-width: 1; }
.trend-grid text, .trend-axis-labels text { fill: #5b6f64; font-size: 10px; }
.trend-empty { fill: #5b6f64; font-size: 14px; }
.bottom-dock {
    position: fixed;
    left: 50%;
    bottom: calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 12;
    width: min(92vw, 480px);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border-radius: 28px;
    background: rgba(18, 41, 30, 0.86);
    box-shadow: 0 22px 36px rgba(14, 32, 24, 0.22);
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 6px;
    border-radius: 20px;
    color: rgba(244, 248, 245, 0.74);
    font-size: 11px;
    font-weight: 700;
}

.dock-item.active .dock-icon { color: #f4f8f5; }

.sheet-mask {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(9, 22, 16, 0.48);
    padding: 16px;
}

.sheet-panel {
    width: min(100%, 520px);
    max-height: 82vh;
    padding: 14px 16px 20px;
    border-radius: 30px 30px 24px 24px;
    background: rgba(246, 251, 247, 0.98);
    box-shadow: 0 -18px 42px rgba(12, 28, 20, 0.2);
    overflow: auto;
}

.sheet-handle {
    width: 54px;
    height: 6px;
    border-radius: 999px;
    background: rgba(54, 86, 69, 0.18);
    margin: 2px auto 14px;
}

.toast {
    position: fixed;
    left: 50%;
    top: calc(16px + env(safe-area-inset-top));
    transform: translateX(-50%);
    z-index: 24;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 700;
    color: #f8fcf9;
    box-shadow: 0 18px 34px rgba(11, 30, 21, 0.18);
}

.toast-info { background: rgba(41, 91, 163, 0.92); }
.toast-success { background: rgba(39, 109, 76, 0.94); }
.toast-error { background: rgba(181, 70, 39, 0.94); }

.sheet-enter-active, .sheet-leave-active, .toast-enter-active, .toast-leave-active { transition: all 0.22s ease; }
.sheet-enter-from, .sheet-leave-to { opacity: 0; }
.sheet-enter-from .sheet-panel, .sheet-leave-to .sheet-panel { transform: translateY(26px); }
.toast-enter-from, .toast-leave-to { opacity: 0; transform: translate(-50%, -10px); }

@media (min-width: 640px) {
    .app-header {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
    .header-copy { max-width: 72%; }
    .field-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
    .boxed { grid-column: 1 / -1; }
}

@media (min-width: 768px) and (max-width: 1099px) {
    .app-shell {
        max-width: 980px;
        padding: 24px 20px 132px;
    }

    .home-screen,
    .video-screen,
    .trend-screen {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
        align-items: start;
    }

    .overview-card,
    .history-card,
    .trend-chart-card,
    .trend-points-card {
        grid-column: 1 / -1;
    }

    .capture-card,
    .stats-card-wrap,
    .video-main-card,
    .video-result-card {
        grid-column: span 1;
    }

    .admin-screen {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
        align-items: start;
    }

    .admin-login-card,
    .admin-summary-card,
    .admin-agronomy-card,
    .admin-rule-card,
    .admin-config-card,
    .admin-log-card {
        grid-column: 1 / -1;
    }

    .metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    .app-shell {
        max-width: 1440px;
        padding: 28px 136px 40px 28px;
    }

    .app-header {
        margin-bottom: 22px;
        padding: 26px 28px;
        border-radius: 34px;
    }

    .header-copy {
        max-width: none;
    }

    .app-main {
        min-width: 0;
    }

    .home-screen {
        display: grid;
        grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
        gap: 18px;
        align-items: start;
    }

    .overview-card {
        grid-column: 1 / -1;
    }

    .capture-card {
        grid-column: 1;
        grid-row: 2;
    }

    .stats-card-wrap {
        grid-column: 2;
        grid-row: 2;
        position: sticky;
        top: 28px;
    }

    .history-card {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .video-screen {
        display: grid;
        grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
        gap: 18px;
        align-items: start;
    }

    .video-main-card {
        grid-column: 1;
    }

    .video-result-card {
        grid-column: 2;
        position: sticky;
        top: 28px;
    }

    .video-stage img {
        min-height: 420px;
        max-height: 620px;
    }

    .trend-screen {
        display: grid;
        grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
        gap: 18px;
        align-items: start;
    }

    .trend-chart-card {
        grid-column: 1 / -1;
    }

    .trend-points-card {
        grid-column: 1 / -1;
    }

    .trend-chart {
        height: 420px;
    }

    .admin-screen {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
        align-items: start;
    }

    .admin-login-card,
    .admin-summary-card,
    .admin-agronomy-card,
    .admin-rule-card,
    .admin-config-card,
    .admin-log-card {
        grid-column: span 2;
    }

    .admin-control-card,
    .admin-image-card,
    .admin-password-card {
        grid-column: span 1;
    }

    .admin-image-card {
        position: sticky;
        top: 28px;
    }

    .admin-log-card {
        max-height: 420px;
        overflow: auto;
    }

    .bottom-dock {
        left: auto;
        right: 26px;
        top: 28px;
        bottom: auto;
        transform: none;
        width: 92px;
        grid-template-columns: 1fr;
        padding: 12px;
        border-radius: 30px;
    }

    .dock-item {
        padding: 12px 8px;
    }

    .dock-item span:last-child {
        text-align: center;
        line-height: 1.2;
    }
}

@media (max-width: 420px) {
    .stats-row, .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quick-grid, .metric-grid { grid-template-columns: 1fr 1fr; }
    .rule-comparison-grid, .rule-action-row { grid-template-columns: 1fr; }
    .rule-subhead { align-items: flex-start; flex-direction: column; }
    .crop-assessment-row > div { align-items: flex-start; flex-direction: column; }
    .ai-advice-columns { grid-template-columns: 1fr; }
}

/* One card per row at every breakpoint; navigation and rule choices stay intact. */
.app-shell .screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.app-shell .screen .section-card {
    grid-column: auto;
    grid-row: auto;
    position: relative;
    top: auto;
    min-width: 0;
}
.app-shell .quick-grid,
.app-shell .metric-grid,
.app-shell .stats-row,
.app-shell .status-grid,
.app-shell .crop-trend-grid,
.app-shell .ai-advice-columns,
.app-shell .field-grid,
.app-shell .summary-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}
.app-shell .field-grid > *, .app-shell .summary-strip > * { min-width: 0; }
