:root {
    --background: #07111f;
    --panel: #101d31;
    --panel-secondary: #172a46;
    --border: #2a4163;
    --text: #f4f7ff;
    --muted: #91a9cb;
    --green: #30d6a4;
    --blue: #559dff;
    --yellow: #f6c453;
    --red: #ff687d;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background:
        radial-gradient(
            circle at top right,
            rgba(85, 157, 255, 0.14),
            transparent 32%
        ),
        var(--background);
}

button,
input {
    font: inherit;
}

button {
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    background: var(--panel-secondary);
    font-weight: 750;
    cursor: pointer;
}

button:hover:not(:disabled) {
    border-color: var(--blue);
}

button.primary {
    border-color: transparent;
    background: linear-gradient(135deg, #327fdc, var(--blue));
}

button:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.app {
    width: min(1450px, calc(100% - 36px));
    margin: 0 auto;
    padding: 28px 0 50px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 17px;
    font-size: 27px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--blue), var(--green));
    box-shadow: var(--shadow);
}

.brand h1 {
    margin: 0;
    font-size: clamp(25px, 3vw, 37px);
    letter-spacing: -0.5px;
}

.brand p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.header-status {
    color: var(--muted);
    text-align: right;
    font-size: 13px;
}

.header-status strong {
    display: block;
    margin-top: 5px;
    color: var(--text);
}

.error-box {
    display: none;
    margin-bottom: 18px;
    padding: 15px 17px;
    border: 1px solid rgba(255, 104, 125, 0.5);
    border-radius: 14px;
    color: #ffd5dc;
    background: rgba(255, 104, 125, 0.1);
}

.status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 20px;

    background:
        linear-gradient(
            135deg,
            rgba(48, 214, 164, 0.09),
            rgba(85, 157, 255, 0.05)
        ),
        var(--panel);

    box-shadow: var(--shadow);
}

.status-main {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-main h2 {
    margin: 0;
    font-size: 21px;
}

.status-main p {
    margin: 5px 0 0;
    color: var(--muted);
}

.status-dot {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--yellow);
    box-shadow: 0 0 18px rgba(246, 196, 83, 0.7);
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 18px rgba(48, 214, 164, 0.8);
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
}

.card {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(16, 29, 49, 0.97);
    box-shadow: var(--shadow);
}

.metric-card {
    grid-column: span 3;
    min-height: 150px;
}

.sources-card,
.pending-card {
    grid-column: span 6;
}

.recovery-card {
    grid-column: span 12;
}

.label {
    display: block;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.metric-card > strong {
    display: block;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.05;
}

.metric-card small {
    display: block;
    margin-top: 12px;
    color: var(--muted);
}

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

.section-header h2,
.recovery-card h2 {
    margin: 0 0 18px;
    font-size: 23px;
}

.counter {
    min-width: 42px;
    padding: 8px 12px;
    border-radius: 20px;
    text-align: center;
    background: var(--panel-secondary);
    font-weight: 800;
}

.counter.warning {
    color: var(--yellow);
}

.sources-list,
.pending-list {
    display: grid;
    gap: 12px;
}

.source-item,
.pending-item {
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel-secondary);
}

.empty-message {
    color: var(--muted);
}

.recovery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.recovery-point {
    min-height: 145px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel-secondary);
}

.recovery-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.recovery-header strong {
    font-size: 17px;
}

.recovery-point p {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.7;
    font-size: 13px;
}

.badge {
    padding: 5px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    background: rgba(120, 140, 170, 0.22);
}

.badge.complete {
    color: #c9ffef;
    background: rgba(48, 214, 164, 0.17);
}

.badge.failed,
.badge.incomplete {
    color: #ffd1d8;
    background: rgba(255, 104, 125, 0.17);
}

.badge.creating,
.badge.verifying {
    color: #dceaff;
    background: rgba(85, 157, 255, 0.18);
}

@media (max-width: 1000px) {
    .metric-card,
    .sources-card,
    .pending-card {
        grid-column: span 6;
    }

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

@media (max-width: 680px) {
    .app {
        width: min(100% - 20px, 1450px);
        padding-top: 18px;
    }

    .header,
    .status-banner {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-status {
        text-align: left;
    }

    .metric-card,
    .sources-card,
    .pending-card {
        grid-column: span 12;
    }

    .recovery-grid {
        grid-template-columns: 1fr;
    }
}

.source-item,
.pending-item {
    position: relative;
}

.source-item strong,
.pending-item strong {
    font-size: 16px;
}

.source-item p,
.pending-item p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.65;
    font-size: 13px;
}

.source-item b,
.pending-item b {
    color: var(--text);
}

.source-item .badge {
    display: inline-block;
    margin-top: 13px;
}

.badge.pending {
    color: #ffe9a8;
    background: rgba(246, 196, 83, 0.16);
}

.pending-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.credential-button {
    flex: 0 0 auto;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(5px);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(520px, 100%);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--panel);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 25px;
}

.form-group {
    margin-bottom: 17px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    background: var(--background);
    outline: none;
}

.form-group input:focus {
    border-color: var(--blue);
}

.form-group input[readonly] {
    opacity: 0.75;
}

.password-field {
    display: flex;
    gap: 8px;
}

.password-field input {
    flex: 1;
}

.password-toggle {
    flex: 0 0 auto;
}

.form-error {
    display: none;
    margin-bottom: 15px;
    padding: 11px;
    border-radius: 10px;
    color: #ffd5dc;
    background: rgba(255, 104, 125, 0.12);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}