:root {
    --bg: #0b1220;
    --bg-soft: #101a2f;
    --card: rgba(16, 26, 47, 0.9);
    --card-2: rgba(255, 255, 255, 0.04);
    --line: rgba(255, 255, 255, 0.08);
    --text: #e6edf7;
    --muted: #9bb0cb;
    --accent: #63e6be;
    --accent-2: #7c9cff;
    --danger: #ff6b6b;
    --warn: #ffb454;
    --shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    --radius: 20px;
    --page-bg-1: rgba(99, 230, 190, 0.18);
    --page-bg-2: rgba(124, 156, 255, 0.18);
    --page-base: #07101d;
    --page-mid: #0b1220;
    --page-end: #0a101b;
    --sidebar-bg: rgba(7, 16, 29, 0.75);
    --panel-soft-bg: rgba(255, 255, 255, 0.03);
}

:root[data-theme="light"] {
    --bg: #f4f7fb;
    --bg-soft: #ffffff;
    --card: rgba(255, 255, 255, 0.92);
    --card-2: rgba(11, 18, 32, 0.04);
    --line: rgba(11, 18, 32, 0.08);
    --text: #101828;
    --muted: #5b6476;
    --accent: #059669;
    --accent-2: #2563eb;
    --danger: #dc2626;
    --warn: #b45309;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
    --page-bg-1: rgba(37, 99, 235, 0.13);
    --page-bg-2: rgba(5, 150, 105, 0.12);
    --page-base: #eef4fb;
    --page-mid: #f7f9fc;
    --page-end: #edf2f7;
    --sidebar-bg: rgba(255, 255, 255, 0.76);
    --panel-soft-bg: rgba(11, 18, 32, 0.03);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
    font-family: "Manrope", "Inter", system-ui, sans-serif;
    background:
        radial-gradient(circle at top left, var(--page-bg-1), transparent 28%),
        radial-gradient(circle at top right, var(--page-bg-2), transparent 24%),
        linear-gradient(180deg, var(--page-base) 0%, var(--page-mid) 45%, var(--page-end) 100%);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    font-size: 0.9em;
}

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

.sidebar {
    padding: 24px;
    border-right: 1px solid var(--line);
    background: var(--sidebar-bg);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand, .auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark, .auth-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #08111e;
    background: linear-gradient(135deg, var(--accent), #d9ffe8);
    box-shadow: 0 12px 24px rgba(99, 230, 190, 0.25);
}

.brand strong, .auth-brand h1 {
    display: block;
    margin: 0;
    font-size: 1.05rem;
}

.brand small, .auth-brand p {
    color: var(--muted);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--muted);
    border: 1px solid transparent;
    background: var(--panel-soft-bg);
}

.nav-item.active, .nav-item:hover {
    color: var(--text);
    border-color: rgba(124, 156, 255, 0.35);
    background: rgba(124, 156, 255, 0.12);
}

.sidebar-logout {
    margin-top: auto;
}

.content {
    padding: 28px;
}

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

.topbar-actions {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--accent);
    font-size: 0.74rem;
}

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

.subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    max-width: 58ch;
}

.searchbar {
    display: flex;
    gap: 10px;
    min-width: min(100%, 420px);
}

.searchbar input,
.auth-form input,
.action-card input,
.action-card select,
.mini-form input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    outline: none;
}

.searchbar input:focus,
.auth-form input:focus,
.action-card input:focus,
.action-card select:focus,
.mini-form input:focus {
    border-color: rgba(99, 230, 190, 0.5);
    box-shadow: 0 0 0 4px rgba(99, 230, 190, 0.08);
}

