:root {
    --bg: #0b1020;
    --bg-soft: #111827;
    --panel: rgba(17, 24, 39, 0.82);
    --panel-solid: #111827;
    --panel-border: rgba(148, 163, 184, 0.18);
    --text: #e5eefc;
    --muted: #94a3b8;
    --primary: #60a5fa;
    --primary-strong: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #22d3ee;
    --danger: #f87171;
    --success: #4ade80;
    --warning: #fbbf24;
    --shadow: 0 18px 50px rgba(2, 6, 23, 0.35);
    --radius: 16px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(34, 211, 238, 0.12), transparent 24%),
        linear-gradient(180deg, #0b1020 0%, #0f172a 100%);
    color: var(--text);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: rgba(15, 23, 42, 0.92);
    border-right: 1px solid var(--panel-border);
    padding: 28px 20px;
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-strong), var(--accent));
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}

.brand {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-sub {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    display: block;
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav a.active,
.nav a:hover {
    background: rgba(59, 130, 246, 0.14);
    color: #fff;
    transform: translateX(2px);
}

.nav-logout {
    margin-top: 8px;
    color: #fca5a5 !important;
}

.sidebar-user {
    margin-top: auto;
    padding: 14px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--panel-border);
}

.sidebar-user-label {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-user-name {
    margin: 0;
    font-weight: 700;
    word-break: break-word;
}

.mobile-topbar,
.sidebar-toggle,
.sidebar-overlay {
    display: none;
}

.content {
    padding: 32px;
    width: 100%;
    min-width: 0;
}

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

.page-header-main h1,
.topbar h1 {
    margin: 0 0 8px;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    letter-spacing: -0.03em;
}

.page-eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.page-header-badge,
.stat-card .stat-meta,
.filter-chip,
.amount-badge,
.row-id {
    font-size: 0.82rem;
}

.page-header-badge {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(34, 211, 238, 0.12);
    border: 1px solid rgba(34, 211, 238, 0.28);
    color: #a5f3fc;
    font-weight: 700;
    white-space: nowrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.stat-card-primary {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.22), rgba(34, 211, 238, 0.12));
    border-color: rgba(96, 165, 250, 0.28);
}

.stat-label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.stat-value {
    margin: 0;
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.stat-meta {
    margin: 8px 0 0;
    color: var(--muted);
}

.card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    width: 100%;
}

.card-wide {
    max-width: none;
}

.card-elevated {
    margin-bottom: 20px;
}

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

.section-head h2,
.card h1,
.card h2 {
    margin: 0 0 6px;
    font-size: 1.2rem;
}

.table-card {
    padding-bottom: 18px;
}

.empty-table-cell {
    text-align: center;
    color: var(--muted);
    padding: 28px 12px !important;
}

.table-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 18px;
}

.pagination-info {
    color: var(--muted);
    font-weight: 600;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    background: rgba(15, 23, 42, 0.55);
}

.assigned-table,
table.dataTable {
    width: 100% !important;
    border-collapse: collapse;
}

.dataTables_wrapper {
    width: 100%;
    color: var(--text);
}

.dataTables_wrapper .dataTables_scroll,
.dataTables_wrapper .dataTables_scrollHead,
.dataTables_wrapper .dataTables_scrollBody,
.dataTables_wrapper .dataTables_scrollHeadInner,
.dataTables_wrapper .dataTables_scrollHeadInner table {
    width: 100% !important;
}

.modern-table thead th,
.assigned-table thead th {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--panel-border);
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: rgba(15, 23, 42, 0.92);
}

.modern-table tbody td,
.assigned-table tbody td,
table.dataTable tbody td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    vertical-align: middle;
    color: var(--text) !important;
    background-color: transparent !important;
}

table.dataTable tbody tr,
table.dataTable.display tbody tr {
    background-color: transparent !important;
}

table.dataTable.stripe tbody tr.odd,
table.dataTable.stripe tbody tr.even,
table.dataTable.display tbody tr.odd,
table.dataTable.display tbody tr.even {
    background-color: transparent !important;
}

table.dataTable.hover tbody tr:hover,
table.dataTable.display tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.06) !important;
}

table.dataTable thead th,
table.dataTable thead td {
    color: #cbd5e1 !important;
    background-color: rgba(15, 23, 42, 0.92) !important;
    border-bottom: 1px solid var(--panel-border) !important;
}

table.dataTable.no-footer {
    border-bottom: 0;
}

.modern-table tbody tr,
.assigned-table tbody tr {
    display: table-row;
    visibility: visible;
}

.modern-table tbody tr:hover,
.assigned-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.06);
}

.address-cell,
.hash-cell,
.date-cell,
.row-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.address-cell {
    font-size: 0.86rem;
    word-break: break-all;
}

.hash-cell {
    font-size: 0.84rem;
    white-space: nowrap;
}

.row-id {
    color: var(--muted);
}

.table-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.table-link:hover {
    color: #bfdbfe;
    text-decoration: underline;
}

.external-link::after {
    content: "↗";
    margin-left: 6px;
    font-size: 0.75rem;
    opacity: 0.8;
}

.amount-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.24);
    color: #bbf7d0;
    font-weight: 700;
}

.filter-form {
    margin-bottom: 0;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px 16px;
    margin-bottom: 16px;
}

.field label,
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #cbd5e1;
    font-size: 0.88rem;
}

.filter-grid input,
input[type="text"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--panel-border);
    background: rgba(15, 23, 42, 0.72);
    color: var(--text);
    margin-bottom: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"],
input[type="password"],
select {
    margin-bottom: 16px;
}

.filter-grid input:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
select:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.65);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-strong), var(--primary-hover));
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.btn-secondary {
    background: rgba(148, 163, 184, 0.14);
    color: var(--text);
    border: 1px solid var(--panel-border);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.22);
    box-shadow: none;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 18px;
}

.active-filters-label {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(96, 165, 250, 0.24);
    color: #dbeafe;
    font-weight: 600;
}

.alert {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.24);
    color: #bbf7d0;
}

.alert-error {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.24);
    color: #fecaca;
}

.alert-info {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.24);
    color: #dbeafe;
}

.api-key-box,
.result-box {
    word-break: break-all;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 14px;
    font-family: monospace;
    margin: 12px 0 20px;
    color: var(--text);
}

.result-box {
    margin-top: 20px;
}

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

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

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 440px;
}

.login-card h1 {
    margin-top: 0;
}

.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
    margin-bottom: 16px;
}

.input-group-select,
.input-group-field,
.input-group-btn {
    margin-bottom: 0;
}

.input-group-select {
    flex: 0 0 130px;
    width: auto;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 0;
    background: rgba(15, 23, 42, 0.92);
    font-weight: 600;
}

.input-group-field {
    flex: 1 1 auto;
    min-width: 0;
    border-radius: 0;
    border-right: 0;
}

.input-group-btn {
    flex: 0 0 auto;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding-left: 20px;
    padding-right: 20px;
}

.input-group:focus-within .input-group-select,
.input-group:focus-within .input-group-field {
    border-color: rgba(96, 165, 250, 0.65);
}

.input-group:focus-within {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
    border-radius: 12px;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.72);
    color: var(--text);
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 12px;
    color: var(--muted);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    color: var(--text) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-strong) !important;
    border-color: var(--primary-strong) !important;
    color: #fff !important;
}

@media (max-width: 768px) {
    html {
        -webkit-text-size-adjust: 100%;
    }

    body {
        overflow-x: hidden;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 25;
        margin: 0 0 18px;
        padding: 14px 16px;
        background: rgba(15, 23, 42, 0.96);
        border-bottom: 1px solid var(--panel-border);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        padding: 0;
        border: 1px solid var(--panel-border);
        border-radius: 12px;
        background: rgba(15, 23, 42, 0.92);
        color: var(--text);
        flex-shrink: 0;
        box-shadow: none;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        z-index: 26;
    }

    .sidebar-toggle:hover {
        transform: none;
        box-shadow: none;
        background: rgba(59, 130, 246, 0.14);
    }

    .sidebar-toggle-icon {
        width: 16px;
        height: 2px;
        background: currentColor;
        border-radius: 999px;
        position: relative;
    }

    .sidebar-toggle-icon::before,
    .sidebar-toggle-icon::after {
        content: "";
        position: absolute;
        left: 0;
        width: 16px;
        height: 2px;
        background: currentColor;
        border-radius: 999px;
    }

    .sidebar-toggle-icon::before {
        top: -5px;
    }

    .sidebar-toggle-icon::after {
        top: 5px;
    }

    .mobile-topbar-brand {
        min-width: 0;
    }

    .mobile-topbar-title {
        display: block;
        font-weight: 800;
        font-size: 0.98rem;
        line-height: 1.2;
    }

    .mobile-topbar-sub {
        display: block;
        color: var(--muted);
        font-size: 0.78rem;
        margin-top: 2px;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, 0.62);
        z-index: 35;
    }

    .sidebar-overlay[hidden] {
        display: none;
    }

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

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(280px, 88vw);
        height: 100vh;
        height: 100dvh;
        z-index: 40;
        transform: translateX(-105%);
        transition: transform 0.24s ease;
        border-right: 1px solid var(--panel-border);
        border-bottom: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .content {
        padding: 16px 16px 28px;
        overflow-x: hidden;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .page-header,
    .topbar,
    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header-badge {
        white-space: normal;
    }

    .card {
        padding: 18px 16px;
        border-radius: 14px;
    }

    .card-elevated {
        margin-bottom: 16px;
    }

    .filter-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .filter-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-actions .btn,
    .filter-actions button,
    .filter-actions a.btn {
        width: 100%;
    }

    .table-pagination {
        justify-content: center;
    }

    .table-wrap {
        -webkit-overflow-scrolling: touch;
    }

    .modern-table thead th,
    .assigned-table thead th,
    .modern-table tbody td,
    .assigned-table tbody td,
    table.dataTable tbody td {
        padding: 12px 10px;
        font-size: 0.84rem;
    }

    .hash-cell {
        white-space: normal;
        word-break: break-all;
    }

    .input-group {
        flex-direction: column;
    }

    .input-group-select,
    .input-group-field,
    .input-group-btn {
        width: 100%;
        border-radius: 12px;
        border-right: 1px solid var(--panel-border);
    }

    .input-group-select {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom: 0;
    }

    .input-group-field {
        border-radius: 0;
        border-bottom: 0;
    }

    .input-group-btn {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: left;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_filter {
        margin-top: 10px;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0;
        margin-top: 6px;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none;
        text-align: center;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_paginate {
        margin-top: 10px;
    }

    .login-wrap {
        padding: 16px;
        align-items: flex-start;
        padding-top: 32px;
    }

    .login-card {
        max-width: none;
    }
}
