:root {
    --iw-accent: #2563eb;
    --iw-accent-hover: #1d4ed8;
    --iw-accent-soft: rgba(37, 99, 235, 0.14);
    --iw-page-bg: #f4faff;
    --iw-surface-card: #ffffff;
    --iw-surface: #f8fafc;
    --iw-surface-muted: #f1f5f9;
    --iw-text: #0f172a;
    --iw-text-body: #334155;
    --iw-text-secondary: #475569;
    --iw-text-muted: #64748b;
    --iw-border: #e2e8f0;
    --iw-danger: #dc2626;
    --iw-danger-soft: #fef2f2;
    --iw-danger-border: #fecaca;
    --iw-success: #16a34a;
    --iw-success-soft: #dcfce7;
    --iw-warning: #d97706;
    --iw-warning-soft: #fef3c7;
    --iw-warning-text: #92400e;
    --iw-radius: 12px;
    --iw-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Roboto, "Segoe UI", Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.16), transparent 28%),
        var(--iw-page-bg);
    color: var(--iw-text);
}

.layout {
    width: 100%;
    margin: auto;
    padding: 20px 16px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
    padding: 26px 28px;
    background: var(--iw-surface-card);
    border: 1px solid var(--iw-border);
    border-radius: 18px;
    box-shadow: var(--iw-shadow);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: linear-gradient(180deg, #007bff, #0056b3);
}

.brand {
    display: inline-block;
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 7px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: 0 8px 18px rgba(0, 86, 179, 0.25);
}

.header h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: -0.4px;
}

.header p,
#filterNote {
    color: var(--iw-text-muted);
    margin: 8px 0 0;
}

.system-status {
    display: inline-flex;
    align-items: center;
    background: var(--iw-success-soft);
    color: #166534;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
}

.pulse {
    width: 9px;
    height: 9px;
    background: var(--iw-success);
    display: inline-block;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.15);
}

.summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 22px;
}

.card {
    background: var(--iw-surface-card);
    padding: 22px;
    border-radius: var(--iw-radius);
    border: 1px solid var(--iw-border);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--iw-shadow);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: #bfdbfe;
}

.card.is-selected {
    border-color: var(--iw-accent);
    box-shadow: 0 0 0 3px var(--iw-accent-soft);
}

