:root {
    --page: #f4f7f2;
    --surface: #ffffff;
    --surface-strong: #f8faf5;
    --ink: #17211a;
    --muted: #687466;
    --line: #dce5d7;
    --green: #248a57;
    --green-dark: #11623d;
    --lime: #a8cf45;
    --amber: #d88921;
    --red: #c94b3b;
    --blue: #2d6cdf;
    --shadow: 0 18px 55px rgba(38, 54, 35, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow-x: hidden;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(168, 207, 69, 0.18), transparent 32rem),
        linear-gradient(135deg, #f7faf3 0%, #edf4ea 48%, #f7f4ed 100%);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
    min-width: 0;
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 28px;
    height: 100vh;
    padding: 28px 20px;
    background: #152117;
    color: #f6fbf2;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--lime), #43b276);
    color: #132117;
    font-weight: 800;
}

.brand strong,
.brand small,
.sidebar-status strong,
.sidebar-status small {
    display: block;
}

.brand small,
.sidebar-status small {
    color: rgba(246, 251, 242, 0.68);
}

.nav-list {
    display: grid;
    gap: 8px;
}

.nav-list a {
    display: block;
    border-radius: 8px;
    color: rgba(246, 251, 242, 0.74);
    padding: 12px 14px;
    text-decoration: none;
    white-space: nowrap;
}

.nav-list a.active,
.nav-list a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-status {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.06);
}

.pulse {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #7ee081;
    box-shadow: 0 0 0 8px rgba(126, 224, 129, 0.14);
}

.main-content {
    min-width: 0;
    padding: 28px;
}

.topbar,
.panel-header,
.sensor-card-head,
.zone-row,
.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar > div,
.panel-header > div,
.sensor-card-head > span,
.zone-row > div {
    min-width: 0;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--green-dark);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 4vw, 3.9rem);
    line-height: 1;
    overflow-wrap: anywhere;
}

h2 {
    margin-bottom: 0;
    font-size: 1.15rem;
}

.topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar-actions span {
    color: var(--muted);
    font-size: 0.92rem;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--green-dark);
    cursor: pointer;
    box-shadow: var(--shadow);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 28px 0;
}

.metric-card,
.panel {
    border: 1px solid rgba(220, 229, 215, 0.86);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 20px;
}

.metric-card span,
.metric-card small {
    display: block;
    color: var(--muted);
}

.metric-card strong {
    display: block;
    margin: 10px 0 8px;
    color: var(--ink);
    font-size: 2rem;
    line-height: 1;
}

.warning-card strong {
    color: var(--amber);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
    gap: 18px;
}

.panel {
    min-width: 0;
    padding: 22px;
}

.climate-panel,
.chart-panel {
    grid-column: 1;
}

.map-panel {
    grid-column: 1 / -1;
}

.ai-panel,
.zones-panel,
.actuator-panel,
.activity-panel {
    grid-column: 2;
}

.sensor-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.sensor-card {
    min-width: 0;
    min-height: 168px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: var(--surface-strong);
}

.sensor-card-head span,
.sensor-card strong,
.sensor-card small {
    display: block;
}

.sensor-card-head span {
    color: var(--muted);
    font-weight: 700;
}

.sensor-card-head i {
    color: var(--muted);
    font-size: 0.76rem;
    font-style: normal;
}

.sensor-card strong {
    margin: 22px 0 14px;
    font-size: 1.85rem;
}

.sensor-card small {
    color: var(--muted);
}

.meter {
    overflow: hidden;
    height: 8px;
    margin-bottom: 12px;
    border-radius: 999px;
    background: #dde8d8;
}

.meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--green);
}

.sensor-card.warning .meter span,
.zone-row.warning {
    background: rgba(216, 137, 33, 0.14);
}

.sensor-card.warning .meter span {
    background: var(--amber);
}

.sensor-card.critical .meter span {
    background: var(--red);
}

.badge {
    border-radius: 999px;
    background: #e7f1df;
    color: var(--green-dark);
    padding: 7px 10px;
    font-size: 0.78rem;
    font-weight: 800;
}

.ai-badge {
    background: #e8efff;
    color: var(--blue);
}

.ai-list,
.zone-list,
.timeline {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.ai-item,
.zone-row,
.timeline-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.ai-item {
    padding: 14px;
}

.ai-item div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.ai-item span,
.ai-item small,
.zone-row span,
.zone-row small,
.timeline-item p {
    color: var(--muted);
}

.ai-item p {
    margin: 10px 0;
    line-height: 1.45;
}

.chart {
    display: grid;
    grid-template-columns: repeat(6, minmax(42px, 1fr));
    align-items: end;
    gap: 12px;
    height: 250px;
    margin-top: 20px;
    border-bottom: 1px solid var(--line);
}

.chart-column {
    display: grid;
    grid-template-rows: 1fr auto;
    align-items: end;
    min-width: 0;
    height: 100%;
}

.chart-bars {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 6px;
    height: 190px;
}

.bar {
    width: min(24px, 42%);
    min-height: 16px;
    border-radius: 8px 8px 0 0;
}

.bar.temp {
    background: linear-gradient(180deg, #e47b45, #d94f39);
}

.bar.humidity {
    background: linear-gradient(180deg, #4f9beb, #2d6cdf);
}

.chart-label {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
}

.zone-row {
    padding: 14px;
}

.zone-row strong,
.zone-row span,
.health b,
.health small {
    display: block;
}

.health {
    min-width: 112px;
    text-align: right;
}

.timeline-item {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
}

.timeline-item time {
    color: var(--green-dark);
    font-weight: 800;
}

.timeline-item p {
    margin-bottom: 0;
    line-height: 1.45;
}

.page-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 18px;
    margin-top: 28px;
}

.wide-panel {
    min-width: 0;
}

.data-table {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.table-row {
    display: grid;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--surface-strong);
}

.sensor-table .table-row {
    grid-template-columns: 1.1fr 1fr 0.7fr 0.8fr 0.6fr 0.75fr;
}

.decision-table .table-row {
    grid-template-columns: 1fr 0.7fr 0.45fr 1.3fr 0.65fr;
}

.table-head {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.table-row span,
.table-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.table-row span {
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-width: 86px;
    border-radius: 999px;
    padding: 7px 10px;
    color: var(--green-dark);
    background: #e7f1df;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill.warning {
    color: #8a520d;
    background: rgba(216, 137, 33, 0.16);
}

.status-pill.critical {
    color: #9d2d22;
    background: rgba(201, 75, 59, 0.15);
}

.check-list {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.check-list div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--surface-strong);
}

.check-list strong,
.check-list span {
    display: block;
}

.check-list span {
    margin-top: 6px;
    color: var(--muted);
    line-height: 1.45;
}

.irrigation-list {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.irrigation-item {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: var(--surface-strong);
}

.irrigation-item > div {
    min-width: 0;
}

.irrigation-item p {
    margin: 6px 0;
    color: var(--muted);
    line-height: 1.45;
}

.irrigation-item small,
.schedule-time span,
.tank-card small {
    color: var(--muted);
}

.schedule-time strong,
.schedule-time span {
    display: block;
}

.schedule-time strong {
    color: var(--green-dark);
}

.tank-card {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 16px;
    margin-top: 18px;
}

.tank-card p {
    color: var(--muted);
    line-height: 1.5;
}

.tank-level {
    display: flex;
    align-items: end;
    overflow: hidden;
    height: 180px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e8f0e4;
}

.tank-level span {
    display: block;
    width: 100%;
    background: linear-gradient(180deg, #66b8e8, #2d6cdf);
}

.decision-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.decision-summary {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #eef6e9;
    color: var(--green-dark);
    font-weight: 700;
    line-height: 1.45;
}

.decision-summary.compact {
    margin-bottom: 12px;
}

.decision-card {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: var(--surface-strong);
}

.decision-card.high .decision-score {
    background: rgba(201, 75, 59, 0.15);
    color: #9d2d22;
}

.decision-card.medium .decision-score {
    background: rgba(216, 137, 33, 0.16);
    color: #8a520d;
}

.decision-card span,
.decision-card p {
    color: var(--muted);
}

.decision-card > div {
    min-width: 0;
}

.decision-card span {
    display: block;
    margin-top: 4px;
}

.decision-card p {
    margin: 12px 0 0;
    line-height: 1.45;
}

.decision-score {
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    border-radius: 999px;
    background: #e8efff;
    color: var(--blue);
    font-weight: 800;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 28px 0;
}

.report-card {
    border: 1px solid rgba(220, 229, 215, 0.86);
    border-radius: 8px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
}

.report-card span,
.report-card small,
.report-card p {
    color: var(--muted);
}

.report-card div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 0;
}

.report-card strong {
    font-size: 2rem;
    line-height: 1;
}

.report-card small {
    color: var(--green-dark);
    font-weight: 800;
}

.report-card p,
.report-summary p {
    margin-bottom: 0;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.report-summary {
    display: grid;
    gap: 22px;
    margin-top: 18px;
}

.mini-bars {
    display: grid;
    grid-template-columns: repeat(6, minmax(32px, 1fr));
    align-items: end;
    gap: 12px;
    height: 170px;
    border-bottom: 1px solid var(--line);
}

.mini-bars span {
    display: block;
    min-height: 18px;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, #4f9beb, #2d6cdf);
}

.live-ai-panel {
    grid-column: span 1;
}

.live-stage-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    max-height: 260px;
    overflow: auto;
}

.live-stage {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-strong);
}

.live-stage span {
    width: 10px;
    height: 10px;
    margin-top: 5px;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 0 5px rgba(36, 138, 87, 0.12);
}

.live-stage p {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.45;
}

.json-preview {
    overflow: auto;
    max-width: 100%;
    max-height: 340px;
    margin: 18px 0 0;
    border: 1px solid #243527;
    border-radius: 8px;
    padding: 14px;
    background: #101914;
    color: #d8f4dc;
    font-size: 0.82rem;
    line-height: 1.5;
}

.actuator-compact-list,
.actuator-list {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.actuator-compact-group,
.actuator-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.actuator-compact-group {
    padding: 14px;
}

.actuator-compact-group div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 8px;
}

.actuator-compact-group span,
.actuator-compact-group small,
.actuator-row span,
.actuator-row small {
    color: var(--muted);
}

.actuator-compact-group small {
    display: inline-flex;
    width: fit-content;
    margin-top: 8px;
    border-radius: 999px;
    padding: 5px 8px;
    background: #e7f1df;
    color: var(--green-dark);
    font-weight: 800;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 28px;
}

.control-group-card {
    min-width: 0;
}

.actuator-row {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) 92px;
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.actuator-row.active {
    border-color: rgba(36, 138, 87, 0.28);
    background: #eef6e9;
}

.actuator-state-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #a7b2a2;
}

.actuator-row.active .actuator-state-dot {
    background: var(--green);
    box-shadow: 0 0 0 6px rgba(36, 138, 87, 0.12);
}

.actuator-row strong,
.actuator-row span,
.actuator-row small,
.actuator-state b {
    display: block;
}

.actuator-row span,
.actuator-row small {
    margin-top: 5px;
    line-height: 1.4;
}

.actuator-state {
    text-align: right;
}

.greenhouse-map-shell {
    display: grid;
    gap: 14px;
    margin-top: 18px;
    min-width: 0;
}

.greenhouse-plan {
    position: relative;
    overflow: hidden;
    width: 100%;
    min-height: 420px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(36, 138, 87, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(36, 138, 87, 0.08) 1px, transparent 1px),
        #f8fbf5;
    background-size: 40px 40px;
}

.map-page-grid .greenhouse-plan {
    min-height: 620px;
}

.map-frame {
    position: absolute;
    inset: 26px;
    border: 2px solid rgba(17, 98, 61, 0.34);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.54);
}

.map-door,
.map-service,
.map-bed,
.map-aisle {
    position: absolute;
    border-radius: 8px;
}

.map-door {
    left: 42%;
    bottom: -2px;
    width: 16%;
    border: 1px solid rgba(17, 98, 61, 0.34);
    border-bottom: 0;
    padding: 8px;
    background: #ffffff;
    color: var(--green-dark);
    font-size: 0.78rem;
    font-weight: 800;
    text-align: center;
}

.map-service {
    right: 4%;
    bottom: 7%;
    width: 18%;
    min-height: 18%;
    border: 1px solid rgba(45, 108, 223, 0.22);
    padding: 10px;
    background: rgba(45, 108, 223, 0.08);
    color: #2554aa;
    font-size: 0.78rem;
    font-weight: 800;
}

.map-bed {
    top: 32%;
    width: 15%;
    height: 38%;
    border: 1px solid rgba(36, 138, 87, 0.22);
    background: rgba(168, 207, 69, 0.16);
    color: rgba(17, 98, 61, 0.74);
    font-size: 0.78rem;
    font-weight: 800;
    padding: 9px;
}

.bed-1 {
    left: 14%;
}

.bed-2 {
    left: 32%;
}

.bed-3 {
    left: 50%;
}

.bed-4 {
    left: 68%;
}

.map-aisle {
    background: rgba(104, 116, 102, 0.08);
}

.map-aisle.vertical {
    top: 10%;
    bottom: 11%;
    left: 8%;
    width: 3%;
}

.map-aisle.horizontal {
    left: 8%;
    right: 8%;
    top: 74%;
    height: 5%;
}

.map-point {
    position: absolute;
    z-index: 2;
    display: grid;
    grid-template-columns: 18px minmax(76px, max-content);
    align-items: center;
    gap: 6px;
    max-width: 190px;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--ink);
    text-align: left;
    transform: translate(-9px, -9px);
    cursor: default;
}

.map-point-dot {
    width: 18px;
    height: 18px;
    border: 3px solid #ffffff;
    border-radius: 999px;
    background: var(--blue);
    box-shadow: 0 2px 9px rgba(23, 33, 26, 0.22);
}

.map-point.sensor .map-point-dot {
    background: var(--blue);
}

.map-point.actuator .map-point-dot {
    background: #7a8790;
}

.map-point.active .map-point-dot {
    background: var(--green);
    box-shadow: 0 0 0 7px rgba(36, 138, 87, 0.13), 0 2px 9px rgba(23, 33, 26, 0.18);
}

.map-point.warning .map-point-dot {
    background: var(--amber);
}

.map-point.critical .map-point-dot {
    background: var(--red);
}

.map-point-label {
    display: block;
    max-width: 160px;
    border: 1px solid rgba(220, 229, 215, 0.94);
    border-radius: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.93);
    box-shadow: 0 8px 20px rgba(38, 54, 35, 0.1);
}

.map-point-label strong,
.map-point-label small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-point-label strong {
    font-size: 0.74rem;
    line-height: 1.2;
}

.map-point-label small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 10px;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.map-mobile-list {
    display: none;
}

.map-mobile-item {
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px;
    background: var(--surface-strong);
}

.map-mobile-item strong,
.map-mobile-item small {
    display: block;
    min-width: 0;
}

.map-mobile-item small {
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.35;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #7a8790;
}

.legend-dot.sensor {
    background: var(--blue);
}

.legend-dot.actuator {
    background: #7a8790;
}

.legend-dot.active {
    background: var(--green);
}

.legend-dot.warning {
    background: var(--amber);
}

.legend-dot.critical {
    background: var(--red);
}

.message-stack {
    display: grid;
    gap: 10px;
    margin: 22px 0 0;
}

.message {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--surface);
    color: var(--muted);
    font-weight: 700;
}

.message.success {
    border-color: rgba(36, 138, 87, 0.25);
    background: #eef6e9;
    color: var(--green-dark);
}

.message.error {
    border-color: rgba(201, 75, 59, 0.25);
    background: rgba(201, 75, 59, 0.1);
    color: #9d2d22;
}

.warning-badge {
    background: rgba(216, 137, 33, 0.16);
    color: #8a520d;
}

.sensor-editor {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

.sensor-input-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px 48px;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--surface-strong);
}

.sensor-input-card.warning {
    border-color: rgba(216, 137, 33, 0.35);
    background: rgba(216, 137, 33, 0.08);
}

.sensor-input-card.critical {
    border-color: rgba(201, 75, 59, 0.35);
    background: rgba(201, 75, 59, 0.08);
}

.sensor-input-card span,
.sensor-input-card small,
.sensor-input-card em {
    display: block;
}

.sensor-input-card small,
.sensor-input-card em {
    color: var(--muted);
}

.sensor-input-card em {
    font-style: normal;
    font-weight: 800;
}

.sensor-input-card input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--ink);
    font-weight: 800;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 6px;
}

.primary-button,
.secondary-button,
.text-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 800;
    text-decoration: none;
}

.primary-button {
    border: 1px solid var(--green-dark);
    background: var(--green-dark);
    color: #ffffff;
}

.secondary-button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--green-dark);
}

.text-link {
    color: var(--green-dark);
}

.scenario-list span {
    font-size: 0.92rem;
}

