/* ==========================================================================
   USDT Wallet Tracker — stylesheet
   Design: near-black BNB-chain-inspired dark theme, gold accent, glass
   panels, mono type for addresses/hashes/numbers (data should look like
   data), Space Grotesk for headings. Light theme is a first-class
   alternate palette, not an afterthought.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600&display=swap');

:root {
    --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --gold: #F0B90B;
    --gold-soft: #F3C93A;
    --green: #2ECC8F;
    --red: #FF5C67;
    --blue: #4C8DFF;
    --orange: #FFA53E;

    --transition: 180ms cubic-bezier(.2,.8,.2,1);
}

[data-theme="dark"] {
    --bg-0: #05060a;
    --bg-1: #0b0e16;
    --bg-2: #11141f;
    --surface: rgba(255,255,255,0.045);
    --surface-strong: rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.09);
    --text-0: #f4f5f7;
    --text-1: #b9bdc9;
    --text-2: #7c8194;
    --shadow: 0 8px 30px rgba(0,0,0,0.45);
}

[data-theme="light"] {
    --bg-0: #f3f2ee;
    --bg-1: #fbfaf7;
    --bg-2: #ffffff;
    --surface: rgba(255,255,255,0.65);
    --surface-strong: rgba(255,255,255,0.9);
    --border: rgba(20,20,30,0.09);
    --text-0: #16181f;
    --text-1: #454955;
    --text-2: #7a7e89;
    --shadow: 0 8px 24px rgba(20,20,40,0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background:
        radial-gradient(circle at 15% -10%, rgba(240,185,11,0.10), transparent 40%),
        radial-gradient(circle at 90% 10%, rgba(76,141,255,0.08), transparent 35%),
        var(--bg-0);
    color: var(--text-0);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--font-mono); }

::selection { background: var(--gold); color: #10120a; }

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------------------------------------------------------------- shell */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    margin-bottom: 34px;
    padding: 0 6px;
}
.brand-icon { color: var(--gold); font-size: 1.1rem; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-weight: 500;
    font-size: 0.92rem;
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--surface); color: var(--text-0); }
.nav-link.active { background: var(--surface-strong); color: var(--gold); }
.nav-icon { width: 18px; text-align: center; opacity: 0.85; }

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-0);
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition), transform var(--transition);
}
.theme-toggle:hover { background: var(--surface-strong); transform: rotate(-12deg); }
[data-theme="dark"] .theme-icon-light,
[data-theme="light"] .theme-icon-dark { display: none; }

.wallet-chip {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-2);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 999px;
}

.main-content {
    padding: 28px 32px 60px;
    max-width: 1400px;
    width: 100%;
}

/* ---------------------------------------------------------------- header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header h1 {
    font-family: var(--font-display);
    font-size: 1.7rem;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}
.subtitle { color: var(--text-2); margin: 0; font-size: 0.9rem; }
.subtitle code { color: var(--text-1); }

.header-actions { display: flex; align-items: center; gap: 12px; }

.sync-pill {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 0.82rem; font-weight: 500;
    padding: 8px 14px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-1);
}
.sync-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); }
.sync-pill[data-status="ok"] .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.sync-pill[data-status="error"] .dot { background: var(--red); box-shadow: 0 0 8px var(--red); }
.sync-pill[data-status="cooldown"] .dot { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.sync-pill[data-status="pending"] .dot { background: var(--blue); }

.btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.87rem;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-0);
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}
.btn:hover { transform: translateY(-1px); background: var(--surface-strong); }
.btn:active { transform: translateY(0); }
.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-soft));
    color: #171200;
    border: none;
    box-shadow: 0 6px 20px rgba(240,185,11,0.25);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(240,185,11,0.35); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------- glass */
