*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0F0F17;
    --surface:     #1A1A2E;
    --surface2:    #22223A;
    --border:      #2D2D4A;
    --accent:      #4A90D9;
    --accent-dim:  #2E5F96;
    --text:        #E8E8F0;
    --text-muted:  #7A7A9A;
    --danger:      #E05C5C;
    --danger-dim:  #8B2020;
    --radius:      12px;
    --radius-sm:   8px;
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; font-size: 15px; line-height: 1.5; }

/* ─── Login ─────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo { margin-bottom: 16px; }
.login-card h1 { font-size: 20px; font-weight: 600; color: var(--text); }
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

/* ─── Forms ─────────────────────────────────── */
.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    transition: border-color .15s;
    resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input:disabled { opacity: .5; cursor: not-allowed; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

/* ─── Buttons ────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background .15s, opacity .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #5a9fe0; }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: #4a4a6a; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ec7070; }
.btn-icon     { background: transparent; color: var(--text-muted); padding: 6px; border-radius: 6px; }
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-full { width: 100%; justify-content: center; padding: 11px; }

/* ─── Alerts ─────────────────────────────────── */
.alert { border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; text-align: left; }
.alert-error { background: rgba(224,92,92,.12); border: 1px solid rgba(224,92,92,.35); color: #f08080; }

/* ─── Header ─────────────────────────────────── */
.app-header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    background: rgba(15,15,23,.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.header-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.user-badge { font-size: 12px; color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border); border-radius: 100px; padding: 4px 10px; }

/* ─── Cards ──────────────────────────────────── */
.dashboard-page { min-height: 100vh; }

.cards-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 28px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
}

.otp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    transition: border-color .2s;
}
.otp-card:hover { border-color: #3a3a5a; }

.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
.card-label { font-size: 13px; font-weight: 500; color: var(--text-muted); line-height: 1.4; word-break: break-word; flex: 1; }

.card-actions { display: flex; gap: 2px; flex-shrink: 0; }

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

.otp-code {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: .12em;
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--text);
    cursor: pointer;
    flex: 1;
    transition: color .2s;
}
.otp-code:hover { color: var(--accent); }
.otp-code.copied { color: #5cb85c; }

/* Countdown ring */
.countdown-ring { flex-shrink: 0; position: relative; width: 52px; height: 52px; cursor: default; }
.countdown-ring svg { transform: rotate(-90deg); }
.ring-bg { stroke: var(--surface2); }
.ring-fill { stroke-linecap: round; transition: stroke-dashoffset .9s linear, stroke .4s; }
.countdown-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

/* ─── Loading / Empty ─────────────────────────── */
.loading-state, .empty-state {
    grid-column: 1/-1;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 12px;
    min-height: 240px; color: var(--text-muted); font-size: 14px;
}
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Modals ─────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn .15s;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    animation: slideUp .15s;
}
.modal-sm { max-width: 360px; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--surface2); }

.modal-body-text { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; line-height: 1.6; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ─── Tabs ───────────────────────────────────── */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; gap: 2px; }
.tab { background: none; border: none; color: var(--text-muted); font-size: 14px; padding: 8px 16px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Copied toast ───────────────────────────── */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); font-size: 13px;
    padding: 10px 20px; border-radius: 100px;
    z-index: 999;
    animation: toastIn .2s, toastOut .2s 1.5s forwards;
}
@keyframes toastIn  { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* ─── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
