:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #19332c;
  background: #f4f7f5;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
a { color: #12674f; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #6bc6a3; outline-offset: 2px; }
header { background: #173c32; color: #fff; padding: 17px 4vw; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; }
header strong { font-size: 1.35rem; letter-spacing: -.04em; }
header .brand span, header .account span { opacity: .8; font-size: .88rem; }
.manager-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.manager-nav a { color: #e7f4ec; text-decoration: none; font-size: .88rem; font-weight: 650; padding: 9px 12px; border-radius: 9px; }
.manager-nav a:hover, .manager-nav a:focus-visible { background: #2b5b4c; }
.manager-nav a[aria-current=page] { background: #e5f1eb; color: #165c49; }
main { max-width: 1460px; margin: auto; padding: 32px 4vw 70px; }
.inline { display: inline-flex; gap: 6px; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.card, .summary-card, .metric-card { background: #fff; border: 1px solid #dce7e1; border-radius: 16px; box-shadow: 0 8px 28px rgba(23, 64, 49, .035); }
.card { padding: 24px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 1.13rem; letter-spacing: -.02em; }
.card h3 { margin: 0 0 10px; font-size: 1rem; }
.eyebrow { display: inline-block; color: #31755e; font-size: .75rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 7px; }
.page-heading, .device-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.page-heading h1, .device-heading h1, .intro h1 { font-size: clamp(1.75rem, 3vw, 2.25rem); letter-spacing: -.05em; line-height: 1.1; margin: 0 0 8px; }
.page-heading p, .intro p, .section-heading p, .section-copy { margin: 0; color: #62776b; line-height: 1.5; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.button-link, .primary { display: inline-flex; align-items: center; justify-content: center; border: 0; background: #13765b; color: #fff; border-radius: 9px; padding: 11px 16px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.button-link:hover, .primary:hover { background: #0f5f49; }
.small { display: inline-flex; align-items: center; justify-content: center; border: 0; background: #13765b; color: #fff; border-radius: 9px; padding: 8px 11px; font-size: .83rem; font-weight: 700; text-decoration: none; }
.secondary { background: #e5f1eb; color: #165c49; }
.secondary:hover { background: #d5e9de; }
.danger { background: #fae5df; color: #a33421; }
.danger:hover { background: #f5d4c9; }
.text-link { font-weight: 700; font-size: .87rem; text-decoration: none; white-space: nowrap; }
.text-link:hover, .device-name:hover, .row-action:hover, .back-link:hover { text-decoration: underline; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label, .interval-form label { font-size: .83rem; font-weight: 700; color: #425f54; }
.field-hint { color: #6c7f75; font-size: .78rem; line-height: 1.5; }
input, select { width: 100%; padding: 10px 12px; border: 1px solid #bdcfc5; border-radius: 9px; background: #fff; min-height: 42px; color: #19332c; }
input[type=checkbox] { width: auto; min-height: auto; }
input[type=file] { padding: 8px; }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.form-page { max-width: 940px; }
.form-card { max-width: 720px; }
.notice, .credentials, .demo-note { padding: 13px 16px; border-radius: 10px; margin-bottom: 18px; line-height: 1.5; }
.notice { background: #e1f5eb; color: #155b3e; border: 1px solid #a7dec0; }
.notice.error { background: #fff0eb; color: #a33820; border-color: #edb8a8; }
.credentials { background: #eff8f4; border: 1px solid #9dceb9; }
.credentials p { margin: 8px 0 0; }
.credentials code, .device-identity code, .key-values code, .topic-list code { word-break: break-all; }
.demo-note { background: #fff8e8; color: #775425; border: 1px solid #eedaa6; }
.muted { color: #6c7f75; }
.login { max-width: 430px; margin: 10vh auto; padding: 30px; }
.login h1 { margin: 0 0 8px; }
.login p { color: #62736e; margin-bottom: 25px; }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.summary-grid.has-unassigned { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.summary-card { padding: 19px 21px; min-width: 0; }
.summary-label, .metric-card span { display: block; color: #5c7468; font-size: .81rem; font-weight: 750; }
.summary-card strong, .metric-card strong { display: block; font-size: 1.85rem; letter-spacing: -.045em; line-height: 1.1; margin: 10px 0 5px; }
.summary-card small, .metric-card small { color: #71857a; font-size: .77rem; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0 0 3px; }
.result-count { background: #eef5f0; border-radius: 30px; padding: 6px 10px; color: #506e5e; font-size: .78rem; font-weight: 750; white-space: nowrap; }
.table-filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding: 16px; margin-bottom: 9px; border: 1px solid #e5eee8; border-radius: 12px; background: #f8fbf9; }
.table-filters .field { margin: 0; }
.table-filters .field:first-child { flex: 1 1 300px; }
.table-filters .field:nth-child(2) { flex: 0 1 180px; }
.table-filters .text-link { padding: 10px 4px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .87rem; }
th { text-align: left; color: #6d8175; font-size: .76rem; font-weight: 750; border-bottom: 1px solid #e2eae5; padding: 12px 10px; white-space: nowrap; }
td { border-bottom: 1px solid #edf2ee; padding: 15px 10px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td code { font-size: .79rem; word-break: break-all; }
.device-table tbody tr:hover { background: #fbfdfb; }
.device-name { color: #173b30; font-weight: 800; font-size: .92rem; text-decoration: none; }
.table-sub { display: block; color: #75897e; font-size: .78rem; margin-top: 3px; line-height: 1.35; }
.metric-inline { font-size: 1.02rem; }
.row-action { color: #166b51; font-weight: 750; font-size: .84rem; text-decoration: none; white-space: nowrap; }
.state-pill { display: inline-block; border-radius: 20px; padding: 5px 10px; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.state-good { background: #e1f4e9; color: #156842; }
.state-alert { background: #fff0e6; color: #9b471f; }
.state-neutral { background: #edf1ee; color: #556b5d; }
.empty-state, .empty-panel { text-align: center; color: #708579; padding: 30px 12px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 20px; padding-top: 18px; font-size: .83rem; color: #62776b; }
.pager a { font-weight: 700; text-decoration: none; }
.pager-disabled { color: #a5b2a9; }
.back-link { display: inline-block; margin-bottom: 16px; font-size: .84rem; font-weight: 750; text-decoration: none; }
.device-heading { align-items: center; margin-bottom: 14px; }
.device-heading h1 { margin-bottom: 7px; }
.device-identity { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: #667d70; font-size: .82rem; }
.device-heading-status { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; font-size: .81rem; }
.device-tabs { display: flex; border-bottom: 1px solid #d7e4dc; margin-bottom: 22px; gap: 18px; }
.device-tabs a { padding: 11px 2px; color: #637b6c; font-weight: 750; font-size: .9rem; text-decoration: none; border-bottom: 3px solid transparent; }
.device-tabs a[aria-current=page] { color: #155d47; border-bottom-color: #16835e; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 19px; }
.metric-card { padding: 18px 17px; min-width: 0; }
.metric-card strong { font-size: 1.65rem; }
.aqi-card { border-left: 4px solid #afbeb5; }
.aqi-card strong { font-size: 1.28rem; line-height: 1.2; }
.aqi-level-1 { border-left-color: #2f9161; background: #f0faf3; }
.aqi-level-2 { border-left-color: #3d9aaa; background: #eff9fa; }
.aqi-level-3 { border-left-color: #d2a531; background: #fffaec; }
.aqi-level-4 { border-left-color: #d98235; background: #fff5eb; }
.aqi-level-5 { border-left-color: #c8534a; background: #fff1ef; }
.aqi-level-6 { border-left-color: #884269; background: #fbf0f7; }
.aqi-note { color: #62776b; font-size: .78rem; line-height: 1.5; margin: -7px 0 20px; }
.trend-summary { display: flex; flex-wrap: wrap; gap: 34px; padding: 14px 0 5px; border-top: 1px solid #edf2ee; }
.trend-summary div { display: flex; align-items: baseline; gap: 6px; }
.trend-summary span { color: #64796d; font-size: .8rem; }
.trend-summary strong { font-size: 1.1rem; }
.trend-summary small { color: #64796d; }
.chart-wrap { width: 100%; margin-top: 8px; }
.trend-chart { display: block; width: 100%; height: auto; max-height: 265px; }
.trend-chart text { fill: #8a9b90; font-size: 12px; }
.chart-grid { stroke: #e7eee9; stroke-width: 1; }
.chart-line { fill: none; stroke: #178460; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: #178460; stroke: #fff; stroke-width: 1.5; }
.chart-axis { display: flex; justify-content: space-between; padding: 0 18px 0 42px; color: #819489; font-size: .76rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.detail-grid > .card { min-width: 0; }
.key-values { margin: 0; }
.key-values > div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid #edf2ee; }
.key-values > div:last-child { border-bottom: 0; }
.key-values dt { color: #6c8073; font-size: .83rem; }
.key-values dd { margin: 0; text-align: right; font-size: .84rem; font-weight: 700; max-width: 65%; overflow-wrap: anywhere; }
.owner-form { margin-top: 18px; padding-top: 18px; border-top: 1px solid #e5eee8; }
.owner-form label { display: block; margin-bottom: 9px; font-size: .83rem; font-weight: 700; color: #425f54; }
.owner-form-row { display: flex; align-items: center; gap: 9px; }
.owner-form-row select { min-width: 0; }
.owner-form-row button { flex: 0 0 auto; }
.control-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.control-row form { margin: 0; }
.interval-form { padding-top: 19px; }
.interval-form label { display: block; margin-bottom: 9px; }
.interval-form input { width: 100px; }
.interval-form span { color: #697d70; font-size: .83rem; }
.control-divider { height: 1px; background: #e5eee8; margin: 22px 0; }
.control-note { color: #71857a; font-size: .78rem; line-height: 1.5; margin: 14px 0 0; }
.status-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.status-values > div { border: 1px solid #e4eee8; background: #f9fcfa; border-radius: 9px; padding: 10px 12px; }
.status-values span { display: block; color: #71857a; font-size: .76rem; margin-bottom: 4px; }
.status-values strong { color: #284a3b; font-size: .86rem; overflow-wrap: anywhere; }
.data-source-note { margin: -4px 0 14px; padding: 12px 15px; border: 1px solid #d8e9df; border-radius: 10px; background: #f0f8f3; color: #405f50; font-size: .84rem; line-height: 1.5; }
.data-source-note strong { color: #19563e; }
.additional-metrics { padding-top: 18px; padding-bottom: 18px; }
.additional-metrics .section-heading { margin-bottom: 14px; }
.sensor-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sensor-values > div { padding: 12px 15px; border: 1px solid #e3ece6; border-radius: 10px; background: #f9fcfa; }
.sensor-values span, .sensor-values small { display: block; color: #6c8073; font-size: .78rem; }
.sensor-values strong { display: block; color: #244739; font-size: 1.22rem; margin: 4px 0; }
.firmware-card { margin-top: 18px; }
.firmware-upload { padding: 17px; border: 1px solid #e5eee8; border-radius: 12px; background: #f8fbf9; }
.firmware-form-grid { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(240px, 2fr); gap: 12px; }
.firmware-form-grid .field { margin-bottom: 0; }
.firmware-upload .check { margin: 14px 0; }
.firmware-card .table-wrap { margin-top: 18px; }
.debug-intro { margin-bottom: 18px; }
.topic-list { display: grid; gap: 8px; margin-top: 16px; }
.topic-list > div { display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid #edf2ee; padding: 7px 0; }
.topic-list > div:last-child { border: 0; }
.topic-list span { color: #688071; font-size: .78rem; font-weight: 700; }
.topic-list code { color: #1d4f3d; font-size: .8rem; }
.json-block { background: #f5f8f6; border: 1px solid #e2eae5; border-radius: 9px; color: #25443a; font-size: .78rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: auto; padding: 13px; margin: 0; }
summary { color: #166b51; font-weight: 700; cursor: pointer; white-space: nowrap; }
details .json-block { margin-top: 9px; min-width: 230px; }
.debug-payload { display: grid; gap: 8px; margin-top: 12px; }
.debug-payload strong { font-size: .77rem; color: #62776b; }
@media (max-width: 1150px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid.has-unassigned { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .detail-grid { grid-template-columns: 1fr; gap: 0; }
  .account { margin-left: auto; }
  .manager-nav { order: 3; width: 100%; }
}
@media (max-width: 700px) {
  header { padding: 16px 20px; }
  main { padding: 24px 16px 54px; }
  .page-heading, .device-heading, .intro { align-items: flex-start; flex-direction: column; }
  .device-heading-status { align-items: flex-start; }
  .summary-grid, .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .sensor-values { grid-template-columns: 1fr; }
  .status-values { grid-template-columns: 1fr; }
  .firmware-form-grid { grid-template-columns: 1fr; }
  .summary-card, .metric-card { padding: 15px; }
  .summary-card strong, .metric-card strong { font-size: 1.5rem; }
  .card { padding: 17px; }
  .table-filters { padding: 12px; }
  .table-filters .field { flex: 1 1 100% !important; }
  .table-filters .primary { flex: 1; }
  .device-table thead { display: none; }
  .device-table, .device-table tbody, .device-table tr, .device-table td { display: block; width: 100%; }
  .device-table tr { border-bottom: 1px solid #e4ede7; padding: 13px 0; }
  .device-table tr:last-child { border-bottom: 0; }
  .device-table td { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border: 0; padding: 5px 0; text-align: right; }
  .device-table td:first-child { display: block; text-align: left; }
  .device-table td[data-label]:not(:first-child)::before { content: attr(data-label); color: #7b8e81; font-size: .77rem; font-weight: 700; margin-right: auto; }
  .device-table td:last-child { padding-top: 10px; }
  .device-table td:last-child::before { content: none !important; }
  .device-table .table-sub { display: inline; }
  .device-table td:first-child .table-sub { display: block; }
  .section-heading { flex-wrap: wrap; }
  .pager { justify-content: space-between; gap: 10px; }
  .key-values > div { gap: 10px; }
  .key-values dd { max-width: 58%; }
  .trend-summary { gap: 12px 20px; }
}
