.system-settings-page {
    min-height: 100vh;
    background: var(--waker-color-page);
}

.system-mobile-only {
    display: none;
}

.system-settings-shell {
    padding-bottom: var(--waker-space-8);
}

.system-settings-header,
.system-settings-title-row,
.system-card__header,
.system-actions,
.system-secret-status,
.system-provider-row,
.system-test-result {
    display: flex;
}

.system-settings-header,
.system-card__header {
    align-items: center;
}

.system-settings-title-row {
    align-items: center;
    gap: var(--waker-space-4);
}

.system-settings-title-icon,
.system-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: var(--waker-radius-md);
    background: var(--waker-color-primary-soft);
    color: var(--waker-color-primary);
}

.system-settings-title-icon {
    width: 48px;
    height: 48px;
}

.system-card__icon {
    width: 42px;
    height: 42px;
}

.system-settings-title-icon svg,
.system-card__icon svg,
.system-actions svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.system-settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: var(--waker-space-5);
}

.system-card--wide {
    grid-column: 1 / -1;
}

.system-provider-health {
    display: inline-flex;
    align-items: center;
    gap: var(--waker-space-2);
    margin-left: auto;
    color: var(--waker-color-ink-muted);
    font-size: var(--waker-font-size-sm);
    font-weight: 700;
}

.system-provider-health .status {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--waker-color-ink-muted);
}

.system-provider-health.is-enabled .status {
    background: var(--waker-status-success-text);
}

.system-provider-health.is-disabled .status {
    background: var(--waker-status-warning-text);
}

.system-unitalk-stats {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--waker-border-soft);
    border-radius: var(--waker-radius-md);
    background: var(--waker-color-surface-soft);
}

.system-unitalk-stats .stat {
    min-width: 0;
    padding: var(--waker-space-4);
}

.system-unitalk-stats .stat + .stat {
    border-left: 1px solid var(--waker-border-soft);
}

.system-unitalk-stats .stat-title,
.system-unitalk-stats .stat-desc {
    color: var(--waker-color-ink-muted);
    font-size: var(--waker-font-size-sm);
}

.system-unitalk-stats .stat-value {
    margin: var(--waker-space-1) 0;
    color: var(--waker-color-ink-strong);
    font-size: 28px;
    font-weight: 800;
}

.system-settings-fields .fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.system-settings-fields .fieldset-legend {
    padding: 0;
}

.system-settings-fields .fieldset .label {
    display: block;
    margin-top: var(--waker-space-1);
    color: var(--waker-color-ink-muted);
    font-size: var(--waker-font-size-sm);
    line-height: 1.45;
}

.system-unitalk-notice,
.system-unitalk-warning {
    display: flex;
    align-items: flex-start;
    gap: var(--waker-space-3);
    border: 1px solid var(--waker-border-soft);
    border-radius: var(--waker-radius-md);
    background: var(--waker-color-surface-soft);
    color: var(--waker-color-ink);
    padding: var(--waker-space-4);
}

.system-unitalk-notice > span svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.system-unitalk-notice div,
.system-unitalk-warning {
    flex-direction: column;
}

.system-unitalk-notice strong,
.system-unitalk-notice span,
.system-unitalk-warning strong,
.system-unitalk-warning span {
    display: block;
}

.system-unitalk-notice span,
.system-unitalk-warning span {
    margin-top: var(--waker-space-1);
    color: var(--waker-color-ink-muted);
}

.system-unitalk-warning {
    border-color: var(--waker-status-warning-border);
    background: var(--waker-status-warning-bg);
    color: var(--waker-status-warning-text);
}

.system-unitalk-test-timeline {
    display: grid;
    gap: var(--waker-space-2);
    border: 1px solid var(--waker-border-soft);
    border-radius: var(--waker-radius-md);
    padding: var(--waker-space-4);
}

.system-unitalk-test-event {
    display: flex;
    align-items: center;
    gap: var(--waker-space-2);
    color: var(--waker-color-ink-muted);
    font-size: var(--waker-font-size-sm);
}

.system-unitalk-test-event::before {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--waker-border-soft);
    content: '';
}

.system-unitalk-test-event.is-complete {
    color: var(--waker-status-success-text);
}

.system-unitalk-test-event.is-complete::before {
    background: var(--waker-status-success-text);
}

.system-card__header {
    gap: var(--waker-space-4);
}

.system-settings-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--waker-space-4);
}

.system-switch-field {
    align-content: start;
}

.system-wide,
.system-secret-status,
.system-test-result {
    grid-column: 1 / -1;
}

.system-secret-status {
    gap: var(--waker-space-3);
}

.system-secret-status > div {
    flex: 1 1 0;
    min-width: 0;
    border: 1px solid var(--waker-border-soft);
    border-radius: var(--waker-radius-md);
    background: var(--waker-color-surface-soft);
    padding: var(--waker-space-4);
}

.system-secret-status strong,
.system-secret-source {
    display: block;
}

.system-secret-status strong {
    margin-top: var(--waker-space-2);
    color: var(--waker-color-ink-strong);
    font-size: var(--waker-font-size-md);
}

.system-secret-source {
    margin-top: var(--waker-space-1);
    color: var(--waker-color-ink-muted);
    font-size: var(--waker-font-size-sm);
}

.system-actions {
    flex-wrap: wrap;
    gap: var(--waker-space-3);
}

.system-actions .wk-button {
    gap: var(--waker-space-2);
}

.system-test-result {
    flex-direction: column;
    gap: var(--waker-space-1);
    border: 1px solid var(--waker-status-success-border);
    border-radius: var(--waker-radius-md);
    background: var(--waker-status-success-bg);
    color: var(--waker-status-success-text);
    padding: var(--waker-space-4);
}

.system-test-result strong {
    color: inherit;
}

.system-provider-list {
    display: grid;
    gap: var(--waker-space-3);
}

.system-provider-row {
    align-items: center;
    justify-content: space-between;
    gap: var(--waker-space-3);
    border: 1px solid var(--waker-border-soft);
    border-radius: var(--waker-radius-md);
    background: var(--waker-color-surface-soft);
    padding: var(--waker-space-4);
}

@media (max-width: 1023px) {
    .system-mobile-only {
        display: block;
    }

    .system-settings-page {
        background: var(--waker-color-page-mobile);
    }

    .system-settings-shell {
        padding: var(--waker-space-4);
    }

    .system-settings-grid,
    .system-settings-fields {
        grid-template-columns: 1fr;
    }

    .system-secret-status {
        flex-direction: column;
    }

    .system-actions {
        flex-direction: column;
    }

    .system-actions .wk-button {
        width: 100%;
    }

    .system-card__header {
        align-items: flex-start;
    }

    .system-provider-health {
        margin-left: 0;
    }

    .system-unitalk-stats {
        grid-template-columns: 1fr;
    }

    .system-unitalk-stats .stat + .stat {
        border-top: 1px solid var(--waker-border-soft);
        border-left: 0;
    }
}

/* Compact System dashboard and shared ShiftAlert-style management dialogs. */
.system-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--waker-space-5);
}

.system-summary-card {
    display: flex;
    min-width: 0;
    min-height: 310px;
    flex-direction: column;
    overflow: hidden;
}

.system-summary-card__header {
    display: flex;
    align-items: flex-start;
    gap: var(--waker-space-4);
    padding: var(--waker-space-5);
}

.system-summary-card__header > div {
    min-width: 0;
}

.system-summary-card__header .wk-card__description {
    margin-top: var(--waker-space-1);
}

.system-summary-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex: 1 1 auto;
    margin: 0 var(--waker-space-5);
    overflow: hidden;
    border: 1px solid var(--waker-border-soft);
    border-radius: var(--waker-radius-md);
    background: var(--waker-color-surface-soft);
}

.system-summary-metric {
    min-width: 0;
    padding: var(--waker-space-4);
}

.system-summary-metric + .system-summary-metric {
    border-left: 1px solid var(--waker-border-soft);
}

.system-summary-metric span,
.system-summary-metric small,
.system-summary-metric strong {
    display: block;
}

.system-summary-metric span {
    color: var(--waker-color-ink-muted);
    font-size: var(--waker-font-size-sm);
    font-weight: 700;
}

