.devices-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.devices-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.devices-admin-badge {
    display: inline-flex;
    align-items: center;
    min-height: 23px;
    padding: 0 8px;
    border: 1px solid #cfe2d2;
    border-radius: 999px;
    background: #f2f8f3;
    color: var(--green-800);
    font-size: 9px;
    font-weight: 820;
}

.devices-header-actions {
    display: flex;
    gap: 8px;
}

.device-stats {
    display: grid;
    grid-template-columns:
        repeat(7, minmax(0, 1fr));
    gap: 9px;
    margin-top: 20px;
}

.device-stat-card {
    padding: 13px 14px;
    border: 1px solid #dfe8e0;
    border-radius: 13px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.device-stat-label {
    color: #859088;
    font-size: 9px;
    font-weight: 760;
}

.device-stat-value {
    margin-top: 5px;
    color: #344139;
    font-size: 21px;
    font-weight: 830;
    font-variant-numeric: tabular-nums;
}

.device-stat-value.online {
    color: #2f8f4e;
}

.device-stat-value.delayed {
    color: #b47a1f;
}

.device-stat-value.offline {
    color: #a84444;
}

.device-stat-value.disabled {
    color: #8b8f8c;
}

.device-stat-value.muted-value {
    color: #6f7d74;
}

.devices-panel {
    margin-top: 14px;
}

.devices-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #edf1ed;
}

.devices-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.devices-search-wrap {
    position: relative;
    width: min(420px, 100%);
}

.devices-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #89958d;
    pointer-events: none;
}

.devices-search-wrap input {
    padding-left: 32px;
}

#deviceStatusFilter {
    width: 130px;
    flex: 0 0 130px;
}

.devices-summary {
    color: #78847c;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.device-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.device-card {
    display: grid;
    grid-template-columns:
        minmax(0, 1.5fr)
        minmax(150px, .65fr)
        minmax(150px, .65fr)
        auto;
    gap: 16px;
    align-items: center;
    padding: 15px 16px;
    border: 1px solid #dfe7e0;
    border-radius: 14px;
    background:
        linear-gradient(
            145deg,
            #fff,
            #fbfdfb
        );
    box-shadow:
        0 6px 18px
        rgba(27, 70, 40, .035);
}

.device-card.disabled-card {
    background: #fafafa;
    opacity: .78;
}

.device-main {
    min-width: 0;
}

.device-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.device-name {
    overflow: hidden;
    color: #314037;
    font-size: 14px;
    font-weight: 820;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-id-chip {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 6px;
    border: 1px solid #e0e6e1;
    border-radius: 6px;
    background: #f7f9f7;
    color: #7a867e;
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Consolas,
        monospace;
    font-size: 8px;
}

.device-location {
    margin-top: 5px;
    color: #748078;
    font-size: 10px;
}

.device-description {
    margin-top: 4px;
    overflow: hidden;
    color: #929b94;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-meta-block {
    min-width: 0;
}

.device-meta-label {
    color: #929c94;
    font-size: 8px;
    font-weight: 760;
}

.device-meta-value {
    margin-top: 4px;
    overflow: hidden;
    color: #435047;
    font-size: 10px;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 25px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
}

.device-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.device-status.online {
    background: #edf8ef;
    color: #2f7d4a;
}

.device-status.online::before {
    background: #50ad68;
}

.device-status.delayed {
    background: #fff7e8;
    color: #966821;
}

.device-status.delayed::before {
    background: #d79b37;
}

.device-status.offline {
    background: #fff1f1;
    color: #a84444;
}

.device-status.offline::before {
    background: #ce6868;
}

.device-status.never_online,
.device-status.unknown {
    background: #f3f5f3;
    color: #747f77;
}

.device-status.never_online::before,
.device-status.unknown::before {
    background: #9da69f;
}

.device-status.disabled {
    background: #f0f1f0;
    color: #777b78;
}

.device-status.disabled::before {
    background: #8d918e;
}

.device-card-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.device-card-actions button {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 9px;
}


.device-detail-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 5px 9px;
    border: 1px solid #c8decd;
    border-radius: 9px;
    background: #f3f9f4;
    color: #2f7443;
    text-decoration: none;
    font-size: 9px;
    font-weight: 760;
}

