:root {
    --bg: #eef3f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #101828;
    --muted: #667085;
    --line: #d9e2ec;
    --line-strong: #c4d0dd;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #dbeafe;
    --teal: #0f766e;
    --amber: #b45309;
    --success: #047857;
    --danger: #b42318;
    --danger-dark: #8f1d14;
    --shadow: 0 18px 50px rgba(16, 24, 40, 0.12);
    --shadow-soft: 0 10px 28px rgba(16, 24, 40, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.15), transparent 32rem),
        linear-gradient(135deg, #eef3f8 0%, #f8fafc 55%, #eaf1f7 100%);
    color: var(--ink);
    font-family: Inter, Arial, Helvetica, sans-serif;
    font-size: 14px;
}

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

svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.1;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 18px;
    background: #101828;
    color: #eef4ff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 12px 0 32px rgba(16, 24, 40, 0.18);
    z-index: 20;
}

.brand-wrap {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 8px 22px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #60a5fa, #14b8a6);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
}

.brand {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
}

.brand-subtitle,
.nav-section,
.sidebar-footer,
.eyebrow,
.user-meta span {
    color: #98a2b3;
    font-size: 12px;
    font-weight: 600;
}

.nav-menu {
    display: grid;
    gap: 6px;
}

.nav-section {
    margin: 18px 10px 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nav-link {
    position: relative;
    display: flex;
    gap: 11px;
    align-items: center;
    color: #d0d5dd;
    padding: 11px 12px;
    border-radius: var(--radius);
    font-weight: 700;
    transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateX(2px);
}

.nav-link.active::before {
    content: "";
    position: absolute;
    left: -18px;
    top: 9px;
    bottom: 9px;
    width: 4px;
    border-radius: 999px;
    background: #60a5fa;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 10px 6px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12);
}

.main {
    min-width: 0;
    padding: 28px;
}

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

.page-title-group {
    display: flex;
    gap: 14px;
    align-items: center;
}

.topbar h1 {
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.08;
    margin: 0;
    letter-spacing: 0;
}

.eyebrow {
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 5px;
}

.user-chip {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(217, 226, 236, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(14px);
}

.avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--teal));
    font-weight: 800;
}

.user-meta {
    display: grid;
    line-height: 1.2;
}

.user-meta strong {
    font-size: 13px;
}

.panel,
.stat,
.login-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(217, 226, 236, 0.95);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

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

.panel h2,
.builder-toolbar h2 {
    margin: 0;
    font-size: 19px;
}

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

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

.stat {
    position: relative;
    overflow: hidden;
    min-height: 142px;
    padding: 18px;
    display: grid;
    align-content: space-between;
}

.stat::after {
    content: "";
    position: absolute;
    right: -38px;
    top: -38px;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.09);
}

.stat > span:not(.stat-icon) {
    color: var(--muted);
    font-weight: 700;
}

.stat-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: var(--radius);
}

.stat strong {
    display: block;
    font-size: 36px;
    line-height: 1;
    margin-top: 12px;
}

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

.full {
    grid-column: 1 / -1;
}

