:root { font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif; color:#243b32; background:#f5f5f0; font-synthesis:none; --line:#dbe3d5; --muted:#63715f; }
* { box-sizing:border-box; }
body { margin:0; }
p,h1,h2,h3 { margin:0; }
button,input { font:inherit; }
button { cursor:pointer; }
button:disabled { opacity:.45; cursor:not-allowed; }
a { color:inherit; text-decoration:none; }
[hidden] { display:none!important; }
svg { fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
button:focus-visible,a:focus-visible,summary:focus-visible,input:focus-visible { outline:3px solid #6c8e55; outline-offset:2px; }
.shell { max-width:1440px; margin:auto; padding:0 28px; }
.masthead { height:60px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--line); }
.brand { display:flex; align-items:center; gap:10px; font-size:22px; font-weight:650; }
.brand-icon { display:grid; place-items:center; width:36px; height:36px; border:1px solid #acbca0; border-radius:11px; }
.brand-icon svg { width:22px; }
.brand-en { display:block; font-size:8px; font-weight:450; letter-spacing:1.3px; margin-top:2px; color:var(--muted); }
.read-only { font-size:12px; color:var(--muted); }
.connection-bar { display:flex; align-items:center; justify-content:space-between; gap:8px; height:54px; }
.connection-info { display:flex; align-items:center; gap:7px; font-size:13px; }
.connection-summary { flex:1; min-width:0; }
.dot { height:6px; width:6px; border-radius:50%; background:#56774a; flex:none; }
.dot.error { background:#a77a35; }.dot.pending { background:#929b8b; }
#refresh { display:flex; align-items:center; gap:6px; min-height:44px; padding:0 12px; border:1px solid var(--line); background:#fafbf7; color:#345746; border-radius:9px; font-size:12px; }
#refresh svg { width:16px; height:16px; }
.section-heading { display:flex; align-items:center; justify-content:space-between; margin:0 0 10px; }
.section-heading h2 { font-size:14px; font-weight:550; }
.section-heading h2 span { font-size:9px; letter-spacing:1.4px; margin-left:8px; color:var(--muted); }
.device-count { font-size:11px; color:var(--muted); }
.device-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.device-card { min-width:0; display:grid; grid-template-columns:1.15fr 1fr; column-gap:10px; padding:12px 16px 4px; border:1px solid #d8e1ce; border-radius:14px; background:linear-gradient(120deg,#f0f4e7,#eaf0df); }
.device-top { grid-column:1/-1; display:flex; align-items:center; justify-content:space-between; gap:6px; margin-bottom:8px; }
.device-identity { display:flex; align-items:center; gap:9px; min-width:0; }
.device-identity h3 { font-size:18px; line-height:1.2; font-weight:600; }
.ac-icon { display:grid; place-items:center; width:34px; height:34px; flex:none; border:1px solid #c8d4bb; border-radius:10px; }
.ac-icon svg { width:28px; }
.device-kind { font-size:10px; line-height:1.3; color:var(--muted); margin-top:2px; }
.power { font-size:10px; padding:3px 7px; border-radius:20px; background:#ffffff65; color:#5a6b51; white-space:nowrap; }
.power.on { background:#345b43; color:#fff; }.power.unknown { color:#805e2e; background:#eee5d4; }
.metric-label { font-size:11px; color:var(--muted); }
.temperature { display:flex; align-items:baseline; gap:4px; margin-top:3px; font-variant-numeric:tabular-nums; }
.temperature>span:first-child { font-size:40px; line-height:1.05; font-weight:400; letter-spacing:-1.5px; }
.temperature-unit { font-size:17px; color:#627658; }
.temperature.missing>span:first-child { font-size:22px; line-height:1.9; letter-spacing:0; }
.temperature-note { font-size:10px; line-height:1.4; color:var(--muted); margin-top:4px; }
.temperature-note.aging { color:#8b642e; }
.ambient-ring { display:none; }
.metrics { padding-top:1px; align-self:start; border-left:1px solid #d5dfca; padding-left:18px; }
.metric-value { font-size:23px; margin-top:7px; line-height:1.2; font-variant-numeric:tabular-nums; }
.metric-caption { margin-top:5px; font-size:10px; line-height:1.4; color:var(--muted); }
.quick-area { grid-column:1/-1; margin-top:8px; }
.quick-buttons,.quick-confirm { display:flex; gap:6px; }
.quick-area button { min-height:40px; padding:4px 12px; border:1px solid #bacbb0; border-radius:8px; background:#fafcf6; color:#345746; font-size:13px; }
.quick-area [data-quick="power"] { flex:1; text-align:left; }
.quick-area [data-delta] { min-width:44px; font-size:18px; }
.quick-area [data-quick-confirm] { flex:1; color:#fff; background:#345746; border-color:#345746; }
.quick-confirm button { white-space:nowrap; }
.card-footer { grid-column:1/-1; display:flex; align-items:center; justify-content:space-between; gap:4px; margin-top:2px; font-size:10px; color:var(--muted); }
.card-footer button { min-height:28px; background:none; border:0; color:#345746; padding:2px 0 2px 8px; font-size:11px; }
.device-card.stale { background:#eeeee6; border-color:#dcded3; }
.device-card.stale .temperature,.device-card.stale .metric-value { color:#777e6e; }
.notice { margin-top:2px; color:#805e2e; font-size:10px; line-height:1.4; overflow-wrap:anywhere; }
.host-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-top:8px; }
.host-tile { min-width:0; border:1px solid var(--line); border-radius:10px; padding:6px 10px; color:#345746; background:#f9faf6; text-align:left; }
.host-heading { display:flex; justify-content:space-between; align-items:center; gap:4px; font-size:12px; line-height:15px; }
.host-heading strong { font-weight:600; }.host-state { font-size:10px; color:var(--muted); }
.host-metrics { display:flex; flex-wrap:wrap; gap:2px 10px; font-size:11px; line-height:16px; font-variant-numeric:tabular-nums; }
.host-metrics>span { white-space:nowrap; }.host-time { display:block; font-size:9px; line-height:12px; color:var(--muted); }
.host-tile.stale { background:#eeeee6; color:#737c6d; }.host-tile.stale .host-state { color:#8b642e; }
.conversation { margin-top:12px; padding:10px 14px; border:1px solid var(--line); border-radius:12px; background:#fafbf7; }
.conversation-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; min-height:22px; margin-bottom:5px; }
.conversation h2 { font-size:13px; font-weight:600; }
#show-result { border:0; background:none; color:#345746; padding:2px; font-size:11px; text-align:right; }
#conversation-form { display:flex; align-items:stretch; gap:8px; }
#conversation-input { flex:1; min-width:0; height:40px; padding:6px 10px; border:1px solid var(--line); border-radius:8px; color:#243b32; background:#fff; font-size:13px; }
#conversation-input::placeholder { color:#77836e; }
#open-conversation { display:flex; align-items:center; justify-content:center; min-height:40px; padding:4px 12px; border:0; border-radius:8px; color:#fff; background:#345746; font-size:12px; white-space:nowrap; }
#conversation-hint { font-size:10px; line-height:1.4; color:var(--muted); margin-top:5px; }
.page-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:34px; font-size:10px; color:var(--muted); }
.page-footer button { border:0; background:none; color:inherit; padding:0; min-height:32px; font-size:10px; }
dialog { width:min(440px,calc(100% - 32px)); max-height:85dvh; overflow:auto; border:1px solid #cdd7c3; border-radius:18px; padding:24px; color:#243b32; background:#f5f5f0; }
dialog::backdrop { background:#243b3255; }
dialog h2 { font-size:20px; margin-bottom:20px; }
dialog .metric { margin-bottom:14px; }
dialog .metric-value { font-size:19px; }
.source-details { font-size:12px; margin:16px 0; }
.source-details>div { display:grid; grid-template-columns:100px 1fr; gap:12px; margin:12px 0; }
.source-details dt { color:var(--muted); }.source-details dd { margin:0; overflow-wrap:anywhere; }
.source-explanation,.control-hint { font-size:12px; color:var(--muted); line-height:1.7; margin:8px 0; }
summary { display:flex; justify-content:space-between; align-items:center; cursor:pointer; min-height:44px; font-size:13px; list-style:none; }
summary::-webkit-details-marker { display:none; }
.device-controls { border-top:1px solid var(--line); margin:16px 0; }
.control-buttons,.temperature-control,.dialog-actions { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:8px 0; }
dialog button { min-height:44px; padding:8px 16px; border:1px solid #a6b59a; border-radius:9px; color:#345746; background:#fafcf7; font-size:13px; }
.temperature-control label { font-size:12px; }.temperature-control input { width:80px; min-height:44px; padding:8px; border:1px solid #a6b59a; border-radius:8px; }
.dialog-actions { justify-content:flex-end; margin-top:20px; }#send-operation { background:#345746; color:white; }
#operation-status { white-space:pre-wrap; overflow-wrap:anywhere; font-size:12px; line-height:1.6; }
#expand-chat { border:0; padding:0; min-height:22px; color:#345746; background:none; font-size:12px; font-weight:600; }
#chat-dialog { position:fixed; inset:12px 12px 12px auto; margin:0; width:min(440px,calc(100% - 24px)); height:calc(100dvh - 24px); max-height:none; padding:16px; border-radius:14px; }
#chat-dialog[open] { display:flex; flex-direction:column; gap:10px; }
.chat-header { display:flex; justify-content:space-between; align-items:center; gap:8px; flex:none; }
.chat-header h2 { margin:0 0 4px; font-size:17px; }
.chat-header p { font-size:10px; color:var(--muted); }
.chat-header button { flex:none; }
.chat-toolbar { display:flex; align-items:center; justify-content:space-between; gap:6px; flex-wrap:wrap; flex:none; }
#chat-state { font-size:11px; color:var(--muted); flex:1; }
.chat-toolbar button { min-height:32px; padding:4px 8px; font-size:11px; }
#chat-messages { flex:1; min-height:60px; overflow:auto; overscroll-behavior:contain; padding:3px; }
.chat-message { margin:0 0 14px; padding:10px 12px; border-radius:10px; background:#fff; border:1px solid var(--line); }
.chat-message.from-user { background:#e7eedd; margin-left:24px; }
.chat-message.from-assistant { margin-right:12px; }
.chat-author { display:block; font-size:10px; color:var(--muted); margin-bottom:5px; }
.chat-message p { white-space:pre-wrap; overflow-wrap:anywhere; font-size:13px; line-height:1.65; }
.chat-empty { font-size:13px; color:var(--muted); padding:18px 4px; line-height:1.8; }
#chat-notice { font-size:10px; line-height:1.5; color:var(--muted); flex:none; }
#chat-form { display:flex; gap:8px; flex:none; }
#chat-input { min-width:0; width:100%; height:44px; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:#fff; font-size:14px; }
#chat-send { flex:none; background:#345746; color:white; }
@media(max-width:600px) { #chat-dialog { inset:8px; width:calc(100% - 16px); height:calc(100dvh - 16px); padding:12px; } }
@media(min-width:1500px) { .device-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }.shell { max-width:1800px; } }
@media(max-width:600px) {
  .shell { padding:0 12px; }.masthead { height:48px; }.brand { font-size:19px; }.brand-en { display:none; }.brand-icon { width:30px; height:30px; }
  .connection-bar { height:50px; }.connection-info { font-size:11px; }.section-heading { margin-bottom:8px; }
  .device-grid { gap:8px; }.device-card { grid-template-columns:1fr; padding:10px 10px 2px; border-radius:12px; }
  .device-top { align-items:flex-start; gap:2px; margin-bottom:6px; }.ac-icon { display:none; }.device-identity h3 { font-size:16px; }.device-kind { font-size:9px; white-space:nowrap; }
  .power { font-size:9px; padding:2px 4px; }
  .temperature>span:first-child { font-size:34px; }.temperature-unit { font-size:14px; }.metric-label { font-size:10px; }
  .temperature-note { font-size:10px; margin-top:4px; }.temperature.missing>span:first-child { font-size:20px; line-height:1.8; }
  .metrics { border:0; padding:0; margin-top:7px; }.metric-value { display:inline; font-size:16px; line-height:1.3; }.metrics .metric-label { display:inline; margin-right:4px; }.metrics .metric-caption { display:none; }
  .quick-area { margin-top:6px; }.quick-buttons,.quick-confirm { gap:4px; }.quick-area button { min-height:40px; padding:4px 6px; font-size:11px; }.quick-area [data-delta] { min-width:34px; padding:4px; font-size:18px; }
  .card-footer { font-size:9px; }.card-footer button { font-size:10px; min-height:28px; padding-left:3px; }
  .page-footer { font-size:9px; }.page-footer button { font-size:9px; }.read-only { font-size:11px; }
  .conversation { margin-top:10px; padding:8px 10px; }#conversation-input { font-size:12px; padding:6px 8px; }#open-conversation { padding:4px 8px; font-size:11px; }
}
@media(min-width:601px) and (max-height:720px) {
  .masthead { height:48px; }.connection-bar { height:48px; }.section-heading { margin-bottom:8px; }
  .device-card { padding:8px 14px 2px; }.device-top { margin-bottom:6px; }.temperature>span:first-child { font-size:34px; }.metric-value { font-size:22px; }.temperature-note { margin-top:3px; }
  .quick-area { margin-top:6px; }.quick-area button { min-height:36px; }.card-footer button { min-height:24px; }.device-grid { gap:8px; }
  .conversation { margin-top:8px; padding:6px 12px; }
}
@media(min-width:601px) and (max-height:500px) {
  .section-heading { display:none; }.masthead { height:38px; }.connection-bar { height:44px; }.brand { font-size:18px; }.brand-en { display:none; }.brand-icon { width:28px; height:28px; }
  .device-card { padding:6px 12px 0; }.device-top { margin-bottom:3px; }.device-identity h3 { font-size:15px; line-height:18px; }.device-kind { font-size:9px; line-height:11px; margin-top:0; }.ac-icon { width:28px; height:28px; }
  .metric-label { font-size:10px; line-height:12px; }.temperature { margin-top:1px; }.temperature>span:first-child { font-size:30px; line-height:31px; }.temperature-note { font-size:10px; line-height:12px; margin-top:1px; }.metric-caption { margin-top:3px; }
  .quick-area { margin-top:4px; }.quick-area button { min-height:32px; font-size:12px; }.quick-area [data-delta] { font-size:17px; }
  .card-footer { margin-top:0; }.card-footer button { min-height:22px; }.device-grid { gap:6px; }
  .conversation { display:grid; grid-template-columns:130px 1fr; gap:0 10px; margin-top:6px; padding:5px 10px; }.conversation-heading { flex-direction:column; align-items:flex-start; justify-content:center; margin:0; grid-row:1/3; }
  #conversation-form { gap:6px; }#conversation-input { height:32px; }#open-conversation { min-height:32px; }#conversation-hint { margin-top:2px; }
  .page-footer { min-height:26px; }.page-footer button { min-height:26px; }
}
@media(min-width:601px) and (max-height:600px) {
  .section-heading { display:none; }
  .conversation { display:grid; grid-template-columns:130px 1fr; gap:0 10px; padding:5px 10px; }
  .conversation-heading { flex-direction:column; align-items:flex-start; justify-content:center; margin:0; grid-row:1/3; }
  #conversation-form { gap:6px; }#conversation-input { height:32px; }#open-conversation { min-height:32px; }#conversation-hint { margin-top:2px; }
}
@media(min-width:601px) and (max-height:500px) {
  .metrics .metric-caption { display:none; }
  .temperature-area { display:grid; grid-template-columns:auto 1fr; align-content:start; }
  .temperature-area .metric-label { grid-column:1; grid-row:1; }
  .temperature-note { grid-column:2; grid-row:1; text-align:right; margin:0; }
  .temperature { grid-column:1/-1; grid-row:2; }
  .quick-area button { line-height:20px; }
}
/* Make room for two host summaries without taking away the conversation entry.
   Narrow terminals use four compact device columns instead of two tall rows. */
@media(min-width:760px) and (max-height:800px) {
  .device-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .device-card { grid-template-columns:1fr; padding:10px 10px 2px; }
  .device-top { gap:3px; align-items:flex-start; margin-bottom:6px; }.ac-icon { display:none; }
  .device-identity h3 { font-size:16px; }.device-kind { font-size:9px; }.power { padding:2px 4px; font-size:9px; }
  .temperature-area { display:block; }.temperature-note { text-align:left; margin-top:4px; }
  .temperature>span:first-child { font-size:34px; line-height:1.1; }
  .metrics { border:0; padding:0; margin-top:8px; }.metrics .metric-label { display:inline; margin-right:4px; }.metrics .metric-value { display:inline; font-size:18px; }.metrics .metric-caption { display:none; }
  .quick-area { margin-top:8px; }.quick-area button { min-height:40px; padding:4px 6px; }.quick-area [data-delta] { min-width:34px; }
  .card-footer button { min-height:28px; }
}
@media(max-width:600px) {
  .device-card { padding-top:8px; }.device-top { margin-bottom:4px; }
  .temperature-area { display:grid; grid-template-columns:auto 1fr; align-content:start; }
  .temperature-area .metric-label { grid-column:1; grid-row:1; }
  .temperature-note { grid-column:2; grid-row:1; text-align:right; font-size:9px; margin:0; }
  .temperature { grid-column:1/-1; grid-row:2; }
  .metrics { margin-top:4px; }.quick-area { margin-top:4px; }.card-footer button { min-height:24px; }
  .host-tile { padding:5px 6px; }.host-heading { font-size:11px; line-height:14px; }.host-state { font-size:9px; }
  .host-metrics { gap:2px 5px; font-size:10px; line-height:15px; }.host-time { font-size:9px; line-height:11px; }
}
@media(max-width:360px) {
  /* The connection bar already names the four devices; avoid repeating that
     heading when the host metrics need to wrap at maximum-width values. */
  .section-heading { display:none; }
}
/* Keep a normal single-device warning in the existing connection row. Multiple
   long errors may expand it rather than overlap, clip, or conceal the errors. */
.connection-bar { height:auto; min-height:54px; padding:5px 0; }
@media(max-width:600px) { .connection-bar { min-height:50px; padding:3px 0; } }
@media(min-width:601px) and (max-height:720px) { .connection-bar { min-height:48px; padding:2px 0; } }
@media(min-width:601px) and (max-height:500px) { .connection-bar { min-height:44px; padding:0; } }

/* Login is a separate screen; it never consumes the fixed overview's grid. */
.header-actions { display: flex; align-items: center; gap: 10px; }
#logout { min-height: 28px; padding: 3px 8px; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbf7; color: #345746; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(100%, 360px); display: block; }
.login-brand { font-size: 24px; font-weight: 700; margin: 0 0 16px; }
.login-card h1 { font-size: 24px; line-height: 1.35; margin: 0 0 12px; }
.login-card p { line-height: 1.6; }
#login-form { display: grid; gap: 12px; margin: 24px 0 12px; }
#password { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #bacbb0; border-radius: 8px; font: inherit; color: #243b32; background: white; }
#login-submit { min-height: 44px; border: 0; border-radius: 8px; background: var(--accent, #355d4b); color: white; }
#login-message { min-height: 3.2em; font-size: 14px; }
.login-footnote { font-size: 12px; color: var(--muted, #657565); }
@media (max-width: 480px) { .login-protected .header-actions .read-only { display: none; } }

#open-automations { min-height:28px; padding:3px 8px; font-size:12px; }
#automations-dialog { width:min(540px,calc(100% - 16px)); max-height:calc(100dvh - 24px); }
#automations-dialog[open] { display:flex; flex-direction:column; gap:8px; }
#automations-dialog .chat-header h2 { margin:0; }
#automation-list { min-height:40px; overflow:auto; overscroll-behavior:contain; }
.automation-item { padding:10px 0; border-bottom:1px solid var(--line); }
.automation-item p { white-space:pre-wrap; overflow-wrap:anywhere; font-size:12px; line-height:1.6; margin-bottom:6px; }
#automation-notice, #automation-confirm { font-size:12px; line-height:1.5; overflow-wrap:anywhere; flex:none; }
#automations-dialog > button, #automations-dialog > header, #automations-dialog > p { flex:none; }
@media(max-width:480px) { .header-actions { gap:4px; } .header-actions .read-only { display:none; } }