.searchbar button,
.btn {
    border: 0;
    border-radius: 14px;
    padding: 14px 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.searchbar button:hover,
.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    color: #07101d;
    background: linear-gradient(135deg, var(--accent), #cdf4ff);
}

.btn-danger {
    color: #fff;
    background: linear-gradient(135deg, #ff6b6b, #ff8a4c);
}

.btn-ghost {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
}

.btn-sm {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
}

.theme-toggle {
    width: 100%;
}

.stats-grid,
.action-grid,
.lookup-grid {
    display: grid;
    gap: 18px;
}

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

.stat-card,
.panel,
.auth-card,
.action-card,
.lookup-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 22px;
}

.stat-card span {
    color: var(--muted);
    display: block;
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: 2rem;
}

.panel {
    padding: 20px;
    margin-bottom: 18px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.panel-head h2,
.action-card h3,
.lookup-card h3 {
    margin: 0 0 6px;
}

.panel-head p,
.action-card p,
.lookup-card p {
    margin: 0;
    color: var(--muted);
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(99, 230, 190, 0.12);
    border: 1px solid rgba(99, 230, 190, 0.18);
    color: var(--accent);
    font-size: 0.85rem;
}

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

.action-card {
    padding: 18px;
}

.action-card.warning {
    background: linear-gradient(180deg, rgba(255, 180, 84, 0.08), rgba(16, 26, 47, 0.95));
}

.action-card label {
    display: block;
    margin: 14px 0;
}

.action-card label span,
.auth-form label span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.table-wrap {
    overflow: auto;
    border-radius: 16px;
    border: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
    background: var(--panel-soft-bg);
}

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: #cfe0ff;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--panel-soft-bg);
}

td small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.status {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    text-transform: capitalize;
    font-size: 0.82rem;
    border: 1px solid transparent;
}

.status-active,
.status-success {
    color: #9ef7cf;
    background: rgba(99, 230, 190, 0.12);
    border-color: rgba(99, 230, 190, 0.18);
}

.status-revoked,
.status-inactive,
.status-blocked {
    color: #ffb3b3;
    background: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.18);
}

.status-pending {
    color: #ffe0a8;
    background: rgba(255, 180, 84, 0.12);
    border-color: rgba(255, 180, 84, 0.18);
}

.lookup-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lookup-card {
    padding: 18px;
}

.license-product-card {
    padding: 14px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.license-product-card:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.license-product-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.license-product-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

.mini-form {
    display: grid;
    gap: 10px;
}

.split-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-stack {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.row-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.catalog-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
}

.catalog-list {
    display: grid;
    gap: 10px;
    max-height: 820px;
    overflow: auto;
    padding-right: 4px;
}

.catalog-detail {
    min-width: 0;
}

.catalog-item {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel-soft-bg);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.catalog-item.active,
.catalog-item:hover {
    border-color: rgba(99, 230, 190, 0.35);
    background: rgba(99, 230, 190, 0.08);
}

.catalog-item strong,
.catalog-item small {
    display: block;
}

.catalog-item small {
    color: var(--muted);
    margin-top: 4px;
}

.lookup-card-large {
    min-height: 100%;
}

.panel-head-compact {
    margin-bottom: 18px;
}

.product-form {
    display: grid;
    gap: 16px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.product-grid label,
.product-form label {
    display: block;
}

.product-grid label span,
.product-form label span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.product-form textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel-soft-bg);
    color: var(--text);
    resize: vertical;
    min-height: 120px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.form-actions .btn,
.form-actions a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-card select {
    appearance: none;
}

.mini-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.mini-row:last-child {
    border-bottom: 0;
}

.empty-state {
    padding: 24px;
    border-radius: 18px;
    background: var(--panel-soft-bg);
    border: 1px dashed var(--line);
    color: var(--muted);
}

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

.notice-success { background: rgba(99, 230, 190, 0.12); border-color: rgba(99, 230, 190, 0.2); color: #c9ffe7; }
.notice-error { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.2); color: #ffd3d3; }
.notice-warning { background: rgba(255, 180, 84, 0.12); border-color: rgba(255, 180, 84, 0.2); color: #ffe0b2; }
.notice-info { background: rgba(124, 156, 255, 0.12); border-color: rgba(124, 156, 255, 0.2); color: #d9e4ff; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(100%, 560px);
    padding: 28px;
}

.auth-form {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

.auth-form label {
    display: block;
}

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

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

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

@media (max-width: 860px) {
    .topbar,
    .panel-head,
    .mini-row {
        flex-direction: column;
        align-items: stretch;
    }

    .searchbar,
    .action-grid,
    .stats-grid,
    .lookup-grid {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .license-product-actions,
    .split-grid,
    .catalog-layout,
    .product-grid {
        grid-template-columns: 1fr;
    }

    .mini-stack {
        justify-items: stretch;
    }

    .catalog-list {
        max-height: none;
    }

    .content {
        padding: 18px;
    }

    table {
        min-width: 680px;
    }
}