.success-card {
    background: linear-gradient(180deg, var(--iw-success-soft), #fff 42%);
}

.success-card.is-selected {
    border-color: var(--iw-success);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}

.warning-card {
    background: linear-gradient(180deg, var(--iw-warning-soft), #fff 42%);
}

.warning-card.is-selected {
    border-color: var(--iw-warning);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.16);
}

.danger-card {
    background: linear-gradient(180deg, var(--iw-danger-soft), #fff 42%);
}

.danger-card.is-selected {
    border-color: var(--iw-danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

.card-label {
    display: block;
    color: var(--iw-text-muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2px;
    margin-bottom: 10px;
}

.card strong {
    font-size: 34px;
    letter-spacing: -0.6px;
}

.success-card strong {
    color: var(--iw-success);
}

.warning-card strong {
    color: var(--iw-warning);
}

.danger-card strong {
    color: var(--iw-danger);
}

.panel {
    background: var(--iw-surface-card);
    border-radius: 18px;
    border: 1px solid var(--iw-border);
    overflow: visible;
    box-shadow: var(--iw-shadow);
}

.panel-header {
    padding: 22px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--iw-border);
    border-radius: 18px 18px 0 0;
    background: linear-gradient(180deg, #fff, var(--iw-surface));
}

.panel-header h2 {
    margin: 0;
    font-size: 18px;
}

.panel-header p {
    margin: 6px 0 0;
    color: var(--iw-text-muted);
    font-size: 13px;
}

.refresh {
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    border: 0;
    padding: 10px 17px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 8px 18px rgba(0, 86, 179, 0.22);
}

.refresh:hover {
    background: linear-gradient(45deg, #0069d9, #004494);
}

.filters {
    padding: 18px 25px;
    border-bottom: 1px solid var(--iw-border);
    background: #fff;
}

.filters input {
    width: 330px;
    max-width: 100%;
    border: 1px solid var(--iw-border);
    border-radius: 10px;
    padding: 11px 13px;
    outline: none;
    font-size: 14px;
    background: var(--iw-surface);
    color: var(--iw-text);
}

.filters input:focus {
    border-color: var(--iw-accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--iw-accent-soft);
}

.table-container {
    overflow: visible;
}

table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

th:nth-child(1) { width: 16%; }
th:nth-child(2),
th:nth-child(3),
th:nth-child(4) { width: 10%; }
th:nth-child(5) { width: 20%; }
th:nth-child(6) { width: 11%; }
th:nth-child(7) { width: 13%; }
th:nth-child(8) { width: 10%; }

th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--iw-surface);
    color: var(--iw-text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .3px;
    text-align: left;
    padding: 12px 8px;
    overflow-wrap: anywhere;
    box-shadow: inset 0 -1px 0 var(--iw-border);
}

td {
    padding: 12px 8px;
    border-top: 1px solid var(--iw-border);
    font-size: 13px;
    color: var(--iw-text-body);
    vertical-align: top;
    overflow-wrap: anywhere;
}

tbody tr:hover {
    background: #f8fbff;
}

.domain {
    font-weight: 700;
    color: var(--iw-text);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.success {
    color: #166534;
    background: var(--iw-success-soft);
}

.success .dot {
    background: var(--iw-success);
}

.warning {
    color: var(--iw-warning-text);
    background: var(--iw-warning-soft);
}

.warning .dot {
    background: var(--iw-warning);
}

.danger {
    color: #991b1b;
    background: var(--iw-danger-soft);
}

.danger .dot {
    background: var(--iw-danger);
}

.neutral {
    color: var(--iw-text-secondary);
    background: var(--iw-surface-muted);
}

.neutral .dot {
    background: #94a3b8;
}

.backup-detail {
    margin-top: 6px;
    margin-left: 4px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--iw-text-muted);
}

.load-cell {
    width: auto;
    min-width: 0;
}

.load-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.load-meta {
    min-width: 0;
}

.screen-open {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.screen {
    display: block;
    border: 1px solid var(--iw-border);
    border-radius: 10px;
    overflow: hidden;
    background: white;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.screen-open:hover .screen,
.screen-open:focus-visible .screen {
    border-color: var(--iw-accent);
}

.screen-bar,
.browser-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.screen-bar {
    height: 20px;
    padding: 0 6px;
    background: var(--iw-surface);
    border-bottom: 1px solid var(--iw-border);
}

.screen-dots {
    display: inline-flex;
    gap: 3px;
    flex: none;
}

.screen-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #93c5fd;
    display: block;
}

.screen-host {
    min-width: 0;
    overflow: hidden;
    color: var(--iw-text-muted);
    font-size: 8px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.screen-view {
    position: relative;
    display: block;
    height: auto;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #fff;
}

.screen-view img,
.browser-stage img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: top center;
    display: block;
    background: #fff;
}

.screen-view img {
    position: absolute;
    inset: 0;
}

.browser-stage img {
    height: 100%;
    object-fit: contain;
}

.screen-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--iw-accent);
    background: #eff6ff;
    font-size: 12px;
    font-weight: 700;
}

.screen-modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.55);
}

.screen-modal.open {
    display: flex;
}

.browser {
    display: flex;
    flex-direction: column;
    width: min(1100px, 100%);
    height: min(760px, 100%);
    overflow: hidden;
    background: white;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.browser-bar {
    padding: 12px 14px;
    background: var(--iw-surface);
    border-bottom: 1px solid var(--iw-border);
}

.browser-address {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--iw-border);
    border-radius: 10px;
    color: var(--iw-text);
    font-size: 13px;
}

.browser-address span:last-child {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.lock {
    flex: none;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--iw-surface-muted);
    color: var(--iw-text-secondary);
    font-size: 11px;
    font-weight: 700;
}

.lock.ok {
    background: var(--iw-success-soft);
    color: #166534;
}

.lock.warning {
    background: var(--iw-warning-soft);
    color: var(--iw-warning-text);
}

.lock.error {
    background: var(--iw-danger-soft);
    color: #991b1b;
}

.browser-close {
    flex: none;
    border: 0;
    background: transparent;
    color: var(--iw-accent-hover);
    font-weight: 700;
    cursor: pointer;
}

.browser-stage {
    position: relative;
    flex: 1;
    background: var(--iw-surface);
}

.browser-stage iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: white;
}

.browser-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    background: var(--iw-page-bg);
    text-align: center;
}

.browser-loading[hidden] {
    display: none;
}

.browser-loading p {
    max-width: 460px;
    margin: 0;
    color: var(--iw-text-muted);
    font-size: 13px;
}

.bar {
    width: 220px;
    height: 4px;
    overflow: hidden;
    background: #dbeafe;
    border-radius: 4px;
}

.bar span {
    display: block;
    width: 40%;
    height: 100%;
    background: linear-gradient(45deg, #007bff, #0056b3);
    animation: loading-bar 1s ease-in-out infinite;
}

@keyframes loading-bar {
    from {
        transform: translateX(-120%);
    }

    to {
        transform: translateX(320%);
    }
}

.screen-fallback {
    position: absolute;
    right: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 2;
    padding: 14px 16px;
    background: white;
    border: 1px solid var(--iw-border);
    border-radius: 12px;
    box-shadow: var(--iw-shadow);
    color: var(--iw-text);
    font-size: 14px;
    line-height: 1.45;
}

.screen-fallback-solo {
    inset: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.browser-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-top: 1px solid var(--iw-border);
    background: #fff;
}

.browser-foot div {
    color: var(--iw-text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

@media (max-width: 900px) {
    .summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .header {
        align-items: flex-start;
    }
}

@media (max-width: 600px) {
    .layout {
        padding: 16px;
    }

    .summary {
        grid-template-columns: 1fr;
    }

    .header,
    .browser-foot {
        flex-direction: column;
        align-items: stretch;
    }
}
