* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --danger: #dc2626;
    --danger-dark: #991b1b;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #0f172a;
    color: white;
    padding: 24px;
    position: fixed;
    inset: 0 auto 0 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 34px;
}

.sidebar-brand strong {
    display: block;
    font-size: 18px;
}

.sidebar-brand span {
    display: block;
    color: #cbd5e1;
    font-size: 13px;
    margin-top: 2px;
}

.brand-badge {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #6366f1, #22d3ee);
    color: white;
    font-weight: 800;
    letter-spacing: 0.08em;
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.3);
}

.brand-badge.small {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    font-size: 13px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    color: #cbd5e1;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.09);
    color: white;
}

.main {
    margin-left: 260px;
    width: calc(100% - 260px);
    padding: 28px;
}

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 800;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 34px;
    letter-spacing: -0.04em;
}

h2 {
    margin-bottom: 4px;
    font-size: 22px;
}

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

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

.user-pill {
    background: white;
    border: 1px solid var(--line);
    padding: 10px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
}

.btn {
    border: 1px solid var(--line);
    background: white;
    color: var(--text);
    border-radius: 12px;
    padding: 11px 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    text-decoration: none;
    font-size: 14px;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger);
    border-color: #fecaca;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

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

.stat-card {
    padding: 18px;
}

.stat-card span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-card strong {
    display: block;
    font-size: 24px;
}

.panel {
    padding: 22px;
}

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

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

.right {
    text-align: right;
}

.action-cell {
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: 56px 18px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: #fafafa;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

label span {
    font-size: 13px;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px 14px;
    font: inherit;
    background: white;
    color: var(--text);
    outline: none;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.code-label {
    margin-top: 16px;
}

textarea {
    min-height: 560px;
    resize: vertical;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.55;
}

.form-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.message {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
}

.message.success {
    background: #dcfce7;
    color: #166534;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

.hidden {
    display: none;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.25), transparent 32%),
        radial-gradient(circle at bottom right, rgba(34, 211, 238, 0.20), transparent 32%),
        #0f172a;
}

.auth-card {
    width: min(420px, 100%);
    background: white;
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.22);
}

.auth-card .brand-badge {
    margin-bottom: 18px;
}

.auth-card h1 {
    margin-bottom: 8px;
}

.tiny-note {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.simple-error {
    min-height: 100vh;
    display: grid;
    place-content: center;
    text-align: center;
    padding: 24px;
}

.simple-error h1 {
    font-size: 58px;
    margin-bottom: 8px;
}

@media (max-width: 860px) {
    .layout {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        padding: 18px;
    }

    .sidebar-brand {
        margin-bottom: 16px;
    }

    .sidebar-nav {
        grid-template-columns: repeat(3, 1fr);
    }

    .sidebar-nav a {
        text-align: center;
        padding: 10px;
    }

    .main {
        margin-left: 0;
        width: 100%;
        padding: 18px;
    }

    .topbar {
        display: grid;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 28px;
    }

    textarea {
        min-height: 420px;
    }
}

@media (max-width: 560px) {
    .sidebar-nav {
        grid-template-columns: 1fr;
    }

    .topbar-actions,
    .form-actions {
        display: grid;
        width: 100%;
    }

    .user-pill {
        width: 100%;
        text-align: center;
    }

    .btn {
        width: 100%;
    }

    th,
    td {
        padding: 12px 10px;
    }
}