.glass {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.card {
    padding: 18px 18px 16px;
    transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { transform: translateY(-2px); }
.card-label { font-size: 0.74rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.card-value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.card-value.small { font-size: 1.05rem; }
.card-sub { font-size: 0.72rem; color: var(--text-2); margin-top: 6px; }
.card.positive .card-value { color: var(--green); }
.card.negative .card-value { color: var(--red); }

.stats-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 24px;
}
.mini-stat {
    background: var(--bg-1);
    padding: 14px 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.mini-stat span { font-size: 0.7rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.mini-stat strong { font-family: var(--font-mono); font-size: 0.95rem; font-weight: 600; }

/* ---------------------------------------------------------------- charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.chart-card { padding: 18px 20px 8px; }
.chart-card h3 { font-family: var(--font-display); font-size: 0.98rem; margin: 0 0 12px; font-weight: 600; }

/* ---------------------------------------------------------------- table */
.table-card { padding: 20px 20px 8px; margin-bottom: 30px; }
.table-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.table-toolbar h3 { font-family: var(--font-display); margin: 0; font-size: 1.05rem; }
.toolbar-controls { display: flex; gap: 10px; }

input[type="search"], input[type="text"], input[type="url"], input[type="number"], select {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-0);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.86rem;
    transition: border-color var(--transition);
}
input:focus, select:focus { border-color: var(--gold); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
thead th:hover { color: var(--text-0); }
thead th.sorted-asc::after { content: ' ↑'; color: var(--gold); }
thead th.sorted-desc::after { content: ' ↓'; color: var(--gold); }
tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    color: var(--text-1);
}
tbody tr:hover { background: var(--surface); }
tbody tr.row-new { animation: highlight-new 2.4s ease-out; }
@keyframes highlight-new {
    0% { background: rgba(240,185,11,0.28); }
    100% { background: transparent; }
}
.empty-row { text-align: center; color: var(--text-2); padding: 30px !important; white-space: normal; }

.copyable { cursor: pointer; position: relative; }
.copyable:hover { color: var(--gold); }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-in { background: rgba(46,204,143,0.15); color: var(--green); }
.badge-out { background: rgba(255,92,103,0.15); color: var(--red); }
.badge-status-confirmed { background: rgba(76,141,255,0.15); color: var(--blue); }
.badge-status-pending { background: rgba(255,165,62,0.15); color: var(--orange); }
.badge-status-failed { background: rgba(255,92,103,0.15); color: var(--red); }

.explorer-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--surface); border: 1px solid var(--border);
    transition: background var(--transition), transform var(--transition);
}
.explorer-link:hover { background: var(--surface-strong); transform: scale(1.08); }

.table-pagination {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 16px 0;
}
.page-btn {
    min-width: 32px; height: 32px; padding: 0 8px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text-1);
    cursor: pointer; font-family: var(--font-mono); font-size: 0.8rem;
    transition: background var(--transition), color var(--transition);
}
.page-btn:hover { background: var(--surface-strong); color: var(--text-0); }
.page-btn.active { background: var(--gold); color: #171200; border-color: transparent; font-weight: 700; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------------------------------------------------------------- settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.settings-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.settings-card h3 { font-family: var(--font-display); margin: 0 0 4px; font-size: 1rem; }
.settings-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; color: var(--text-1); font-weight: 500; }
.settings-card label small { color: var(--text-2); font-weight: 400; font-size: 0.74rem; }
.settings-card label small a { color: var(--gold); }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 10px !important; }
.checkbox-label input { width: 16px; height: 16px; accent-color: var(--gold); }
.settings-actions {
    grid-column: 1 / -1;
    display: flex; align-items: center; gap: 14px;
    padding-top: 4px;
}
.save-status { font-size: 0.85rem; color: var(--text-2); }
.save-status.ok { color: var(--green); }
.save-status.err { color: var(--red); }

/* ---------------------------------------------------------------- toasts */
.toast-container {
    position: fixed; bottom: 22px; right: 22px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 999;
    max-width: 340px;
}
.toast {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--green);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    font-size: 0.85rem;
    animation: toast-in 220ms ease-out;
}
.toast.toast-out { border-left-color: var(--red); }
.toast.toast-err { border-left-color: var(--red); }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.toast strong { display: block; margin-bottom: 2px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static; height: auto; flex-direction: row;
        align-items: center; padding: 14px 16px;
    }
    .nav { flex-direction: row; flex: 1; justify-content: center; }
    .sidebar-footer { border-top: none; padding-top: 0; }
    .main-content { padding: 20px 16px 50px; }
    .charts-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .brand-text { display: none; }
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: stretch; }
    .header-actions { justify-content: space-between; }
}
