:root {
    --bg: #0b1220;
    --card: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.12);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.68);
    --primary: #4f7cff;
    --danger: #ff4d4f;
    --ok: #35c759;
    --shadow-sm: 0 8px 28px rgba(0, 0, 0, 0.28);
    --focus-ring: 0 0 0 3px rgba(79, 124, 255, 0.22);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(1200px 600px at 10% 10%, rgba(79, 124, 255, 0.25), transparent),
                radial-gradient(1000px 500px at 90% 20%, rgba(255, 77, 79, 0.15), transparent),
                var(--bg);
    color: var(--text);
}

button, input, select {
    font-family: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    border-left: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.brand {
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.brand-title {
    font-weight: 900;
    font-size: 1.1rem;
}

.brand-sub {
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    width: 100%;
    text-align: right;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
    border-color: rgba(79, 124, 255, 0.7);
    background: rgba(79, 124, 255, 0.18);
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    color: var(--muted);
}

.main {
    padding: 1.25rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    flex: 1;
}

.title {
    font-size: 1.6rem;
    font-weight: 800;
}

.sub {
    color: var(--muted);
    margin-top: 0.25rem;
}

.topbar-actions {
    flex: 1;
    max-width: 640px;
}

.token-row {
    display: grid;
    grid-template-columns: 140px 1fr 120px;
    gap: 0.75rem;
    align-items: center;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-weight: 900;
    margin-bottom: 0.75rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.stat {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.85rem 0.9rem;
    background: rgba(0, 0, 0, 0.25);
}

.stat .k {
    color: var(--muted);
    font-size: 0.9rem;
}

.stat .v {
    font-size: 1.4rem;
    font-weight: 900;
    margin-top: 0.25rem;
}

.toolbar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0.75rem;
}

.toolbar .btn {
    width: auto;
}

.toolbar .input {
    width: auto;
    min-width: 180px;
}

.pager .btn {
    width: auto;
}

.actions-row .btn {
    width: auto;
}

.pager {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.muted {
    color: var(--muted);
    font-weight: 700;
}

.small:hover {
    background: rgba(255, 255, 255, 0.12);
}

.small:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}


.row {
    display: grid;
    grid-template-columns: 160px 1fr 120px;
    gap: 0.75rem;
    align-items: center;
}

.label {
    color: var(--muted);
    font-size: 0.95rem;
}

.input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    outline: none;
}

.input:focus {
    box-shadow: var(--focus-ring);
    border-color: rgba(79, 124, 255, 0.55);
}

.btn {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(79, 124, 255, 0.9), rgba(79, 124, 255, 0.7));
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(1.05);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.06);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.table-wrap {
    overflow: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.table th,
.table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
}

.table th {
    color: var(--muted);
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
}

.badge.ok { border-color: rgba(53, 199, 89, 0.6); color: rgba(53, 199, 89, 0.95); }
.badge.bad { border-color: rgba(255, 77, 79, 0.6); color: rgba(255, 77, 79, 0.95); }
.badge.wait { border-color: rgba(255, 200, 0, 0.55); color: rgba(255, 200, 0, 0.95); }

.actions {
    display: flex;
    gap: 0.5rem;
}

.small {
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
}

.small.ok { background: rgba(53, 199, 89, 0.15); }
.small.bad { background: rgba(255, 77, 79, 0.15); }

.toast {
    display: none;
    margin-bottom: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
}

.toast.show { display: block; }
.toast.ok { border-color: rgba(53, 199, 89, 0.6); }
.toast.bad { border-color: rgba(255, 77, 79, 0.6); }

.link {
    color: rgba(79, 124, 255, 0.95);
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

@media (max-width: 720px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-left: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .nav-item {
        width: auto;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .token-row {
        grid-template-columns: 1fr;
    }

    .grid {
        grid-template-columns: 1fr;
    }
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
}

.modal.show {
    display: flex;
}

.modal-card {
    width: 100%;
    max-width: 520px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(11, 18, 32, 0.98);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-weight: 900;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    font-size: 1.4rem;
    font-weight: 900;
    line-height: 1;
}

.modal-body {
    padding: 1rem;
}

.modal-actions {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.actions-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
