:root {
    --brand: #3b82f6;
    --brand-2: #2563eb;
    --brand-soft: rgba(59, 130, 246, .14);
    --bg: #0a0f1c;
    --bg-2: #0f172a;
    --card: #111a2e;
    --card-2: #0d1526;
    --line: #1e2a44;
    --line-soft: #18233b;
    --text: #e5edf7;
    --muted: #93a3ba;
    --danger: #f87171;
    --warn: #fbbf24;
    --ok: #4ade80;
    --radius: 16px;
    --radius-sm: 11px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 40px -28px rgba(0, 0, 0, .9);
    --shadow-lg: 0 30px 70px rgba(0, 0, 0, .65);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    background:
        radial-gradient(900px 500px at 100% -10%, rgba(37, 99, 235, .12), transparent 60%),
        radial-gradient(700px 420px at -10% 110%, rgba(59, 130, 246, .08), transparent 60%),
        var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: #7db0ff; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ===================== Layout ===================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 252px;
    flex: 0 0 252px;
    background: linear-gradient(180deg, #070c18 0%, #0b1324 100%);
    border-right: 1px solid var(--line);
    color: #aab8cc;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 20;
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: #fff;
    font-size: 1.03rem;
    padding: 2px 6px 22px;
    white-space: nowrap;
}
.brand .logo {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    box-shadow: 0 10px 24px rgba(37, 99, 235, .55);
    flex: none;
}
.brand b { color: #7db0ff; font-weight: 700; }

.nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: 11px;
    color: #aab8cc;
    font-size: .93rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item .dot { width: 7px; height: 7px; border-radius: 50%; background: #3b4a66; flex: none; }
.nav-item.active {
    background: linear-gradient(180deg, var(--brand), var(--brand-2));
    color: #fff;
    box-shadow: 0 14px 26px -12px rgba(37, 99, 235, .95);
}
.nav-item.active .dot { background: #fff; }

.sidebar-foot {
    margin-top: auto;
    padding: 14px 8px 0;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: .85rem;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: rgba(10, 15, 28, .82);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 15px 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.page-title { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -.2px; color: #fff; }
.userbox { display: flex; align-items: center; gap: 12px; }
.uname { font-size: .9rem; font-weight: 600; color: var(--text); }

.content { padding: 26px 28px 60px; width: 100%; max-width: 1200px; margin: 0 auto; }

/* ===================== Panels ===================== */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 16px; font-size: 1.03rem; font-weight: 700; letter-spacing: -.2px; color: #fff; }
.panel-highlight { border-color: #2f4d86; box-shadow: 0 0 0 3px rgba(59, 130, 246, .14), var(--shadow); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 15px;
    margin-bottom: 22px;
}
.stat-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--brand), var(--brand-2));
}
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.85rem; font-weight: 800; color: #fff; margin-top: 4px; line-height: 1.1; letter-spacing: -.5px; }
.stat-value.accent { color: #7db0ff; }
.stat-value.danger { color: var(--danger); }

/* ===================== Forms ===================== */
label { display: block; font-size: .88rem; color: #b9c6da; margin-bottom: 14px; font-weight: 500; }
.field-label { display: block; font-size: .88rem; color: #b9c6da; margin-bottom: 9px; font-weight: 600; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="datetime-local"], select, textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 13px;
    border: 1px solid #24314d;
    border-radius: var(--radius-sm);
    font-size: .94rem;
    font-family: inherit;
    background: #0b1220;
    color: var(--text);
    transition: border .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #5b6b86; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .25);
}
select option { background: #0b1220; color: var(--text); }

button {
    cursor: pointer;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--brand), var(--brand-2));
    color: #fff;
    padding: 11px 18px;
    font-size: .9rem;
    font-weight: 700;
    font-family: inherit;
    transition: filter .15s, transform .05s;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }
.btn-danger { background: linear-gradient(180deg, #ef4444, #dc2626); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-warn { background: linear-gradient(180deg, #f59e0b, #d97706); color: #1a1204; }
.btn-warn:hover { filter: brightness(1.08); }
.btn-ghost {
    display: inline-block;
    background: rgba(59, 130, 246, .1);
    color: #9cc0ff;
    border: 1px solid #2b3f68;
    border-radius: var(--radius-sm);
    padding: 9px 15px;
    font-size: .88rem;
    font-weight: 600;
}
.btn-ghost:hover { background: rgba(59, 130, 246, .2); text-decoration: none; }
.btn-block { width: 100%; padding: 13px; font-size: .96rem; }
.mini { padding: 4px 10px; font-size: .75rem; border-radius: 8px; margin-left: 6px; background: rgba(59, 130, 246, .16); color: #9cc0ff; font-weight: 700; }
.mini:hover { background: rgba(59, 130, 246, .28); }

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0 20px;
    align-items: end;
}
.grid-form .full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-top: 4px; }

.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #0d1526;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    margin: 0;
    font-size: .88rem;
    font-weight: 500;
}
.check input { width: auto; margin: 0; accent-color: var(--brand); }

/* ===================== Filters ===================== */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters select, .filters input { width: auto; margin-top: 0; }

/* ===================== Tables ===================== */
.table-wrap { overflow-x: auto; border-radius: 13px; border: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 12px 15px; font-size: .87rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
th { background: var(--card-2); color: #8fa1ba; font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; }
tbody tr:hover { background: #131e36; }
tbody tr:last-child td { border-bottom: none; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions form { margin: 0; }

/* ===================== Alerts ===================== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: .9rem; border: 1px solid transparent; }
.alert-success { background: rgba(22, 163, 74, .12); color: #86efac; border-color: rgba(22, 163, 74, .4); }
.alert-error { background: rgba(220, 38, 38, .12); color: #fca5a5; border-color: rgba(220, 38, 38, .4); }

.muted { color: var(--muted); font-size: .88rem; }

code {
    font-family: Consolas, 'Courier New', monospace;
    font-size: .85rem;
    background: #0d1526;
    color: #bcd2ff;
    padding: 3px 7px;
    border-radius: 6px;
    border: 1px solid var(--line-soft);
}
pre.code {
    background: #070c18;
    color: #cfe0ff;
    border: 1px solid var(--line);
    padding: 17px;
    border-radius: 13px;
    overflow: auto;
    font-size: .82rem;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}
textarea.snippet {
    background: #070c18;
    color: #cfe0ff;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 16px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: .84rem;
    line-height: 1.6;
    resize: vertical;
    white-space: pre;
    overflow: auto;
}

/* ===================== Badges ===================== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge.ok { background: rgba(22, 163, 74, .18); color: var(--ok); }
.badge.bad { background: rgba(220, 38, 38, .18); color: var(--danger); }

.role { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.role-admin { background: rgba(59, 130, 246, .18); color: #93c5fd; }
.role-seller { background: rgba(217, 119, 6, .18); color: var(--warn); }

/* ===================== Sellers ===================== */
.seller-card {
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 17px;
    margin-bottom: 14px;
    background: var(--card-2);
}
.seller-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; flex-wrap: wrap; }
.seller-head strong { margin-right: 8px; color: #fff; }
.assign-form { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.assign-form .checks { flex: 1; min-width: 220px; }

/* ===================== Auth ===================== */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(1100px 520px at 50% -10%, #14275a 0%, #070c18 55%, #04070e 100%);
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.auth-logo {
    width: 56px; height: 56px;
    margin: 0 auto 16px;
    border-radius: 17px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    font-size: 1.6rem;
    font-weight: 800;
    display: grid;
    place-items: center;
    box-shadow: 0 14px 30px rgba(37, 99, 235, .6);
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.36rem; color: #fff; }
.auth-card form { margin-top: 22px; text-align: left; }
.auth-card .muted { margin: 0; }

/* ===================== Responsive ===================== */
@media (max-width: 1024px) {
    .content { padding: 22px 20px 52px; }
    .topbar { padding: 13px 20px; }
}

@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: sticky;
        top: 0;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .brand { padding: 0; }
    .brand span:not(.logo) { display: none; }
    .nav {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 6px;
        flex: 1;
    }
    .nav-item { padding: 9px 13px; font-size: .87rem; }
    .sidebar-foot {
        margin: 0 0 0 auto;
        border: none;
        padding: 0;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    .sidebar-foot .muted { display: none; }
    .topbar { position: static; }
    .page-title { display: none; }
    .content { padding: 18px 14px 48px; }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .content { padding: 16px 12px 44px; }
    .panel { padding: 17px 15px; border-radius: 13px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: .72rem; }
    .grid-form { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions button, .form-actions .btn-ghost { width: 100%; text-align: center; }
    .filters select, .filters input, .filters button, .filters .btn-ghost { width: 100%; }
    .auth-card { padding: 28px 20px; }

    /* Tables -> cards */
    .table-wrap { border: none; border-radius: 0; overflow: visible; }
    .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
    .table-wrap thead { display: none; }
    .table-wrap tr {
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: 13px;
        margin-bottom: 12px;
        padding: 6px 4px;
        box-shadow: var(--shadow);
    }
    .table-wrap tr:hover { background: var(--card); }
    .table-wrap td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 14px;
        padding: 9px 13px;
        border-bottom: 1px dashed var(--line-soft);
        white-space: normal;
        text-align: right;
    }
    .table-wrap td:last-child { border-bottom: none; }
    .table-wrap td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--muted);
        font-size: .74rem;
        text-transform: uppercase;
        letter-spacing: .4px;
        flex: none;
        text-align: left;
    }
    .table-wrap td.actions { flex-wrap: wrap; justify-content: flex-end; }
    .table-wrap td.actions::before { content: ''; }
    .actions { width: 100%; justify-content: flex-end; }
    .actions button, .actions .btn-ghost { width: auto; }
}