.device-detail-link:hover {
    border-color: #9fc5a8;
    background: #eaf5ec;
}

.devices-empty {
    padding: 50px 16px;
    color: #87928a;
    text-align: center;
    font-size: 11px;
}

.device-modal {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(10, 28, 17, .48);
    backdrop-filter: blur(4px);
    z-index: 300;
}

.device-modal.show {
    display: grid;
}

.device-dialog {
    width: min(720px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    padding: 21px;
    border: 1px solid #dce5dd;
    border-radius: 18px;
    background: #fff;
    box-shadow:
        0 30px 80px
        rgba(7, 28, 14, .24);
}

.sensor-dialog {
    width: min(900px, 100%);
}

.device-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 13px;
    border-bottom: 1px solid #edf1ed;
}

.device-dialog-head h2 {
    margin: 0;
}

.icon-button {
    width: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 9px;
    font-size: 20px;
    line-height: 1;
}

.device-form-grid,
.sensor-form-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 11px;
    margin-top: 15px;
}

.device-description-field,
.sensor-description-field {
    margin-top: 11px;
}

.device-description-field textarea,
.sensor-description-field textarea {
    min-height: 80px;
    resize: vertical;
}

.field-hint {
    margin-top: 4px;
    color: #9aa39c;
    font-size: 8px;
    line-height: 1.45;
}

.device-enabled-row {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 8px;
    align-items: center;
    margin-top: 13px;
    padding: 10px 11px;
    border: 1px solid #e2e8e3;
    border-radius: 10px;
    background: #fafcfa;
    cursor: pointer;
}

.device-enabled-row input {
    width: 15px;
    min-height: 15px;
    accent-color: var(--green-700);
}

.device-enabled-row span {
    color: #415047;
    font-size: 10px;
    font-weight: 780;
}

.device-enabled-row small {
    color: #8c968e;
    font-size: 8px;
}

.device-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.sensor-dialog-meta {
    margin-top: 4px;
    color: #89948c;
    font-size: 9px;
}

.sensor-dialog-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding: 10px 11px;
    border: 1px solid #e1e9e2;
    border-radius: 11px;
    background: #f8faf8;
}

.sensor-dialog-toolbar strong {
    color: #405047;
    font-size: 10px;
}

.sensor-dialog-toolbar span {
    margin-left: 7px;
    color: #8d978f;
    font-size: 8px;
}

.sensor-config-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.sensor-config-row {
    display: grid;
    grid-template-columns:
        80px minmax(0, 1.25fr)
        minmax(100px, .7fr)
        minmax(90px, .6fr)
        auto;
    gap: 10px;
    align-items: center;
    padding: 10px 11px;
    border: 1px solid #e0e8e1;
    border-radius: 11px;
    background: #fff;
}

.sensor-key-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 7px;
    border-radius: 7px;
    background: #edf6ef;
    color: var(--green-800);
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Consolas,
        monospace;
    font-size: 9px;
    font-weight: 780;
}

.sensor-config-name {
    overflow: hidden;
    color: #39473f;
    font-size: 10px;
    font-weight: 780;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sensor-config-sub {
    margin-top: 2px;
    overflow: hidden;
    color: #929c94;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sensor-config-actions {
    display: flex;
    gap: 5px;
}

.sensor-config-actions button {
    min-height: 29px;
    padding: 4px 7px;
    font-size: 8px;
}

.sensor-editor {
    display: none;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid #dfe7e0;
    border-radius: 12px;
    background: #f9fbf9;
}

.sensor-editor.show {
    display: block;
}

.sensor-editor-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #405047;
    font-size: 11px;
    font-weight: 800;
}