.preview-panel {
    margin-top: 18px;
}

@media (max-width: 1120px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        gap: 16px;
        padding: 20px 28px;
    }

    .nav-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .nav-list a {
        flex: 0 0 auto;
        padding: 10px 12px;
    }

    .sidebar-status {
        margin-top: 0;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .climate-panel,
    .chart-panel,
    .map-panel,
    .ai-panel,
    .zones-panel,
    .actuator-panel,
    .activity-panel {
        grid-column: auto;
    }

    .summary-grid,
    .report-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-grid,
    .decision-grid,
    .control-grid {
        grid-template-columns: 1fr;
    }

    .sensor-table .table-row,
    .decision-table .table-row {
        grid-template-columns: 1fr;
    }

    .table-head {
        display: none;
    }
}

@media (max-width: 760px) {
    .main-content,
    .sidebar {
        padding: 14px;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
    }

    .sidebar-status {
        padding: 12px;
    }

    .nav-list {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .nav-list a {
        flex: 1 1 auto;
        text-align: center;
    }

    .main-content {
        display: grid;
        gap: 18px;
    }

    h1 {
        font-size: 1.7rem;
        line-height: 1.08;
    }

    .topbar,
    .panel-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .topbar-actions span {
        flex: 1 1 auto;
        font-size: 0.84rem;
    }

    .icon-button {
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
    }

    .summary-grid,
    .report-grid {
        gap: 12px;
        margin: 0;
    }

    .dashboard-grid,
    .page-grid,
    .control-grid {
        gap: 14px;
        margin-top: 0;
    }

    .panel,
    .metric-card,
    .report-card {
        padding: 16px;
    }

    .metric-card strong,
    .report-card strong {
        font-size: 1.55rem;
    }

    .badge {
        max-width: 100%;
        white-space: normal;
    }

    .summary-grid,
    .report-grid,
    .sensor-grid {
        grid-template-columns: 1fr;
    }

    .irrigation-item,
    .tank-card,
    .decision-card,
    .sensor-input-card,
    .actuator-row {
        grid-template-columns: 1fr;
    }

    .sensor-grid {
        gap: 12px;
        margin-top: 14px;
    }

    .sensor-card {
        min-height: auto;
        padding: 14px;
    }

    .sensor-card strong {
        margin: 16px 0 12px;
        font-size: 1.6rem;
    }

    .ai-item div,
    .actuator-compact-group div {
        display: grid;
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .zone-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .health {
        min-width: 0;
        text-align: left;
    }

    .timeline-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .status-pill {
        max-width: 100%;
        min-width: 0;
        white-space: normal;
    }

    .form-actions > * {
        flex: 1 1 100%;
    }

    .json-preview {
        font-size: 0.74rem;
    }

    .chart {
        gap: 8px;
        overflow-x: auto;
        grid-template-columns: repeat(6, 64px);
    }

    .greenhouse-plan,
    .map-page-grid .greenhouse-plan {
        width: 100%;
        min-height: 430px;
    }

    .map-frame {
        inset: 16px;
    }

    .map-point {
        display: block;
        width: 22px;
        height: 22px;
        transform: translate(-11px, -11px);
    }

    .map-point-dot {
        display: block;
        width: 18px;
        height: 18px;
    }

    .map-point-label {
        display: none;
    }

    .map-service,
    .map-bed,
    .map-door {
        font-size: 0.68rem;
        padding: 6px;
    }

    .map-legend {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .map-legend span {
        justify-content: center;
        padding: 6px 8px;
        font-size: 0.72rem;
    }

    .map-mobile-list {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .map-mobile-item {
        display: grid;
    }
}

@media (max-width: 430px) {
    .main-content,
    .sidebar {
        padding: 12px;
    }

    h1 {
        font-size: 1.55rem;
    }

    h2 {
        font-size: 1.02rem;
    }

    .panel,
    .metric-card,
    .report-card {
        padding: 14px;
    }

    .nav-list a {
        padding: 9px 11px;
        font-size: 0.9rem;
    }

    .greenhouse-plan,
    .map-page-grid .greenhouse-plan {
        min-height: 390px;
    }

    .map-point {
        width: 20px;
        height: 20px;
        transform: translate(-10px, -10px);
    }

    .map-point-dot {
        width: 16px;
        height: 16px;
        border-width: 2px;
    }
}