label {
    display: block;
    font-weight: 700;
    color: #344054;
    margin-bottom: 7px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 12px;
    font: inherit;
    background: #fff;
    color: var(--ink);
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

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

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

.button,
button {
    border: 0;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    padding: 10px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.16);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover,
button:hover {
    background: var(--primary-dark);
    box-shadow: 0 14px 24px rgba(37, 99, 235, 0.24);
    transform: translateY(-1px);
}

.button.secondary {
    background: #475467;
    box-shadow: 0 10px 20px rgba(71, 84, 103, 0.14);
}

.button.danger,
button.danger {
    background: var(--danger);
    box-shadow: 0 10px 20px rgba(180, 35, 24, 0.15);
}

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

.icon-button {
    width: 42px;
    padding: 0;
}

.mobile-menu-button {
    display: none;
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.alert {
    padding: 13px 15px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid;
    box-shadow: var(--shadow-soft);
}

.alert.success {
    color: var(--success);
    background: #ecfdf3;
    border-color: #abefc6;
}

.alert.error {
    color: var(--danger);
    background: #fef3f2;
    border-color: #fecdca;
}

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
}

table.dataTable,
.plain-table {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
}

.dataTables_wrapper {
    width: 100%;
}

.dataTables_scroll,
.dataTables_scrollHead,
.dataTables_scrollBody,
.dataTables_scrollHeadInner,
.dataTables_scrollHeadInner table,
.dataTables_scrollBody table {
    width: 100% !important;
}

.dataTables_scrollBody {
    border-bottom: 1px solid var(--line) !important;
}

table.dataTable thead th,
.plain-table thead th {
    background: #e8eef6;
    color: #101828;
    border: 0;
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table.dataTable tbody td,
.plain-table td {
    border-bottom: 1px solid var(--line);
    background: #fff;
    vertical-align: middle;
}

.plain-table th,
.plain-table td,
table.dataTable thead th,
table.dataTable tbody td {
    padding: 12px 13px;
    text-align: left;
}

table.dataTable tbody tr:hover td,
.plain-table tbody tr:hover td {
    background: #f8fbff;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-left: 7px;
}

.datatable-toolbar,
.datatable-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.datatable-toolbar {
    display: grid;
    grid-template-columns: auto auto minmax(260px, 420px) 1fr;
    justify-content: start;
}

.datatable-toolbar .dataTables_length {
    order: 2;
}

.datatable-toolbar .dataTables_filter {
    order: 3;
    margin-left: 0;
    justify-self: start;
    width: min(420px, 100%);
}

.datatable-toolbar .dt-buttons {
    order: 1;
}

.datatable-toolbar .dataTables_filter label {
    display: grid;
    grid-template-columns: auto minmax(190px, 1fr);
    gap: 8px;
    align-items: center;
    margin-bottom: 0;
}

.datatable-toolbar .dataTables_filter input {
    width: 100%;
}

.datatable-footer {
    margin-top: 14px;
    margin-bottom: 0;
}

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

.dt-button,
div.dt-button-collection .dt-button {
    border: 0 !important;
    border-radius: var(--radius) !important;
    background: #eef4ff !important;
    color: #1d4ed8 !important;
    font-weight: 800 !important;
    padding: 8px 11px !important;
    box-shadow: none !important;
}

.dt-button:hover,
div.dt-button-collection .dt-button:hover {
    background: #dbeafe !important;
    color: #1e40af !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius) !important;
}

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

.login-card {
    width: min(440px, 100%);
    padding: 32px;
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--teal));
}

.login-card h1 {
    margin-top: 0;
    font-size: 28px;
}

.logout-form {
    margin: 0;
}

.builder-toolbar,
.field-builder-head,
.inline-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

td .inline-actions {
    justify-content: flex-start;
    flex-wrap: nowrap;
    min-width: 220px;
}

td .inline-actions .button,
td .inline-actions button {
    min-height: 36px;
    padding: 8px 11px;
}

.builder-toolbar {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.field-builder {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 14px;
    background: var(--surface-soft);
}

.field-builder-head {
    margin-bottom: 14px;
}

.field-type-example {
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    background: #eff6ff;
    color: #1e3a8a;
    padding: 11px 12px;
    font-weight: 700;
}

.options-builder {
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: #fff;
    padding: 14px;
}

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

.option-list {
    display: grid;
    gap: 10px;
}

.option-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.choice-group {
    display: grid;
    gap: 8px;
}

.choice-group label {
    font-weight: 500;
    margin-bottom: 0;
}

.choice-group input {
    width: auto;
    margin-right: 6px;
}

.help-text {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.sidebar-backdrop {
    display: none;
}

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

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

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(300px, 86vw);
        transform: translateX(-104%);
        transition: transform 180ms ease;
    }

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

    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(16, 24, 40, 0.52);
        z-index: 15;
    }

    .main {
        padding: 20px;
    }

    .mobile-menu-button {
        display: inline-flex;
    }

    .app-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .user-chip {
        width: 100%;
        justify-content: space-between;
    }

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

    .datatable-toolbar {
        grid-template-columns: 1fr;
    }

    .datatable-toolbar .dataTables_filter {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .user-chip {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .panel,
    .login-card {
        padding: 18px;
    }
}
