:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #dbe3ee;
    --sidebar: #0f172a;
    --sidebar-soft: #1e293b;
    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-warm: #f97316;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 8px;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    background: var(--bg);
    font-family: var(--font);
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
}

.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.94)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.05'%3E%3Cpath d='M0 40h160M0 80h160M0 120h160M40 0v160M80 0v160M120 0v160'/%3E%3C/g%3E%3C/svg%3E");
}

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

.auth-card {
    width: min(430px, 100%);
    padding: 34px;
    background: var(--panel);
    border: 1px solid rgba(219, 227, 238, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.brand-lockup,
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
    border-radius: var(--radius);
    font-weight: 800;
}

.brand-lockup span,
.sidebar-brand span,
.topbar-user span,
#page-subtitle {
    display: block;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.auth-card h1 {
    margin: 30px 0 8px;
    font-size: 28px;
}

.auth-subtitle {
    margin: 0 0 24px;
    color: var(--muted);
}

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

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--ink);
    background: #ffffff;
    outline: none;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 800;
    text-decoration: none;
    transition: transform .12s ease, background .12s ease, border .12s ease;
}

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

.btn:disabled {
    cursor: not-allowed;
    opacity: .65;
    transform: none;
}

.btn-primary {
    color: #ffffff;
    background: var(--accent);
}

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

.btn-secondary {
    color: var(--ink);
    background: #ffffff;
    border-color: var(--line);
}

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

.btn-warm {
    color: #ffffff;
    background: var(--accent-warm);
}

.btn-block {
    width: 100%;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 260px;
    padding: 18px;
    color: #e2e8f0;
    background: var(--sidebar);
}

.sidebar-brand {
    padding: 4px 4px 18px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.12);
}

.sidebar-brand strong {
    color: #ffffff;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    margin-top: 18px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: #cbd5e1;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    text-align: left;
    font-weight: 750;
}

.nav-item svg,
.icon-button svg,
.btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
}

.nav-item:hover,
.nav-item.active {
    color: #ffffff;
    background: var(--sidebar-soft);
    border-color: rgba(226, 232, 240, 0.08);
}

.app-main {
    width: 100%;
    min-width: 0;
    margin-left: 260px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 28px;
    background: rgba(244, 247, 251, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

#page-title {
    display: block;
    font-size: 20px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: #ffffff;
    background: var(--sidebar-soft);
    border-radius: 50%;
    font-weight: 800;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: #ffffff;
}

.content {
    padding: 28px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-head h1 {
    margin: 0;
    font-size: 26px;
}

.page-head p {
    margin: 5px 0 0;
    color: var(--muted);
}

.grid {
    display: grid;
    gap: 18px;
}

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

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

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

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.card-pad {
    padding: 18px;
}

.metric-card {
    display: grid;
    gap: 8px;
    padding: 18px;
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-card strong {
    font-size: 32px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 14px;
}

.section-title h2 {
    margin: 0;
    font-size: 18px;
}

.toolbar {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.toolbar label {
    min-width: 190px;
    flex: 1;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

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

th {
    color: var(--muted);
    background: var(--panel-soft);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

tr:hover td {
    background: #f8fafc;
}

tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.badge-success {
    color: #166534;
    background: #dcfce7;
}

.badge-warning {
    color: #92400e;
    background: #fef3c7;
}

.badge-danger {
    color: #991b1b;
    background: #fee2e2;
}

.badge-info {
    color: #1e40af;
    background: #dbeafe;
}

.badge-muted {
    color: #475569;
    background: #e2e8f0;
}

.actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 220px;
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert-error {
    color: #991b1b;
    background: #fee2e2;
    border: 1px solid #fecaca;
}

.alert-info {
    color: #1e40af;
    background: #dbeafe;
    border: 1px solid #bfdbfe;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.switch {
    position: relative;
    width: 54px;
    height: 30px;
}

.switch input {
    width: 0;
    height: 0;
    opacity: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: .15s ease;
}

.slider::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: .15s ease;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .18);
}

.switch input:checked + .slider {
    background: var(--success);
}

.switch input:checked + .slider::before {
    transform: translateX(24px);
}

.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e40af;
    border-radius: 999px;
    padding: 6px 10px;
    font-weight: 800;
}

.preview-box,
.qr-box {
    min-height: 150px;
    padding: 16px;
    background: var(--panel-soft);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    white-space: pre-wrap;
}

.qr-box {
    display: grid;
    place-items: center;
    text-align: center;
}

.qr-box img {
    max-width: 260px;
    width: 100%;
    border-radius: var(--radius);
}

.progress {
    height: 12px;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: 999px;
}

.progress span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-warm));
    transition: width .25s ease;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.58);
}

.modal {
    width: min(760px, 100%);
    max-height: min(88vh, 820px);
    overflow: auto;
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 {
    margin: 0;
    font-size: 19px;
}

.modal-body {
    padding: 18px;
}

.toast-root {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    display: grid;
    gap: 10px;
    max-width: 360px;
}

.toast {
    padding: 13px 14px;
    color: #ffffff;
    background: var(--sidebar);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-weight: 750;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--accent);
}

.global-loader {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: start center;
    padding-top: 12px;
    pointer-events: none;
}

.global-loader span {
    width: 180px;
    height: 4px;
    overflow: hidden;
    background: rgba(37, 99, 235, .16);
    border-radius: 999px;
}

.global-loader span::before {
    content: "";
    display: block;
    width: 40%;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    animation: loader 1s infinite ease-in-out;
}

@keyframes loader {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(260%); }
}

.mobile-only {
    display: none;
}

@media (max-width: 1100px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 820px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .18s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .mobile-only {
        display: inline-grid;
    }

    .topbar {
        padding: 12px 16px;
    }

    .topbar-user > div:not(.avatar) {
        display: none;
    }

    .content {
        padding: 18px 14px;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .page-head,
    .switch-row {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar {
        align-items: stretch;
    }

    .toolbar label,
    .toolbar .btn {
        width: 100%;
    }
}

