:root {
    --sidebar-bg: #234b2b;
    --sidebar-soft: #2f6137;
    --sidebar-text: #d5e4cc;
    --sidebar-title: #a7bf96;
    --sidebar-active: rgba(239, 174, 23, 0.18);
    --sidebar-border: rgba(225, 239, 214, 0.12);
    --page-bg: #f4f7fb;
    --page-accent: rgba(82, 155, 255, 0.14);
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-border: rgba(15, 23, 42, 0.08);
    --text: #334155;
    --title: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 12px 32px rgba(15, 23, 42, 0.06);
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
}

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

body {
    position: relative;
    min-height: 100vh;
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.app-backdrop {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.1), transparent 28%),
        radial-gradient(circle at right 20%, rgba(14, 165, 233, 0.09), transparent 24%),
        linear-gradient(180deg, #f8fbff 0%, #f4f7fb 48%, #eef3f8 100%);
    z-index: 0;
}

.crm-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, rgba(35, 75, 43, 0.98), rgba(47, 97, 55, 0.98));
    color: var(--sidebar-text);
    min-height: 100vh;
    padding: 22px 16px 18px;
    border-right: 1px solid var(--sidebar-border);
    backdrop-filter: blur(20px);
}

.sidebar-mobile-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 10px 14px;
}

.sidebar-mobile-head strong {
    color: #fff;
    font-size: 1rem;
}

.sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
}

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

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f0b018, #d8950d);
    box-shadow: 0 0 0 6px rgba(240, 176, 24, 0.16);
}

.brand strong {
    display: block;
    color: #fff;
    font-size: 1.12rem;
    font-weight: 700;
}

.brand small {
    display: block;
    margin-top: 4px;
    color: #c3d5b9;
    font-size: 0.84rem;
}

.sidebar-user {
    margin: 12px 8px 18px;
    padding: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(212, 232, 196, 0.04));
    border: 1px solid rgba(225, 239, 214, 0.1);
    border-radius: var(--radius-md);
}

.sidebar-user strong {
    display: block;
    color: #fff;
    font-size: 0.98rem;
}

.sidebar-user span {
    display: block;
    margin-top: 5px;
    color: #c2d7b6;
    font-size: 0.88rem;
}

.sidebar-title {
    margin: 0 10px 10px;
    color: var(--sidebar-title);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.nav-links {
    display: grid;
    gap: 6px;
    margin-bottom: 18px;
}

.nav-links a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 14px;
    color: var(--sidebar-text);
    border: 1px solid transparent;
    transition: 0.18s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    background: var(--sidebar-active);
    border-color: rgba(240, 176, 24, 0.24);
    box-shadow: inset 0 0 0 1px rgba(255, 240, 204, 0.08);
}

.nav-alert-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: #f0b018;
    color: #17341e;
    font-size: 0.76rem;
    font-weight: 800;
}

.main-content {
    min-width: 0;
}

.content-shell {
    width: min(1280px, calc(100% - 32px));
    margin: 24px auto 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 22px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.topbar-alert-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid rgba(240, 176, 24, 0.18);
    border-radius: 12px;
    background: rgba(255, 251, 235, 0.92);
    color: #7c4a03;
    box-shadow: 0 6px 16px rgba(240, 176, 24, 0.12);
}

.topbar-alert-icon {
    font-size: 1rem;
}

.topbar-alert-text {
    font-weight: 700;
}

.topbar-alert-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.76rem;
    font-weight: 800;
}

