:root {
    --sidebar-width: 240px;
    --bg: #0e1016;
    --surface: #161922;
    --surface-2: #1c202b;
    --border: #272d3a;
    --text: #e6e8ec;
    --text-muted: #969fb0;
    --accent: #6366f1;
    --accent-hover: #7c83f6;
    --accent-soft: rgba(99, 102, 241, 0.16);
    --danger: #f87171;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- App shell + fixed sidebar ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: #0a0c11;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.875rem;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    padding: 0.25rem 0.5rem 0.75rem;
    color: #fff;
}

.sidebar-balance {
    display: block;
    margin: 0 0.5rem 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm, 8px);
    background: rgba(56, 189, 248, 0.12);
    color: #9aa4b4;
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid rgba(56, 189, 248, 0.25);
}
.sidebar-balance strong { color: #38bdf8; font-size: 0.95rem; }
.sidebar-balance:hover { background: rgba(56, 189, 248, 0.2); }

.lang-switcher {
    margin: 0 0.5rem 1rem;
    padding: 0.35rem 0.5rem;
    width: calc(100% - 1rem);
    background: var(--surface-2, #1a1f28);
    color: #cbd5e1;
    border: 1px solid var(--border-color, #2a303c);
    border-radius: var(--radius-sm, 8px);
    font-size: 0.85rem;
    cursor: pointer;
}
.auth-topbar { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
.auth-topbar .lang-switcher { width: auto; margin: 0; }
.auth-disclaimer {
    margin: -0.25rem 0 0.25rem;
    padding: 0.6rem 0.75rem;
    background: rgba(250, 204, 21, 0.1);
    border: 1px solid rgba(250, 204, 21, 0.3);
    border-radius: var(--radius-sm, 8px);
    color: #eab308;
    font-size: 0.82rem;
    line-height: 1.35;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-nav a {
    color: #9aa4b4;
    text-decoration: none;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }

.sidebar-foot {
    flex-shrink: 0;
    padding-top: 0.875rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
}
.sidebar-user {
    font-size: 0.78rem;
    color: #6f7788;
    padding: 0 0.5rem 0.6rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-logout button {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: transparent;
    color: #b8c0ce;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
}
.sidebar-logout button:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }

.content { flex: 1; min-width: 0; }
.content-inner { max-width: 1080px; margin: 0 auto; padding: 2rem 2.5rem 3rem; }

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 1.25rem; }
h2 { font-size: 1.1rem; font-weight: 650; margin: 2rem 0 0.75rem; }

/* ---------- Auth pages ---------- */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(1000px 500px at 50% -10%, #1b1f3a 0%, var(--bg) 55%);
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.25rem 2rem;
    box-shadow: var(--shadow);
}
.auth-brand { font-size: 1.3rem; font-weight: 700; text-align: center; letter-spacing: -0.02em; color: #fff; }
.auth-subtitle { text-align: center; color: var(--text-muted); margin: 0.35rem 0 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.4rem; }
.auth-form label span { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.auth-form input {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--surface-2);
    color: var(--text);
}
.auth-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-alt { text-align: center; margin: 1.25rem 0 0; font-size: 0.88rem; color: var(--text-muted); }
.auth-alt a { font-weight: 600; text-decoration: none; }

/* ---------- Buttons ---------- */

.btn-primary,
button.primary,
.content .primary {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}
.btn-primary:hover,
button.primary:hover,
.content .primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}
.btn-secondary:hover { border-color: var(--accent); color: #fff; }

/* ---------- Page intro + cards ---------- */

.page-desc { color: var(--text-muted); margin: -0.6rem 0 1.5rem; font-size: 0.92rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.lookup-card { padding: 1.25rem 1.4rem; margin-bottom: 1.5rem; max-width: 780px; }
.lookup-form { display: flex; flex-direction: column; gap: 0.9rem; }
.lookup-actions { display: flex; justify-content: flex-end; }

.results-title { font-size: 1.05rem; font-weight: 650; margin: 1.5rem 0 0.5rem; }
.table-card { overflow-x: auto; margin-top: 0.5rem; border-radius: var(--radius); }

.recheck-btn,
.view-all-values-btn,
.view-history-btn {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
}
.recheck-btn:hover,
.view-all-values-btn:hover,
.view-history-btn:hover { border-color: var(--accent); color: #fff; }

/* ---------- Cards / sections ---------- */

.settings-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    max-width: 640px;
    box-shadow: var(--shadow);
}
.settings-form,
.settings-form-inline { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.settings-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--text-muted); }
.settings-form input,
.settings-form textarea,
.settings-form select {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    background: var(--surface-2);
    color: var(--text);
}
.settings-form input:focus,
.settings-form textarea:focus,
.settings-form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.api-key-value { display: block; margin-top: 0.4rem; word-break: break-all; font-family: ui-monospace, monospace; }
.api-docs-link { text-decoration: none; font-weight: 600; }

.text-muted { color: var(--text-muted); }

/* ---------- Stats ---------- */

.stats-row { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0 0 2rem; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.4rem;
    flex: 1;
    min-width: 150px;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; color: #fff; }
.stat-label { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.25rem; }

/* ---------- News ---------- */

.news-list { display: flex; flex-direction: column; gap: 1rem; }
.news-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}
.news-card-date { color: var(--text-muted); font-size: 0.78rem; }
.news-card-title { margin: 0.3rem 0 0.4rem; font-size: 1.05rem; color: #fff; }
.news-card-summary { color: #c3cad6; margin: 0 0 0.6rem; }
.news-card-read { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.88rem; }
.news-article {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow);
}
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--accent); text-decoration: none; font-size: 0.88rem; font-weight: 500; }

/* ---------- Tables ---------- */

table.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
table.data-table th,
table.data-table td {
    text-align: left;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
table.data-table thead th {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
table.data-table tbody tr { transition: background 0.1s; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-2); }
table.data-table tbody td { vertical-align: middle; }
table.data-table tbody td:first-child { font-weight: 500; }
table.data-table td[data-copy] { cursor: pointer; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85rem; }
table.data-table td[data-copy]:hover { color: var(--accent); }

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #2a303c;
    color: #b8c0ce;
}
.badge-success { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.badge-fail { background: rgba(248, 113, 113, 0.18); color: #f87171; }
.badge-recheck { background: rgba(250, 204, 21, 0.18); color: #facc15; }
.badge-na { background: #2a303c; color: #9aa4b4; }
.badge-frozen { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }

/* ---------- Alerts ---------- */

.alert { padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); font-size: 0.88rem; }
.alert-error { background: rgba(248, 113, 113, 0.12); color: #fca5a5; border: 1px solid rgba(248, 113, 113, 0.3); }
.alert-success { background: rgba(34, 197, 94, 0.12); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.3); margin-bottom: 1rem; }

/* ---------- Pagination ---------- */

.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; font-size: 0.88rem; }
.pagination a { color: var(--accent); text-decoration: none; font-weight: 500; }
.pagination .disabled { color: #5b6376; }
.pagination-status { color: var(--text-muted); }

/* ---------- Lookup input ---------- */

textarea.lookup-input {
    width: 100%;
    min-height: 130px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.9rem;
    resize: vertical;
    background: var(--surface-2);
    color: var(--text);
}
textarea.lookup-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Amount presets (payment) ---------- */

.amount-presets { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.amount-preset-btn {
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}
.amount-preset-btn.selected { border-color: var(--accent); color: #fff; background: var(--accent-soft); font-weight: 600; }

/* ---------- Modal ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.modal-close { float: right; cursor: pointer; border: none; background: none; font-size: 1.25rem; color: var(--text-muted); line-height: 1; }
.modal-box pre {
    background: var(--surface-2);
    padding: 0.85rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.8rem;
    color: #c3cad6;
}

/* Reverse-lookup results bar (summary + filter/clear controls). */
.lookup-results-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.lookup-results-bar .page-desc { margin: 0; }
.lookup-results-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.lookup-results-controls select {
    margin-left: 0.4rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.5rem;
}
.lookup-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: inherit;
    color: var(--accent);
    text-decoration: underline;
}
.lookup-toggle:hover { color: var(--accent-hover); }
.lookup-owner-summary { color: var(--text-muted); margin: 0 0 0.75rem; }
.lookup-owner {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}
.lookup-owner:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.lookup-owner h4 { margin: 0 0 0.5rem; font-size: 0.95rem; }

/* ---------- Plans / subscriptions ---------- */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.plan-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.plan-card.plan-combo { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.plan-card h3 { margin: 0; font-size: 1.05rem; }
.plan-caps { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.plan-cap { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); padding: 0.15rem 0.45rem; border-radius: 999px; }
.plan-cap.auto { color: #4ade80; border-color: rgba(34,197,94,0.35); }
.plan-options { display: flex; flex-direction: column; gap: 0.5rem; margin-top: auto; }
.plan-option { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.5rem 0.65rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.plan-option .po-label { color: var(--text-muted); font-size: 0.85rem; }
.plan-option .po-price { font-weight: 600; margin-left: auto; }
.plan-buy { padding: 0.35rem 0.75rem; font-size: 0.82rem; border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.plan-buy:hover { background: var(--accent-hover); }
.plan-buy:disabled { opacity: 0.6; cursor: default; }
.subs-active { margin: 1rem 0; }

/* ---------- Streaming lookup progress ---------- */
.lookup-loading { font-size: 0.8rem; animation: lookupPulse 1.1s ease-in-out infinite; }
@keyframes lookupPulse { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }
