html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

:root {
    --bg: #05080f;
    --panel: #0d1420;
    --panel-2: #111b2b;
    --border: rgba(255, 255, 255, .09);
    --muted: #9aa8ba;
    --text: #eef3f9;
    --gold: #f5b942;
    --gold-dark: #a97416;
    --danger: #ff6b6b;
    --success: #50d890;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(245, 185, 66, .15), transparent 32rem),
        linear-gradient(135deg, #05080f 0%, #09111d 48%, #04060a 100%);
    color: var(--text);
    min-height: 100vh;
    font-family: Inter, "Segoe UI", Tahoma, Arial, sans-serif;
}

a {
    color: #ffd476;
    text-decoration: none;
}

a:hover {
    color: #fff0bd;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.5rem;
    background: rgba(8, 13, 22, .96);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(16px);
}

.brand {
    display: flex;
    align-items: center;
    gap: .8rem;
    color: var(--text);
    margin-bottom: 2rem;
}

.brand:hover {
    color: var(--text);
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #111;
    background: linear-gradient(135deg, #ffd476, var(--gold));
    font-weight: 900;
    box-shadow: 0 16px 35px rgba(245, 185, 66, .2);
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: .78rem;
}

.side-nav {
    display: grid;
    gap: .35rem;
}

.side-nav a,
.nav-section {
    display: block;
    padding: .8rem .95rem;
    border-radius: 14px;
    color: #d9e2ef;
}

.side-nav a:hover {
    background: rgba(255, 255, 255, .06);
}

.nav-section {
    margin-top: 1rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .7rem;
}

.disabled-link {
    color: rgba(217, 226, 239, .42) !important;
    cursor: not-allowed;
}

.main-content {
    padding: 1.5rem;
}

.topbar {
    min-height: 96px;
    padding: 1.2rem 1.4rem;
    margin-bottom: 1.2rem;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(17, 27, 43, .95), rgba(13, 20, 32, .78));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.eyebrow {
    margin: 0;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: .14em;
    font-size: .72rem;
    font-weight: 700;
}

.topbar h1 {
    margin: .2rem 0 0;
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 800;
}

.topbar-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card,
.panel,
.wallet-card,
.wallet-item {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(17, 27, 43, .94), rgba(13, 20, 32, .94));
    box-shadow: 0 20px 50px rgba(0, 0, 0, .22);
}

.stat-card {
    padding: 1.1rem;
    border-radius: 22px;
}

.stat-card span,
.stat-card small {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin: .35rem 0;
    font-size: 1.35rem;
    letter-spacing: -.03em;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 1rem;
}

.panel {
    padding: 1.2rem;
    border-radius: 24px;
}

.narrow-panel {
    max-width: 980px;
}

.panel-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.panel-header p {
    margin: .25rem 0 0;
    color: var(--muted);
}

.app-table {
    color: var(--text);
    margin-bottom: 0;
}

.app-table thead th {
    color: var(--muted);
    border-bottom-color: var(--border);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.app-table td {
    border-top-color: var(--border);
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    background: transparent;
    color: inherit;
}

.form-control,
.form-select {
    color: var(--text);
    background-color: rgba(255, 255, 255, .055);
    border: 1px solid var(--border);
}

.form-control:focus,
.form-select:focus {
    color: var(--text);
    background-color: rgba(255, 255, 255, .08);
    border-color: rgba(245, 185, 66, .72);
    box-shadow: 0 0 0 .2rem rgba(245, 185, 66, .14);
}

.form-control::placeholder {
    color: rgba(238, 243, 249, .42);
}

.form-label {
    color: #dce6f5;
    font-weight: 650;
}

.form-actions {
    margin-top: 1.2rem;
    display: flex;
    justify-content: flex-end;
    gap: .65rem;
}

.btn-warning {
    background: linear-gradient(135deg, #ffd476, var(--gold));
    border: 0;
    color: #16100a;
    font-weight: 800;
}

.btn-outline-light {
    border-color: rgba(255, 255, 255, .2);
}

.wallet-list {
    display: grid;
    gap: .7rem;
}

.wallet-item,
.wallet-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-radius: 18px;
    padding: 1rem;
    color: var(--text);
}

.wallet-item:hover,
.wallet-card:hover {
    color: var(--text);
    transform: translateY(-1px);
    border-color: rgba(245, 185, 66, .32);
}

.wallet-item span,
.wallet-card span {
    color: var(--muted);
}

.wallet-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.wallet-card {
    min-height: 140px;
    flex-direction: column;
    align-items: flex-start;
}

.wallet-card strong {
    font-size: 1.35rem;
}

.details-list {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: .75rem 1rem;
    margin: 0;
}

.details-list dt {
    color: var(--muted);
}

.details-list dd {
    margin: 0;
    font-weight: 650;
}

.mini-form {
    display: grid;
    gap: .7rem;
}

.mini-form h3 {
    font-size: .95rem;
    color: var(--gold);
    margin: 0;
}

hr {
    border-color: var(--border);
    opacity: 1;
}

.alert {
    border: 0;
    border-radius: 16px;
}

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

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .side-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid,
    .content-grid,
    .wallet-cards {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .main-content,
    .sidebar {
        padding: 1rem;
    }

    .side-nav {
        grid-template-columns: 1fr;
    }

    .details-list {
        grid-template-columns: 1fr;
    }

    .wallet-item {
        align-items: flex-start;
        flex-direction: column;
    }
}

html[dir="rtl"] body {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    text-align: right;
}

html[dir="rtl"] .sidebar {
    border-right: 0;
    border-left: 1px solid var(--border);
}

html[dir="rtl"] .brand,
html[dir="rtl"] .wallet-item,
html[dir="rtl"] .wallet-card,
html[dir="rtl"] .panel-header,
html[dir="rtl"] .topbar,
html[dir="rtl"] .topbar-actions,
html[dir="rtl"] .form-actions {
    direction: rtl;
}

.setup-list {
    display: grid;
    gap: .65rem;
    margin: 0;
    color: #dce6f5;
}

.code-box {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .045);
    direction: ltr;
    text-align: left;
}

.empty-state {
    padding: 2rem;
    border-radius: 20px;
    border: 1px dashed rgba(245, 185, 66, .35);
    background: rgba(245, 185, 66, .045);
    color: #dce6f5;
}

.empty-state h3 {
    color: var(--gold);
    font-weight: 850;
}

.details-grid {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: .75rem 1rem;
    margin: 0;
}

.details-grid dt {
    color: var(--muted);
}

.details-grid dd {
    margin: 0;
    font-weight: 650;
    white-space: pre-wrap;
}

.section-title {
    margin: 0 0 .8rem;
    font-size: 1rem;
    color: var(--gold);
    font-weight: 800;
}

.info-note {
    padding: .85rem 1rem;
    border-radius: 16px;
    background: rgba(245, 185, 66, .08);
    border: 1px solid rgba(245, 185, 66, .18);
    color: #f4e3b7;
}

.report-preview {
    min-height: 360px;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .045);
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.8;
    direction: rtl;
    text-align: right;
}

.auth-panel {
    width: min(100%, 520px);
    margin: 4rem auto;
    padding: 1.35rem;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(17, 27, 43, .96), rgba(13, 20, 32, .96));
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}

.secure-note {
    padding: .85rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(245, 185, 66, .18);
    background: rgba(245, 185, 66, .06);
    color: #f4e3b7;
}

.account-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .045);
}

.account-chip span {
    color: #dce6f5;
    padding-inline: .55rem;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.command-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .7rem;
}

.command-grid span,
.audit-json {
    display: block;
    padding: .65rem .8rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .045);
}

.command-grid span {
    color: #fff0bd;
    font-weight: 750;
    text-align: center;
}

.audit-json {
    max-width: 520px;
    max-height: 120px;
    overflow: auto;
    color: #dce6f5;
    white-space: pre-wrap;
    direction: ltr;
    text-align: left;
}

@media (max-width: 640px) {
    .command-grid {
        grid-template-columns: 1fr;
    }
}