.topbar-left h1 {
    margin: 0;
    color: var(--title);
    font-size: clamp(1.5rem, 2vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.breadcrumb-line {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    padding: 9px 12px;
    border-radius: 12px;
}

.user-chip {
    display: grid;
    gap: 3px;
    padding: 10px 14px;
    min-width: 220px;
    background: rgba(248, 250, 252, 0.95);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    text-align: right;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.user-chip strong {
    color: var(--title);
}

.user-chip span {
    color: var(--muted);
    font-size: 0.88rem;
}

.page-content {
    margin-top: 24px;
}

.alert,
.floating-alert {
    margin-top: 18px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    border: 1px solid var(--card-border);
    border-left: 4px solid;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(14px);
}

.alert.success,
.floating-alert.success {
    border-left-color: var(--success);
}

.alert.danger,
.floating-alert.danger {
    border-left-color: var(--danger);
}

.stats-grid,
.content-grid {
    display: grid;
    gap: 22px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    margin-bottom: 22px;
}

.stat-card,
.card,
.panel {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
}

.stat-card {
    overflow: hidden;
    padding: 22px;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
}

.stat-card.accent::before {
    background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
}

.stat-card strong {
    display: block;
    margin-top: 14px;
    color: var(--title);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.card,
.panel {
    padding: 22px;
}

.wide-card {
    grid-column: 1 / -1;
}

.two-columns {
    grid-template-columns: minmax(340px, 430px) 1fr;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.panel-heading h2,
.panel-heading h3 {
    margin: 0;
    color: var(--title);
    font-size: 1.14rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.eyebrow {
    margin: 0 0 5px;
    color: #7c8ca6;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.form-grid,
.inline-grid,
.assignment-row,
.stack-list,
.assignments-box {
    display: grid;
    gap: 16px;
}

.form-grid > *,
.inline-grid > *,
.assignment-row > * {
    min-width: 0;
}

label {
    display: block;
    width: 100%;
    min-width: 0;
}

.inline-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.assignment-row {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    padding: 16px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.92));
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-md);
    position: relative;
    padding-top: 44px;
}

.assignment-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    min-width: 30px;
    height: 30px;
    border: 1px solid #dbe3ee;
    border-radius: 999px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.assignment-remove:hover {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

label span {
    display: block;
    margin-bottom: 7px;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #dbe3ee;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    transition: 0.18s ease;
}

.select2-container {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    display: block !important;
}

.select2-container .select2-selection--single {
    height: 46px !important;
    border: 1px solid #dbe3ee !important;
    border-radius: var(--radius-sm) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    padding: 8px 14px !important;
    display: flex !important;
    align-items: center !important;
    overflow: hidden;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text) !important;
    line-height: 1.4 !important;
    padding-left: 0 !important;
    padding-right: 24px !important;
    display: block !important;
    width: 100% !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.92rem !important;
    max-width: 100%;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px !important;
    right: 10px !important;
}

.select2-dropdown {
    border: 1px solid #dbe3ee !important;
    border-radius: var(--radius-sm) !important;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    box-sizing: border-box;
    max-width: 100%;
}

.select2-container--open .select2-dropdown {
    width: 100% !important;
}

.select2-search--dropdown {
    padding: 10px !important;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid #dbe3ee !important;
    border-radius: var(--radius-sm) !important;
    padding: 8px 10px !important;
}

.select2-results__option {
    padding: 10px 12px !important;
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.35 !important;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
}

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

textarea {
    resize: vertical;
}

.primary-button,
.ghost-button,
.tag,
.secondary-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    transition: 0.18s ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

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

.ghost-button,
.secondary-button {
    background: #fff;
    color: #334155;
    border-color: #dbe3ee;
}

.ghost-button:hover,
.secondary-button:hover {
    background: #f8fafc;
}

.danger-button {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 10px 24px rgba(220, 38, 38, 0.18);
}

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

.tag.success {
    background: rgba(22, 163, 74, 0.12);
    color: var(--success);
    border-color: rgba(22, 163, 74, 0.18);
}

.tag.muted {
    background: rgba(148, 163, 184, 0.14);
    color: #64748b;
    border-color: rgba(148, 163, 184, 0.14);
}

.full-width {
    width: calc(100% - 16px);
    margin: 0 8px;
}

.table-wrap {
    overflow: visible;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid #eef2f7;
    text-align: left;
    white-space: normal;
    font-size: 0.94rem;
}

th {
    color: #64748b;
    font-weight: 700;
    background: rgba(248, 250, 252, 0.95);
}

tbody tr:hover {
    background: rgba(248, 250, 252, 0.72);
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.88);
}

.list-item strong {
    color: var(--title);
}

.list-item span {
    color: var(--muted);
}

.form-inline,
.inline-actions form {
    margin: 0;
}

.filter-inline-form {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-inline-form label {
    min-width: 220px;
}

.dashboard-inline-filter {
    justify-content: flex-end;
}

.dashboard-inline-filter label {
    min-width: 190px;
}

.dashboard-inline-filter span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.profile-layout {
    gap: 18px;
}

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

.profile-summary-card {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(241, 245, 249, 0.9));
}

.profile-summary-card span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.profile-summary-card strong {
    color: var(--title);
    font-size: 1rem;
    line-height: 1.35;
}

.profile-password-panel {
    max-width: 620px;
}

.profile-password-form {
    gap: 14px;
}

.records-inline-filter {
    margin-bottom: 12px;
}

.records-inline-filter label {
    min-width: 200px;
}

.records-inline-filter span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

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

.tabs-header {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.tab-button {
    min-height: 42px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid #dbe3ee;
    background: #fff;
    color: #475569;
    cursor: pointer;
    font-weight: 600;
}

.tab-button.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.actions-cell {
    white-space: normal;
}

.record-summary {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
    padding: 16px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.92));
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-md);
}

.record-summary strong {
    color: var(--title);
}

.mobile-record-list {
    display: none;
}

.mobile-record-filter {
    display: none;
}

.mobile-record-filter label {
    display: grid;
    gap: 8px;
}

.mobile-record-filter span {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mobile-record-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.mobile-record-card + .mobile-record-card {
    margin-top: 12px;
}

.mobile-record-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.mobile-record-card__header h3 {
    margin: 4px 0 0;
    color: var(--title);
    font-size: 1.05rem;
    line-height: 1.3;
}

.mobile-record-badge {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.mobile-record-meta {
    display: grid;
    gap: 10px;
    margin: 0;
}

.mobile-record-meta div {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-sm);
    background: rgba(248, 250, 252, 0.92);
}

.mobile-record-meta div:last-child {
    padding-bottom: 10px;
}

.mobile-record-meta dt,
.mobile-record-meta dd {
    margin: 0;
}

.mobile-record-meta dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mobile-record-meta dd {
    color: var(--title);
    font-size: 0.96rem;
    font-weight: 700;
    text-align: left;
}

.mobile-record-actions {
    justify-content: flex-start;
}

.mobile-record-card--empty p {
    margin: 0;
    color: var(--muted);
}

.records-mobile-tabs {
    position: relative;
}

.app-modal-wrapper,
.record-modal-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(4px);
    z-index: 35;
}

.app-modal-wrapper.is-open,
.record-modal-backdrop {
    display: block;
}

.app-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 40;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.22);
}

