/* Device list and configuration: keep these rules scoped to the device page. */
.devices-page {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.devices-page > * { min-width: 0; }
.device-list-card, .device-config-card, .device-info-card, .device-data-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.device-config-card, .device-info-card { padding: 20px; }
.device-list-card { overflow: hidden; }
.main-wrap:has(.device-list-page) .topbar .muted { display: none; }
.device-filters { padding: 16px 20px; }
.device-filter-row, .device-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.device-filter-row { flex-wrap: wrap; }
.device-search-group { display: flex; flex: 1 1 320px; max-width: 620px; gap: 10px; }
.device-search-group input { flex: 1; }
.device-selection { color: var(--muted); font-size: 16px; white-space: nowrap; }
.device-filter-fields {
    display: none;
    align-items: end;
    gap: 12px;
    margin-top: 14px;
}
.device-filter-fields.is-custom { display: grid; grid-template-columns: repeat(2, minmax(0, 250px)); }
.devices-page label {
    display: grid;
    gap: 7px;
    min-width: 0;
    margin: 0;
    color: var(--muted);
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0;
}
.devices-page input:not([type="checkbox"]), .devices-page select {
    min-width: 0;
    height: 40px;
    padding: 8px 11px;
    border-radius: 8px;
    font-size: 17px;
    color: var(--text);
}
.devices-page .device-filter-fields label { font-size: 15px; }
.devices-page .device-filter-fields input, .devices-page .device-filter-fields .device-button { font-size: 16px; }
.devices-page input:focus-visible, .devices-page select:focus-visible, .devices-page button:focus-visible, .device-data-panel summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
.devices-page .device-button {
    min-height: 40px;
    padding: 9px 18px;
    border-radius: 8px;
    box-shadow: none;
    font-size: 17px;
    font-weight: 500;
    line-height: 22px;
    white-space: nowrap;
}
.devices-page button:disabled { cursor: not-allowed; opacity: .45; }
.devices-page h2 { margin: 0; font-size: 17px; font-weight: 600; }
.device-section-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}
.device-bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.device-bulk-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px 24px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--accent-soft); }
.device-bulk-selection { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 18px; }
.device-bulk-selection > span:last-child { font-size: 15px; color: var(--muted); }
.device-bulk-toolbar .device-selection { min-width: 100px; font-weight: 500; }
.device-bulk-toolbar .device-selection { color: var(--accent); }
.device-table-wrap tbody tr:has(input[data-fan-device]:checked) { background: #f0f8f8; }
.device-selection { margin-right: 4px; }
.device-table-wrap { border-top: 1px solid var(--line); }
.device-table-wrap table { width: 100%; min-width: 850px; }
.device-table-wrap th, .device-table-wrap td { padding: 15px 18px; }
.device-table-wrap th { background: var(--surface-2); color: var(--muted); font-size: 15px; font-weight: 600; }
.device-table-wrap th:first-child, .device-table-wrap td:first-child { width: 60px; text-align: center; padding-right: 8px; }
.devices-page input[type="checkbox"] {
    display: inline-block;
    width: 16px;
    height: 16px;
    padding: 0;
    margin: 0;
    vertical-align: middle;
    accent-color: var(--accent);
    cursor: pointer;
    box-shadow: none;
}
.device-cell-sub { display: block; margin-top: 5px; font-size: 15px; color: var(--muted); }
.device-model { margin-left: 10px; }
.device-mono { font-family: ui-monospace, Consolas, monospace; }
.device-channel-cell { display: block; max-width: 270px; white-space: normal; overflow-wrap: anywhere; line-height: 1.6; }
.device-log-status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; background: #f0f3f4; color: #66777e; border-radius: 6px; font-size: 15px; white-space: nowrap; }
.device-log-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #93a2a8; }
.device-log-status.is-enabled { background: #e5f6ec; color: var(--ok); font-weight: 600; }
.device-log-status.is-enabled::before { background: var(--ok); }
.device-config-link { border: 0; border-radius: 6px; padding: 6px 10px; color: #fff; background: var(--accent); font-size: 15px; font-weight: 500; }
.device-config-link:hover:not(:disabled) { background: #195d63; }
.device-config-link:active:not(:disabled) { background: #144d52; }
.device-list-note { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.device-empty { display: grid; gap: 6px; padding: 56px 24px; color: var(--muted); text-align: center; border-top: 1px solid var(--line); line-height: 1.8; }
.device-empty strong { font-size: 18px; color: var(--text); }
.device-pagination { display: flex; align-items: center; gap: 20px; padding: 14px 20px; color: var(--muted); font-size: 15px; }
.device-pagination > span { white-space: nowrap; }
.device-pagination .events-pager { flex: 1; padding: 0; }
.devices-page .events-pager-jump { display: flex; align-items: center; gap: 6px; }
.devices-page .events-pager input, .devices-page .events-pager select { height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 15px; }
.device-log-heading { min-height: 40px; }
.device-log-control { display: flex; align-items: center; gap: 12px; flex: none; min-height: 40px; }
.device-log-control > span { min-width: 85px; text-align: right; color: var(--muted); font-size: 17px; }
.device-log-control > span.is-enabled { color: var(--accent); }
.device-log-switch { position: relative; flex: none; width: 48px; height: 28px; padding: 0; border: 0; border-radius: 999px; background: #a4b2b8; transition: background .15s ease; }
.device-log-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(24, 43, 52, .18); transition: transform .15s ease; }
.device-log-switch[aria-checked="true"] { background: var(--accent); }
.device-log-switch[aria-checked="true"]::after { transform: translateX(20px); }
.device-config-hint { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; line-height: 1.8; }
.device-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 28px; margin: 22px 0 0; }
.device-facts dt { margin-bottom: 6px; color: var(--muted); font-size: 15px; }
.device-facts dd { margin: 0; overflow-wrap: anywhere; }
.device-data-panel { padding: 0 20px; overflow: hidden; }
.device-data-panel summary { padding: 17px 0; cursor: pointer; font-size: 17px; font-weight: 500; }
.device-data-panel summary span { margin-left: 12px; font-size: 15px; font-weight: 400; color: var(--muted); }
.device-data-panel > .empty { padding-bottom: 20px; }
.device-data-panel > .table-wrap { margin-bottom: 20px; }
.device-event-filters { display: grid; grid-template-columns: minmax(0, 230px) minmax(0, 230px) auto; justify-content: start; align-items: end; gap: 12px; margin: 0 0 12px; }
.device-event-filters label { font-size: 15px; }
.devices-page .device-event-filters input { font-size: 16px; }
.device-event-status { min-height: 24px; margin: 0 0 12px; font-size: 15px; color: var(--muted); }
.device-events-results { height: 420px; overflow: auto; overflow-anchor: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.device-events-results .table-wrap { overflow: visible; }
.device-events-results table { min-width: 600px; }
.device-events-results .empty { padding: 40px 16px; }
.device-event-pagination { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 0; font-size: 15px; color: var(--muted); }
.device-event-pagination > div { display: flex; gap: 8px; }

@media (max-width: 720px) {
    .devices-page { gap: 14px; }
    .device-filters, .device-config-card, .device-info-card { padding: 16px; }
    .device-section-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
    .device-search-group { flex-basis: 100%; max-width: none; }
    .device-filter-fields, .device-filter-fields.is-custom { grid-template-columns: minmax(0, 1fr); }
    .device-bulk-toolbar { padding: 14px 16px; gap: 12px; }
    .device-bulk-actions { width: 100%; }
    .device-pagination { flex-wrap: wrap; gap: 12px; }
    .device-pagination .events-pager { flex-basis: 100%; }
    .devices-page .device-log-heading { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
    .device-log-control { gap: 8px; }
    .device-log-control > span { min-width: 68px; }
    .device-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
    .device-event-filters { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .device-log-switch, .device-log-switch::after { transition: none; }
}

.device-alpha-heading { min-height: 40px; }
.device-alpha-controls { display: flex; align-items: center; gap: 10px; flex: none; max-width: 100%; }
.devices-page .device-alpha-controls input { width: 120px; }
@media (max-width: 720px) {
    .device-alpha-heading { flex-direction: row; flex-wrap: wrap; align-items: center; }
}
@media (max-width: 520px) {
    .device-alpha-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; width: 100%; }
    .devices-page .device-alpha-controls input { width: 100%; }
    .devices-page .device-alpha-controls .device-button { padding: 8px 12px; font-size: 16px; }
}
