

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}

.card:hover {
    border-color: var(--border-strong);
}

.card-header {
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 15px;
}

.card-body {
    padding: 22px;
}

.card-body-flush {
    padding: 0;
}


.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.3s var(--ease-out), transform 0.2s var(--ease-out);
}

.stat-card:hover {
    border-color: var(--accent-border);
    transform: translateY(-1px);
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-value-sm {
    font-size: 20px;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 6px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--error); }


.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 550;
    line-height: 1.6;
    white-space: nowrap;
}

.badge-default { background: var(--bg-badge); color: var(--text-secondary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-accent { background: var(--accent-subtle); color: var(--accent); }


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 550;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out), color 0.2s var(--ease-out), transform 0.15s var(--ease-out), box-shadow 0.2s var(--ease-out);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--text-on-accent);
    box-shadow: 0 4px 12px rgba(43,232,114,.25);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--border);
    border-color: var(--border-strong);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: rgba(255,255,255,.06);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--error);
    color: var(--text-on-accent);
    border-color: var(--error);
}

.btn-danger:hover {
    background: color-mix(in srgb, var(--error), #000 20%);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
    min-height: 32px;
}

.btn-xs {
    padding: 3px 8px;
    min-height: 28px;
    font-size: 12px;
}


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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 550;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.form-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
    outline: none;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ba1b4' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(43,232,114,.12);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-input-mono {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: -0.02em;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-error {
    font-size: 12px;
    color: var(--error);
    margin-top: 4px;
}


.file-drop {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.25s var(--ease-out), background 0.25s var(--ease-out), transform 0.2s var(--ease-out);
    background: var(--bg-input);
}

.file-drop:hover,
.file-drop.dragover {
    border-color: var(--accent);
    background: var(--accent-subtle);
    transform: scale(1.01);
}

.file-drop-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: var(--text-tertiary);
}

.file-drop-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.file-drop-text strong {
    color: var(--accent);
    font-weight: 600;
}

.file-drop-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}


.empty-state {
    padding: 48px 24px;
    text-align: center;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--text-tertiary);
    opacity: 0.5;
    animation: gentleFloat 4s ease-in-out infinite;
}

@keyframes gentleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.empty-state h3 {
    margin-bottom: 6px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}


.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: color 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-sans);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}


.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}

.alert svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(52,211,153,.15); }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid rgba(248,113,113,.15); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(251,191,36,.15); }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(96,165,250,.15); }


.key-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 12px 0;
}

.key-display code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-link);
    flex: 1;
    word-break: break-all;
}

.key-display .btn {
    flex-shrink: 0;
}


.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease-out);
    backdrop-filter: blur(2px);
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(12px) scale(0.98);
    opacity: 0;
    transition: transform 0.3s var(--ease-out-expo), opacity 0.25s var(--ease-out);
}

.modal-backdrop.active .modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-header {
    padding: 20px 24px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 17px;
}

.modal-body {
    padding: 0 24px 24px;
}

.modal-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border);
}


.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.healthy {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(26,154,92,.15);
    animation: statusPulse 3s ease-in-out infinite;
}
.status-dot.unhealthy {
    background: var(--error);
    box-shadow: 0 0 0 3px rgba(217,59,59,.15);
}
.status-dot.unknown {
    background: var(--text-tertiary);
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(26,154,92,.15); }
    50% { box-shadow: 0 0 0 5px rgba(26,154,92,.08); }
}


.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(26,154,92,.15);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    animation: slideInRight 0.4s var(--ease-out-expo) both;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.flash svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.flash span {
    flex: 1;
}

.flash-close {
    background: none;
    border: none;
    color: var(--success);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.6;
    line-height: 1;
}

.flash-close:hover {
    opacity: 1;
}


.copy-btn {
    padding: 4px 10px;
    font-size: 12px;
    font-family: var(--font-sans);
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    color: rgba(255,255,255,.7);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out), transform 0.1s var(--ease-out);
}

.copy-btn:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.copy-btn:active {
    transform: scale(0.95);
}


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

.section-header h2 {
    font-size: 18px;
}

@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 44px; }
    .btn-xs { min-height: 36px; padding: 6px 10px; }
    .copy-btn { min-height: 36px; padding: 6px 12px; }
}


.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s var(--ease-out);
}

.modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04);
    width: 100%;
    max-width: 440px;
    padding: 24px 24px 18px;
    transform: translateY(8px) scale(0.98);
    opacity: 0;
    transition: transform 0.22s var(--ease-out-expo), opacity 0.18s var(--ease-out);
}

.modal-overlay.is-open .modal-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    background: var(--accent-soft-bg);
    color: var(--accent);
}

.modal-icon svg { width: 22px; height: 22px; }

.modal-card-danger .modal-icon {
    background: rgba(220, 80, 80, 0.12);
    color: rgb(232, 110, 110);
}

.modal-card-warn .modal-icon {
    background: rgba(232, 175, 110, 0.14);
    color: rgb(232, 175, 110);
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.modal-message {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 20px;
}

.modal-message code {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 1px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

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

.modal-actions .btn {
    min-width: 90px;
}

/* Danger button used in destructive confirm dialogs. */
.btn-danger {
    background: rgb(220, 80, 80);
    color: #fff;
    border: 1px solid rgb(220, 80, 80);
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 550;
    cursor: pointer;
    transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out), box-shadow 0.18s var(--ease-out);
}

.btn-danger:hover {
    background: rgb(232, 96, 96);
    border-color: rgb(232, 96, 96);
    box-shadow: 0 4px 12px rgba(220, 80, 80, 0.28);
}

.btn-danger:active { transform: translateY(0); }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

@keyframes modalShake {
    0%, 100% { transform: translateY(0) scale(1); }
    25%      { transform: translateY(0) translateX(-3px) scale(1); }
    75%      { transform: translateY(0) translateX(3px)  scale(1); }
}

.modal-card.is-shaking { animation: modalShake 0.2s var(--ease-out) 1; }

@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-card { transition: none; }
}

@media (max-width: 480px) {
    .modal-card { padding: 20px 18px 14px; }
    .modal-title { font-size: 16px; }
}
