.device-view { --text: #192838; --app-gap: 16px; --app-pad: 18px; }
.device-heading { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 18px; margin-bottom: 18px; border: 1px solid #d7e2ec; border-radius: 16px; background: #e5edf5; }
.device-heading h1 { font-size: 30px; letter-spacing: -.7px; overflow-wrap: anywhere; }
.device-heading .eyebrow { margin: 0 0 4px; font-size: 12px; }
.device-section-trigger { min-width: 170px; justify-content: space-between; }
.device-connection { margin: 8px 0 16px; display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 15px; }
.device-state { display: flex; gap: 12px; align-items: center; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; margin-bottom: 16px; }
.device-state-ring { width: 28px; height: 28px; border: 3px solid #288153; border-radius: 50%; background: #edf0f3; flex-shrink: 0; }
.device-state[data-state="off"] .device-state-ring, .device-state[data-state="alarm"] .device-state-ring { border-color: #b52c31; background: #b52c31; }
.device-state[data-state="warning"] .device-state-ring { border-color: #a56c18; }
.device-state[data-state="offline"] .device-state-ring, .device-state[data-state="unknown"] .device-state-ring, .device-state[data-state="disabled"] .device-state-ring { border-color: #8794a3; background: #a8b2bd; }
.device-state strong { font-size: 21px; }
.device-state[data-state="alarm"] strong, .device-state[data-state="off"] strong { color: var(--danger); }
.device-state .device-mode { color: var(--muted); margin-left: auto; }
.device-pane { display: grid; gap: 16px; }
.device-view .detail-card { padding: var(--app-pad); border: 1px solid var(--line); border-radius: 16px; background: #fff; min-width: 0; }
.device-view .section-label { color: var(--muted); font-size: 17px; font-weight: 650; margin-bottom: 12px; }
.device-view .device-phase { border-top: 5px solid #e2c52f; }
.device-view .device-phase.phase-l2 { border-top-color: #3d9968; }
.device-view .device-phase.phase-l3 { border-top-color: #cd5057; }
.device-identity { margin: 18px 2px 0; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.device-view .measurement-stack { display: grid; gap: var(--app-gap); }
.device-view .measurement-stack[data-phases="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.device-view .measurement-stack[data-phases="3"] > .detail-card:not(.device-phase) { grid-column: 1 / -1; }
.device-view .measurement-stack[data-phases="3"] .device-phase .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.device-view .detail-phase-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.device-view .detail-phase-grid.phase-count-1 { grid-template-columns: minmax(0, 1fr); }
.device-view .detail-phase-block { min-width: 0; border: 1px solid #d9e1ec; border-radius: 10px; overflow: hidden; }
.device-view .detail-phase-title { padding: 6px 12px; background: #e6ca35; color: #253342; font-size: 18px; font-weight: 750; }
.device-view .phase-l2 .detail-phase-title { background: #3d9968; color: #fff; }
.device-view .phase-l3 .detail-phase-title { background: #cd5057; color: #fff; }
.device-view .detail-phase-list, .device-view .metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; }
.device-view .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; }
.device-view .metric-tile { min-width: 0; border: 1px solid #e4eaf0; border-radius: 10px; padding: 14px; background: #f6f9fb; }
.device-view .detail-phase-list .metric-tile { padding: 0; border: 0; background: transparent; }
.device-view .metric-tile > span { display: block; color: var(--muted); font-size: 16px; line-height: 1.3; }
.device-view .metric-tile strong { display: block; font-size: 27px; line-height: 1.25; margin-top: 5px; color: #192838; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.device-view .metric-tile .metric-threshold { margin-top: 5px; font-size: 14px; }
.device-view .metric-tile.is-alarm strong { color: #b22a33; }
.device-empty { padding: 28px 8px; color: var(--muted); }
.device-loading { padding: 20px; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.device-tab-actions { display: flex; gap: 12px; justify-content: flex-end; }
.device-control { max-width: 780px; width: 100%; }
.device-control-state { display: none; }
.device-control-state strong { font-size: 25px; }
.device-control-state span { color: var(--muted); }
.device-control-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.device-control-actions .button { min-height: 82px; font-size: 22px; }
.device-control-actions .device-control-primary { grid-column: 1 / -1; }
.device-control-actions .device-control-test { grid-column: 1 / -1; min-height: 58px; font-size: 20px; }
.device-control-actions .button-success { background: #e9f6ef; color: #246f4b; border-color: #9bc7ac; }
.device-result { margin: 16px 0 0; padding: 16px; border-radius: 12px; background: #edf2f6; }
.device-result[data-outcome="completed"] { color: #246f4b; background: #e9f6ef; }
.device-result[data-outcome="uncertain"], .device-result[data-outcome="failed"], .device-result[data-outcome="expired"] { color: #a42d38; background: #fff0f1; }
.device-modal-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: #1c2b40ad; }
.device-modal { display: flex; flex-direction: column; width: min(760px, 100%); max-height: calc(100dvh - 48px); border-radius: 22px; background: #fff; box-shadow: 0 20px 70px #0004; overflow: hidden; }
.device-modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.device-modal-head h2 { font-size: 26px; }
.device-modal-content { padding: 24px; overflow-y: auto; overscroll-behavior: contain; }
.device-modal-content p { white-space: pre-line; }
.device-modal-content .actions .button { min-height: 62px; flex: 1; font-size: 20px; }
.device-picker-list { display: grid; gap: 12px; }
.device-picker-list .button { min-height: 64px; justify-content: space-between; font-size: 21px; }
.device-picker-list .button[aria-pressed="true"] { border-color: #397d91; color: #245465; background: #e6f1f5; }
.device-picker-list .button[aria-pressed="true"]::after { content: '✓'; }
.device-view .history-point-panel { min-height: 98px; display: grid; gap: 10px; padding: 0 4px 16px; }
.device-view .history-point-time { font-size: 16px; color: var(--muted); }
.device-view .history-point-values { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.device-view .history-point-value { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; }
.device-view .history-point-value i { display: inline-block; width: 6px; height: 26px; border-radius: 3px; }
.device-view .history-point-value strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.device-view .history-chart { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
.device-view .history-grid-line { stroke: #e2e9ef; stroke-width: 1; }
.device-view .history-line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.device-view .history-cursor-line { stroke: #6c849a; stroke-dasharray: 4 4; stroke-width: 1.5; }
.device-view .history-cursor-point { stroke: #fff; stroke-width: 2; }
.device-view .history-axis-value { fill: #647589; font: 14px system-ui, sans-serif; }
.device-view .history-axis { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); }
.device-view .history-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.device-view .history-controls .button { width: 100%; justify-content: space-between; }
.device-view .history-controls label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 15px; }
.device-view .history-archive-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; margin-top: 18px; }
.device-view .history-archive-nav input { width: 100%; accent-color: #397c8b; min-height: 48px; }
.device-view .history-archive-label { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.device-journal-list { display: grid; gap: 9px; }
.device-journal-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; padding: 16px; min-height: 66px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); text-align: left; align-items: center; width: 100%; }
.device-journal-icon { display: grid; width: 30px; height: 30px; place-items: center; color: #52718c; background: #eaf1f7; border-radius: 9px; font-size: 21px; }
.device-journal-row[data-severity="alarm"] .device-journal-icon, .device-journal-row[data-severity="error"] .device-journal-icon { color: #ac2c35; background: #fff0f1; }
.device-journal-row[data-severity="warning"] .device-journal-icon { color: #95600f; background: #fff6df; }
.device-journal-row time { color: var(--muted); font-size: 14px; text-align: right; }
.device-journal-message { overflow-wrap: anywhere; }
.device-event-description { border-left: 4px solid #b52c31; border-radius: 10px; padding: 16px; background: #fff2f3; font-size: 22px; font-weight: 700; margin: 16px 0; }
.device-event-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.device-event-value { border: 1px solid var(--line); padding: 14px; border-radius: 12px; background: #f5f8fb; }
.device-event-value span { display: block; color: var(--muted); font-size: 16px; }
.device-event-value strong { font-size: 26px; display: block; margin-top: 5px; }
.device-event-value.is-alarm strong { color: #b52c31; }
@media (max-width: 1000px) {
    .device-view .measurement-stack[data-phases="3"] { grid-template-columns: minmax(0, 1fr); }
    .device-view .detail-phase-grid { grid-template-columns: minmax(0, 1fr); }
    .device-view .detail-phase-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
    body:has(.device-view) .site-header { min-height: 80px; padding-top: 8px; padding-bottom: 8px; flex-direction: row; align-items: center; gap: 12px; }
    body:has(.device-view) .account { display: flex; flex-direction: column; align-items: flex-end; width: auto; flex: 1; gap: 5px; }
    body:has(.device-view) .account-email { font-size: 13px; }
    body:has(.device-view) .account .button { width: auto; min-height: 38px; padding: 7px 12px; }
    body:has(.device-view) .brand { min-height: 60px; }
    body:has(.device-view) .brand-lockup { height: 60px; width: 77px; }
    body:has(.device-view) main { margin-top: 18px; }
    .device-heading { grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 12px; }
    .device-heading h1 { font-size: 25px; }
    .device-heading .device-section-trigger { grid-column: 1 / -1; width: 100%; }
    .device-heading .eyebrow { letter-spacing: .5px; }
    .device-view .detail-phase-list, .device-view .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .device-view .metric-tile { padding: 12px; }
    .device-view .metric-tile strong { font-size: 24px; }
    .device-view .metric-tile > span { font-size: 15px; }
    .device-view .history-controls { gap: 10px; }
    .device-view .history-controls .button { padding: 12px; font-size: 16px; }
    .device-view .history-chart { min-height: 210px; }
    .device-view .history-point-values { gap: 8px; }
    .device-view .history-point-value { gap: 5px; }
    .device-view .history-point-value > span { font-size: 13px; }
    .device-view .history-point-value strong { font-size: 23px; }
    .device-modal-overlay { padding: 10px; }
    .device-modal { max-height: calc(100dvh - 20px); border-radius: 18px; }
    .device-modal-head, .device-modal-content { padding: 16px; }
    .device-modal-head h2 { font-size: 23px; }
    .device-modal-head .button { padding: 10px 12px; font-size: 16px; }
    .device-journal-row { grid-template-columns: 28px minmax(0, 1fr); gap: 6px 10px; padding: 12px; }
    .device-journal-row time { grid-column: 2; }
    .device-event-grid { grid-template-columns: minmax(0, 1fr); }
}
