:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --panel-border: rgba(16, 24, 40, 0.08);
    --text: #142033;
    --muted: #5f6f86;
    --primary: #1f6feb;
    --primary-dark: #1554b8;
    --edit: #f08b2d;
    --edit-dark: #cd6f16;
    --danger: #d64545;
    --danger-dark: #ae2c2c;
    --success: #1f9d61;
    --warning: #b7791f;
    --shadow: 0 22px 40px rgba(20, 32, 51, 0.08);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(31, 111, 235, 0.12), transparent 28%),
        radial-gradient(circle at bottom right, rgba(240, 139, 45, 0.14), transparent 30%),
        var(--bg);
    color: var(--text);
}

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

a:hover {
    text-decoration: underline;
}

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

.app-shell {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 24px;
    min-height: 100vh;
    padding: 24px;
}

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

.login-wrap {
    width: min(100%, 460px);
}

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

.login-card,
.sidebar,
.content > .card,
.stat-card {
    padding: 28px;
}

.sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand-block h1 {
    margin-bottom: 8px;
}

.eyebrow {
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    color: var(--primary);
    font-weight: 700;
}

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

.nav-links {
    display: grid;
    gap: 10px;
}

.nav-links a {
    padding: 12px 14px;
    border-radius: 16px;
    background: #f6f8fb;
    color: var(--text);
    font-weight: 600;
}

.nav-links a:hover {
    background: #ebf1fb;
    text-decoration: none;
}

.sidebar-status {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.content {
    display: grid;
    gap: 24px;
}

.hero-card {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
}

.hero-actions,
.queue-actions,
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.stat-card {
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-label {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

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

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

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

label span {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

input,
textarea {
    width: 100%;
    border: 1px solid #d6dfeb;
    border-radius: 16px;
    padding: 14px 16px;
    font: inherit;
    color: var(--text);
    background: #fbfdff;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    outline: 2px solid rgba(31, 111, 235, 0.18);
    border-color: rgba(31, 111, 235, 0.45);
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
    opacity: 0.96;
}

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

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

.btn-edit {
    background: var(--edit);
}

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

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

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

.btn-small {
    padding: 10px 14px;
    font-size: 0.92rem;
}

.btn-block {
    width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-success {
    background: rgba(31, 157, 97, 0.12);
    color: var(--success);
}

.badge-danger {
    background: rgba(214, 69, 69, 0.12);
    color: var(--danger);
}

.badge-warning {
    background: rgba(183, 121, 31, 0.14);
    color: var(--warning);
}

.flash {
    padding: 16px 18px;
    border-radius: 18px;
    font-weight: 600;
}

.flash-success {
    background: rgba(31, 157, 97, 0.12);
    color: var(--success);
}

.flash-error {
    background: rgba(214, 69, 69, 0.12);
    color: var(--danger);
}

.section-head,
.queue-meta,
.queue-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

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

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

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid #edf2f7;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.88rem;
}

.preview-box {
    padding: 18px;
    border-radius: 18px;
    background: #f8fbff;
    border: 1px solid #e4edf8;
}

.queue-list {
    display: grid;
    gap: 20px;
}

.queue-item {
    padding: 22px;
    border-radius: 22px;
    background: #f9fbfd;
    border: 1px solid #e6edf5;
}

.pill-link {
    padding: 9px 14px;
    border-radius: 999px;
    background: #f4f7fb;
    color: var(--text);
    font-weight: 600;
}

.pill-link:hover {
    text-decoration: none;
    background: #e8f0fb;
}

.debug-card pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
    color: var(--muted);
}

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

    .sidebar {
        position: static;
    }

    .grid-two,
    .hero-card {
        grid-template-columns: 1fr;
        display: grid;
    }
}

@media (max-width: 640px) {
    .app-shell,
    .login-body {
        padding: 16px;
    }

    .login-card,
    .sidebar,
    .content > .card,
    .stat-card,
    .queue-item {
        padding: 20px;
    }

    .section-head,
    .queue-meta,
    .queue-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}