.text-button {
    min-height: 28px;
    padding: 3px 6px;
    border-color: transparent;
    background: transparent;
    color: #718078;
    box-shadow: none;
    font-size: 9px;
}

.text-button:hover {
    background: #f1f5f2;
    box-shadow: none;
}

.compact-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    cursor: pointer;
}

.compact-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.compact-toggle-track {
    position: relative;
    width: 36px;
    height: 21px;
    border-radius: 999px;
    background: #d8dfda;
}

.compact-toggle-track::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(30, 50, 36, .18);
    transition: transform .16s ease;
}

.compact-toggle input:checked + .compact-toggle-track {
    background: var(--green-600);
}

.compact-toggle input:checked + .compact-toggle-track::after {
    transform: translateX(15px);
}

.compact-toggle span:last-child {
    color: #647168;
    font-size: 9px;
    font-weight: 720;
}

.sensor-enabled-field {
    align-self: end;
}

.sensor-editor-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

@media (max-width: 1150px) {
    .device-stats {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .device-card {
        grid-template-columns:
            minmax(0, 1fr)
            minmax(140px, .7fr)
            auto;
    }

    .device-meta-block:nth-of-type(3) {
        display: none;
    }
}

@media (max-width: 800px) {
    .devices-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .devices-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .devices-toolbar-left {
        width: 100%;
    }

    .devices-summary {
        white-space: normal;
    }

    .device-card {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .device-card-actions {
        justify-content: flex-start;
    }

    .device-form-grid,
    .sensor-form-grid {
        grid-template-columns: 1fr;
    }

    .sensor-config-row {
        grid-template-columns:
            80px minmax(0, 1fr) auto;
    }

    .sensor-config-row > div:nth-child(3),
    .sensor-config-row > div:nth-child(4) {
        display: none;
    }
}

@media (max-width: 560px) {
    .device-stats {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .devices-toolbar-left {
        align-items: stretch;
        flex-direction: column;
    }

    .devices-search-wrap {
        width: 100%;
    }

    #deviceStatusFilter {
        width: 100%;
        flex-basis: auto;
    }

    .device-dialog {
        padding: 16px;
        border-radius: 14px;
    }

    .sensor-dialog-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .sensor-dialog-toolbar span {
        display: block;
        margin: 3px 0 0;
    }
}

/* M2.4 device operations overview */
.device-ops-overview {
    margin-top: 14px;
    padding: 15px 16px;
}

.device-ops-overview-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.device-ops-overview-head h2 {
    margin: 2px 0 0;
    font-size: 14px;
}

.device-ops-sub {
    margin-top: 5px;
    color: #89948c;
    font-size: 9px;
}

.device-ops-updated {
    color: #87928a;
    font-size: 9px;
    white-space: nowrap;
}

.device-ops-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 13px;
}

.device-ops-card {
    padding: 11px 12px;
    border: 1px solid #e1e9e2;
    border-radius: 11px;
    background: #fbfdfb;
}

.device-ops-card span {
    color: #87928a;
    font-size: 8px;
    font-weight: 740;
}

.device-ops-card strong {
    display: block;
    margin-top: 5px;
    color: #334139;
    font-size: 17px;
    font-variant-numeric: tabular-nums;
}

.device-ops-card.warning-card strong { color: #a97724; }
.device-ops-card.alert-card strong { color: #a84444; }

.device-metric-main {
    font-variant-numeric: tabular-nums;
}

.device-event-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.device-event-chip {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #f3f5f3;
    color: #758078;
    font-size: 8px;
    font-weight: 760;
    white-space: nowrap;
}

.device-event-chip.has-alert {
    background: #fff0f0;
    color: #a84444;
}

.device-event-chip.has-quality {
    background: #fff7e8;
    color: #966821;
}

/* M2.4 adds per-device data and event columns. */
.device-card {
    grid-template-columns:
        minmax(220px, 1.35fr)
        minmax(118px, .58fr)
        minmax(130px, .62fr)
        minmax(135px, .64fr)
        minmax(135px, .64fr)
        minmax(235px, auto);
    gap: 13px;
}

@media (max-width: 1500px) {
    .device-card {
        grid-template-columns:
            minmax(210px, 1.2fr)
            minmax(115px, .55fr)
            minmax(125px, .6fr)
            minmax(130px, .62fr)
            minmax(210px, auto);
    }

    .device-event-block {
        grid-column: 3 / 5;
    }

    .device-card-actions {
        grid-column: 5;
        grid-row: 1 / span 2;
    }
}

@media (max-width: 1120px) {
    .device-ops-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .device-main,
    .device-card-actions {
        grid-column: 1 / -1;
    }

    .device-event-block {
        grid-column: auto;
    }

    .device-card-actions {
        justify-content: flex-start;
        grid-row: auto;
    }
}

@media (max-width: 680px) {
    .device-ops-overview-head {
        flex-direction: column;
    }

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

@media (max-width: 520px) {
    .device-ops-grid,
    .device-card {
        grid-template-columns: 1fr;
    }

    .device-main,
    .device-card-actions {
        grid-column: auto;
    }
}

.device-ops-card.status-card strong { color: #a45a4f; }

.device-stat-value.pending { color: #6f7d74; }
.device-status.pending { color: #647269; background: #f2f5f2; }
.device-status.pending::before { background: #9ba69e; }


/* M2.8.2.11 · device page desktop composition */
@media (min-width: 1200px) {
    .devices-header {
        align-items: center;
    }

    .device-stats {
        grid-template-columns:
            repeat(4, minmax(0, 1fr));
        gap: 11px;
        margin-top: 23px;
    }

    .device-stat-card {
        min-height: 92px;
        padding: 15px 16px;
        border-radius: 14px;
    }

    .device-stat-label {
        font-size: 9.5px;
    }

    .device-stat-value {
        margin-top: 8px;
        font-size: 24px;
    }

    .device-ops-overview {
        margin-top: 18px;
        padding: 18px 19px;
    }

    .device-ops-grid {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
        gap: 10px;
        margin-top: 15px;
    }

    .device-ops-card {
        min-height: 78px;
        padding: 13px 14px;
        border-radius: 12px;
    }

    .device-ops-card span {
        font-size: 8.5px;
    }

    .device-ops-card strong {
        margin-top: 7px;
        font-size: 19px;
    }

    .devices-panel {
        margin-top: 18px;
        padding: 18px;
    }

    .devices-toolbar {
        padding-bottom: 16px;
    }

    .device-list {
        gap: 12px;
        margin-top: 16px;
    }

    /*
     * Device card: one clean primary row plus a secondary event row.
     * This avoids six tiny columns fighting for width.
     */
    .device-card {
        grid-template-columns:
            minmax(270px, 1.45fr)
            minmax(145px, .68fr)
            minmax(145px, .68fr)
            minmax(160px, .74fr)
            minmax(210px, auto);
        grid-template-rows: auto auto;
        column-gap: 18px;
        row-gap: 10px;
        padding: 18px;
        border-radius: 15px;
    }

    .device-main {
        grid-column: 1;
        grid-row: 1 / span 2;
        align-self: center;
    }

    .device-card > .device-meta-block:nth-of-type(1) {
        grid-column: 2;
        grid-row: 1;
    }

    .device-card > .device-meta-block:nth-of-type(2) {
        grid-column: 3;
        grid-row: 1;
    }

    .device-data-block {
        grid-column: 4;
        grid-row: 1;
    }

    .device-event-block {
        grid-column: 2 / 5;
        grid-row: 2;
        align-self: end;
    }

    .device-card-actions {
        grid-column: 5;
        grid-row: 1 / span 2;
        align-self: center;
        justify-content: flex-end;
    }

    .device-name {
        font-size: 15px;
    }

    .device-location {
        margin-top: 6px;
    }

    .device-meta-label {
        font-size: 8.5px;
    }

    .device-meta-value {
        margin-top: 5px;
        font-size: 10.5px;
    }
}


/* M2.8.2.13 · devices desktop density refinement */
@media (min-width: 1200px) {
    .device-stats {
        gap: 12px;
    }

    .device-stat-card,
    .device-ops-card {
        border-color: #e6ebe7;
        background: #fafcfb;
        box-shadow: none;
    }

    .device-card {
        border-color: #e4e9e5;
        background: #fff;
        box-shadow:
            0 2px 8px rgba(27, 60, 36, .018);
    }
}


/* M2.8.2.16 · device list product-state refinement */
.device-list > .app-state {
    margin-top: 2px;
}

@media (max-width: 720px) {
    .device-card-actions button,
    .device-detail-link {
        min-height: 44px;
    }
}
/* M3.1.0 · web-mainline device fleet refinement */
.devices-page .devices-header { align-items: center; }

.devices-page .devices-header-actions {
    align-items: center;
    flex-wrap: wrap;
}

.device-refresh-chip {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid #d8e5da;
    border-radius: 999px;
    background: #f4faf5;
    color: #397c4c;
    font-size: 11px;
    font-weight: 760;
    white-space: nowrap;
}

.devices-page .devices-header-actions button {
    min-height: 38px;
    padding-inline: 13px;
    font-size: 12px;
}

.devices-page .device-stats {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 9px;
    margin-top: 20px;
}

.devices-page .device-stat-card {
    appearance: none;
    width: 100%;
    min-height: 76px;
    padding: 12px 13px;
    border: 1px solid #e0e8e1;
    border-radius: 12px;
    background: #fff;
    box-shadow: none;
    text-align: left;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.devices-page .device-stat-card:hover,
.devices-page .device-stat-card.selected {
    transform: translateY(-1px);
    border-color: #bcd3c1;
    background: #f8fbf8;
}

.devices-page .device-stat-card.selected {
    box-shadow: inset 0 0 0 1px #c4dcc9;
}

.devices-page .device-stat-label { font-size: 10px; }

.devices-page .device-stat-value {
    margin-top: 6px;
    font-size: 23px;
}

.devices-page .device-ops-overview {
    margin-top: 15px;
    padding: 16px 17px;
}

.devices-page .device-ops-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.devices-page .device-ops-card {
    min-height: 72px;
    padding: 11px 12px;
    border-color: #e4eae5;
    background: #fafcfb;
    box-shadow: none;
}

.devices-page .device-ops-card span { font-size: 10px; }

.devices-page .device-ops-card strong {
    margin-top: 6px;
    font-size: 19px;
}

.devices-page .device-ops-sub,
.devices-page .device-ops-updated { font-size: 10px; }

.devices-page .devices-panel {
    margin-top: 15px;
    padding: 17px;
}

.devices-page .devices-toolbar {
    gap: 12px;
    padding-bottom: 13px;
}

.devices-page .devices-toolbar-left { flex-wrap: wrap; }

.devices-page .devices-search-wrap {
    width: min(430px, 100%);
    flex: 1 1 300px;
}

.devices-page #deviceStatusFilter,
.devices-page #deviceSortMode {
    width: 132px;
    flex: 0 0 132px;
}

.devices-page .devices-toolbar input,
.devices-page .devices-toolbar select {
    min-height: 38px;
    font-size: 12px;
}

.devices-page .devices-summary { font-size: 11px; }

.devices-page .device-list {
    gap: 10px;
    margin-top: 13px;
}

.devices-page .device-card {
    position: relative;
    grid-template-columns:
        minmax(260px, 1.45fr)
        minmax(130px, .62fr)
        minmax(135px, .64fr)
        minmax(145px, .68fr)
        minmax(190px, auto);
    grid-template-rows: auto auto;
    column-gap: 16px;
    row-gap: 9px;
    padding: 15px 16px 15px 18px;
    border-color: #e3e9e4;
    border-radius: 13px;
    background: #fff;
    box-shadow: none;
    overflow: hidden;
}

.devices-page .device-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: #b7c2ba;
}

.devices-page .device-card.status-online::before { background: #55a86b; }
.devices-page .device-card.status-delayed::before { background: #d49a3e; }
.devices-page .device-card.status-offline::before,
.devices-page .device-card.has-active-alert::before { background: #c95e59; }
.devices-page .device-card.status-pending::before,
.devices-page .device-card.status-never_online::before { background: #9ba69e; }

.devices-page .device-card.has-active-alert { border-color: #ead0ce; }

.devices-page .device-main {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
}

.devices-page .device-card > .device-meta-block:nth-of-type(1) {
    grid-column: 2;
    grid-row: 1;
}

.devices-page .device-card > .device-meta-block:nth-of-type(2) {
    grid-column: 3;
    grid-row: 1;
}

.devices-page .device-data-block {
    grid-column: 4;
    grid-row: 1;
}

.devices-page .device-event-block {
    grid-column: 2 / 5;
    grid-row: 2;
    align-self: end;
}

.devices-page .device-card-actions {
    grid-column: 5;
    grid-row: 1 / span 2;
    align-self: center;
    justify-content: flex-end;
}

.devices-page .device-name { font-size: 14px; }

.devices-page .device-name-link {
    color: #314037;
    text-decoration: none;
}

.devices-page .device-name-link:hover { color: #2f7443; }
.devices-page .device-location { font-size: 10.5px; }
.devices-page .device-description { font-size: 10px; }
.devices-page .device-meta-label { font-size: 9px; }
.devices-page .device-meta-value { font-size: 11px; }

.devices-page .device-config-sub {
    margin-top: 4px;
    color: #8a958d;
    font-size: 9px;
}

.devices-page .device-status {
    min-height: 26px;
    font-size: 10px;
}

.devices-page .device-event-chip {
    min-height: 23px;
    font-size: 9px;
}

.devices-page .device-event-chip.healthy {
    background: #edf8ef;
    color: #3f7f51;
}

.devices-page .device-card-actions button,
.devices-page .device-detail-link {
    min-height: 34px;
    padding: 5px 9px;
    font-size: 10px;
}

.devices-page .device-detail-link {
    border-color: #b9d4c0;
    background: #eff7f1;
    color: #2f7443;
}

@media (max-width: 1380px) {
    .devices-page .device-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .devices-page .device-ops-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .devices-page .device-card {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .devices-page .device-main,
    .devices-page .device-card-actions {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .devices-page .device-card > .device-meta-block:nth-of-type(1),
    .devices-page .device-card > .device-meta-block:nth-of-type(2),
    .devices-page .device-data-block,
    .devices-page .device-event-block {
        grid-column: auto;
        grid-row: auto;
    }

    .devices-page .device-card-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
    .devices-page .devices-header {
        align-items: stretch;
        flex-direction: column;
    }

    .devices-page .devices-header-actions > * {
        flex: 1 1 auto;
        justify-content: center;
    }

    .devices-page .device-stats,
    .devices-page .device-ops-grid,
    .devices-page .device-card {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .devices-page .devices-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .devices-page .devices-toolbar-left {
        align-items: stretch;
        flex-direction: column;
    }

    .devices-page .devices-search-wrap,
    .devices-page #deviceStatusFilter,
    .devices-page #deviceSortMode {
        width: 100%;
        flex: 1 1 auto;
    }

    .devices-page .device-main,
    .devices-page .device-card-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 520px) {
    .devices-page .device-stats,
    .devices-page .device-ops-grid,
    .devices-page .device-card {
        grid-template-columns: 1fr;
    }

    .devices-page .device-main,
    .devices-page .device-card-actions {
        grid-column: auto;
    }

    .devices-page .device-card-actions,
    .devices-page .device-card-actions > * {
        width: 100%;
    }
}