.app-modal.modal-wide {
    width: min(960px, calc(100vw - 32px));
}

.app-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.app-modal-close {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 999px;
    font-size: 1.2rem;
}

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

.checkbox-field input {
    width: auto;
}

.helper-text {
    color: var(--muted);
    font-size: 0.9rem;
}

.modal-helper {
    display: grid;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.94));
}

.modal-helper p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.dataTables_wrapper {
    font-size: 0.94rem;
    overflow: visible;
}

.dataTables_wrapper table.dataTable th,
.dataTables_wrapper table.dataTable td {
    white-space: normal !important;
    word-break: break-word;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin: 12px 0;
    color: var(--muted);
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #dbe3ee;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    background: #fff;
}

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

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 8px 12px !important;
    border: 1px solid #dbe3ee !important;
    border-radius: var(--radius-sm) !important;
    background: #fff !important;
    color: #334155 !important;
    margin-left: 0 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f8fafc !important;
    color: #0f172a !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    border-color: transparent !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.55;
    cursor: default !important;
}

.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.18), transparent 22%),
        linear-gradient(180deg, #eff5ff 0%, #eef3fb 100%);
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
}

.auth-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: 1fr 430px;
    gap: 26px;
    align-items: stretch;
}

.auth-hero,
.auth-card {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.auth-hero {
    padding: 38px;
    color: #fff;
    background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 55%, #38bdf8 100%);
}

.auth-hero .eyebrow {
    color: rgba(255, 255, 255, 0.76);
}

.auth-hero h1 {
    margin: 0 0 14px;
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    line-height: 1.04;
    letter-spacing: -0.04em;
}

.auth-card {
    padding: 30px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(18px);
}

.auth-card h2 {
    margin: 0 0 18px;
    color: var(--title);
    font-size: 1.5rem;
}

.login-brand {
    margin-bottom: 18px;
    color: var(--title);
    text-align: center;
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

@media (max-width: 1180px) {
    .content-shell {
        width: min(100%, calc(100% - 28px));
    }
}

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

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        z-index: 50;
        transition: left 0.22s ease;
    }

    .crm-shell.sidebar-open .sidebar {
        left: 0;
    }

    .sidebar-mobile-head {
        display: flex;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .content-shell {
        width: min(100%, calc(100% - 20px));
        margin-top: 14px;
    }

    .two-columns,
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .app-modal {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: 100%;
        max-height: none;
        z-index: 1;
        box-shadow: var(--shadow);
    }

    .app-modal-wrapper.is-open {
        display: block;
        padding: 10px;
        overflow: auto;
    }

    .records-list-hidden-mobile {
        display: none;
    }
}

@media (max-width: 640px) {
    .records-mobile-shell {
        padding: 14px;
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(244, 247, 251, 0.98)),
            radial-gradient(circle at top, rgba(37, 99, 235, 0.08), transparent 42%);
    }

    .records-mobile-shell .panel-heading {
        gap: 12px;
        margin-bottom: 14px;
    }

    .records-mobile-shell .panel-heading h2 {
        font-size: 1.3rem;
    }

    .records-mobile-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding: 6px;
        margin-bottom: 14px;
        border: 1px solid rgba(226, 232, 240, 0.95);
        border-radius: 14px;
        background: rgba(241, 245, 249, 0.95);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    }

    .records-mobile-tabs .tab-button {
        min-height: 42px;
        justify-content: center;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: #5b6b86;
        font-size: 0.9rem;
        font-weight: 700;
        box-shadow: none;
    }

    .records-mobile-tabs .tab-button.active {
        background: linear-gradient(135deg, #2563eb, #1d4ed8);
        color: #fff;
        box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
    }

    .content-shell {
        width: min(100%, calc(100% - 14px));
    }

    .topbar {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 16px;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .user-chip {
        min-width: 0;
        width: 100%;
        text-align: left;
    }

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

    .panel-heading,
    .list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .auth-wrapper {
        padding: 16px;
    }

    .auth-hero,
    .auth-card,
    .card,
    .panel,
    .stat-card {
        padding: 18px;
        border-radius: var(--radius-lg);
    }

    .app-modal {
        width: 100%;
    }

    .mobile-record-list {
        display: block;
        margin-bottom: 12px;
    }

    .mobile-record-filter {
        display: block;
        position: sticky;
        top: 10px;
        z-index: 3;
        margin-bottom: 14px;
    }

    .records-inline-filter {
        margin-bottom: 10px;
    }

    .records-inline-filter label {
        min-width: 100%;
    }

    .mobile-record-filter--subtle label {
        gap: 4px;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
    }

    .mobile-record-filter--subtle span {
        margin-bottom: 2px;
        font-size: 0.72rem;
        letter-spacing: 0.04em;
        color: #7b8aa5;
    }

    .table-wrap {
        display: none;
    }

    .mobile-record-card__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .mobile-record-card {
        gap: 12px;
        padding: 14px;
        border-radius: 16px;
        border-color: rgba(210, 221, 235, 0.92);
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(248, 250, 252, 0.98)),
            radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 28%);
        box-shadow:
            0 10px 26px rgba(15, 23, 42, 0.08),
            0 1px 0 rgba(255, 255, 255, 0.7) inset;
    }

    .mobile-record-card__header h3 {
        font-size: 1rem;
    }

    .mobile-record-card__header .eyebrow {
        font-size: 0.68rem;
        letter-spacing: 0.12em;
    }

    .mobile-record-badge {
        min-height: 30px;
        padding: 0 12px;
        border-radius: 999px;
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(96, 165, 250, 0.08));
        color: #1d4ed8;
        font-size: 0.8rem;
    }

    .mobile-record-filter label {
        gap: 6px;
        padding: 12px;
        border: 1px solid rgba(209, 219, 233, 0.95);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
        backdrop-filter: blur(16px);
    }

    .mobile-record-filter input {
        min-height: 46px;
        border-radius: 12px;
        border: 1px solid rgba(203, 213, 225, 0.95);
        background: #f8fbff;
        box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
    }

    .mobile-record-filter--subtle input {
        min-height: 42px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.92);
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    }

    .mobile-record-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .mobile-record-actions {
        gap: 10px;
        padding-top: 2px;
    }

    .mobile-record-actions .primary-button,
    .mobile-record-actions .secondary-button,
    .mobile-record-actions .danger-button {
        min-height: 40px;
        padding: 0 14px;
        font-size: 0.92rem;
        border-radius: 12px;
    }
}

@media (max-width: 420px) {
    .mobile-record-meta {
        grid-template-columns: 1fr;
    }
}