.system-summary-metric strong {
    margin: var(--waker-space-2) 0 var(--waker-space-1);
    overflow: hidden;
    color: var(--waker-color-ink-strong);
    font-size: 23px;
    font-weight: 800;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.system-summary-metric small {
    color: var(--waker-color-ink-muted);
    font-size: 12px;
    line-height: 1.35;
}

.system-summary-card__footer {
    display: flex;
    justify-content: flex-end;
    padding: var(--waker-space-5);
}

.system-provider-health .system-health-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin: 0;
    border-radius: 999px;
    background: var(--waker-color-ink-muted);
}

.system-provider-health.is-enabled .system-health-dot {
    background: var(--waker-status-success-text);
}

.system-provider-health.is-disabled .system-health-dot {
    background: var(--waker-status-warning-text);
}

.system-settings-dialog {
    display: flex;
    width: min(1240px, calc(100vw - 32px));
    max-width: none;
    max-height: min(920px, calc(100vh - 32px));
    flex-direction: column;
    overflow: hidden;
}

.system-settings-modal-form {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
}

.system-settings-modal-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    min-height: 0;
    overflow-y: auto;
    padding-top: 8px;
}

.system-modal-wide {
    grid-column: 1 / -1;
}

.system-modal-help {
    display: block;
    margin-top: 7px;
    color: var(--waker-color-ink-muted);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0;
    text-transform: none;
}

.system-modal-switch-field > .wk-switch {
    display: inline-flex;
    width: 56px;
    height: 32px;
    margin: 0;
}

.system-modal-switch-field > .wk-switch .wk-switch__track {
    margin: 0;
}

.system-modal-help-inline {
    font-style: normal;
}

.system-modal-info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.system-modal-info-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.system-modal-info-grid--auth {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.system-modal-info-grid > div {
    min-width: 0;
    border: 1px solid var(--waker-border-soft);
    border-radius: 8px;
    background: var(--waker-color-surface-soft);
    padding: 14px;
}

.system-modal-info-grid span,
.system-modal-info-grid strong,
.system-modal-info-grid small {
    display: block;
}

.system-modal-info-grid span {
    color: var(--waker-color-ink-muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.system-modal-info-grid strong {
    margin-top: 8px;
    overflow: hidden;
    color: var(--waker-color-ink-strong);
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.system-modal-info-grid small {
    margin-top: 4px;
    color: var(--waker-color-ink-muted);
    font-size: 12px;
    line-height: 1.35;
}

.system-modal-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid var(--waker-border-soft);
    border-radius: 8px;
    background: var(--waker-color-surface-soft);
    color: var(--waker-color-ink);
    padding: 14px;
}

.system-modal-notice > span,
.system-modal-notice > span svg {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
}

.system-modal-notice svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.system-modal-notice strong,
.system-modal-notice small {
    display: block;
}

.system-modal-notice small {
    margin-top: 4px;
    color: var(--waker-color-ink-muted);
    font-size: 13px;
    line-height: 1.4;
}

.system-modal-notice--warning {
    border-color: var(--waker-status-warning-border);
    background: var(--waker-status-warning-bg);
    color: var(--waker-status-warning-text);
}

.system-settings-modal-actions {
    flex: 0 0 auto;
    flex-wrap: wrap;
    background: #ffffff;
}

.system-settings-modal-actions .sa-modal-button {
    min-width: 0;
}

@media (max-width: 1180px) {
    .system-modal-info-grid--auth {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1023px) {
    .system-summary-grid {
        grid-template-columns: 1fr;
    }

    .system-summary-card {
        min-height: 0;
    }

    .system-settings-dialog {
        width: min(100%, 760px);
        max-height: calc(100vh - 28px);
    }

    .system-settings-modal-body,
    .system-modal-info-grid,
    .system-modal-info-grid--two,
    .system-modal-info-grid--auth {
        grid-template-columns: 1fr;
    }

    .system-settings-modal-actions {
        max-height: 42vh;
        overflow-y: auto;
    }
}

@media (max-width: 600px) {
    .system-summary-card__header {
        flex-wrap: wrap;
    }

    .system-provider-health {
        width: 100%;
    }

    .system-summary-metrics {
        grid-template-columns: 1fr;
    }

    .system-summary-metric + .system-summary-metric {
        border-top: 1px solid var(--waker-border-soft);
        border-left: 0;
    }

    .system-summary-card__footer .wk-button {
        width: 100%;
    }
}
