:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #dbe4f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #ffedd5;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --sidebar: #0f172a;
    --sidebar-text: #e2e8f0;
    --shadow: 0 16px 40px rgba(15, 23, 42, .08);
    --radius-lg: 20px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: Inter, Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
input, select, textarea {
    width: 100%; padding: 0.85rem 0.95rem; border-radius: 12px; border: 1px solid var(--border);
    background: #fff; color: var(--text); outline: none; transition: border-color .2s ease, box-shadow .2s ease;
}
input:focus, select:focus, textarea:focus { border-color: rgba(37, 99, 235, .45); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
textarea { resize: vertical; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border: 0; border-radius: 12px; background: var(--primary); color: #fff; padding: .9rem 1.15rem; font-weight: 700; cursor: pointer; }
.button:hover { background: var(--primary-dark); }
.button-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--sidebar), #111827); color: var(--sidebar-text); padding: 1.5rem 1.25rem; display: flex; flex-direction: column; gap: 1.5rem; }
.sidebar-brand, .sidebar-footer { padding: 1rem; border-radius: 16px; background: rgba(255,255,255,.04); }
.sidebar-title { font-size: 1.1rem; font-weight: 800; margin-bottom: .35rem; }
.sidebar-subtitle, .sidebar-user-hint { color: rgba(226, 232, 240, .72); font-size: .92rem; line-height: 1.5; }
.sidebar-nav { display: grid; gap: .4rem; }
.nav-link { color: rgba(226, 232, 240, .8); padding: .95rem 1rem; border-radius: 12px; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-user { font-weight: 700; }
.content-shell { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem 2rem; background: rgba(255,255,255,.75); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.page-kicker { font-size: .83rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.page-title { font-size: 1.35rem; font-weight: 800; }
.topbar-actions, .inline-actions, .form-actions, .filter-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.ghost-link { color: var(--muted); font-weight: 600; }
.page-content { padding: 2rem; }
.page-section { display: grid; gap: 1.25rem; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-header h1 { margin: .15rem 0 .35rem; font-size: 1.85rem; }
.page-header p, .muted-text, .landing-hero p, .login-copy p { margin: 0; color: var(--muted); line-height: 1.6; }
.card-surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.5rem; }
.filters-card { box-shadow: none; }
.table-card { padding: 0; overflow: hidden; }
.form-card { max-width: 980px; }
.form-card-wide { max-width: 1180px; }
.alert { border-radius: 14px; padding: 1rem 1.1rem; margin-bottom: 1rem; border: 1px solid transparent; font-weight: 600; }
.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: var(--success); }
.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.stats-grid--dashboard, .stats-grid--dashboard-wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats-grid--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card { background: linear-gradient(180deg, #111827, #0f172a); color: #fff; border-radius: 18px; padding: 1.3rem; }
.stat-card--light { background: #fff; color: var(--text); border: 1px solid var(--border); }
.stat-label { display: inline-block; color: var(--muted); font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat-card h3 { margin: .75rem 0 .4rem; font-size: 1.85rem; }
.stat-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.dashboard-grid, .dashboard-grid--wide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.dashboard-span-2 { grid-column: span 2; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2, .details-notes-card h3 { margin: 0 0 .25rem; }
.section-heading p { margin: 0; color: var(--muted); }
.quick-actions-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.quick-action { border: 1px solid var(--border); background: var(--surface-soft); border-radius: 16px; padding: 1rem; display: grid; gap: .45rem; }
.item-list { display: grid; gap: .9rem; }
.item-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .95rem 0; border-bottom: 1px solid var(--border); }
.item-row:last-child { border-bottom: 0; padding-bottom: 0; }
.item-row p { margin: .25rem 0 0; color: var(--muted); }
.filter-form { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 1rem; align-items: end; }
.filter-form--single-row { grid-template-columns: 1fr auto; }
.filter-form--three { grid-template-columns: 1.3fr 1fr auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-field { display: grid; gap: .45rem; }
.form-field--full { grid-column: 1 / -1; }
.form-field label { font-weight: 700; }
.checkbox-field { display: flex; align-items: center; gap: .75rem; align-self: center; padding-top: 1.7rem; }
.checkbox-field input { width: auto; margin: 0; }
.validation-summary, .field-validation { color: var(--danger); font-size: .92rem; font-weight: 600; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 1rem 1.2rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { color: var(--muted); font-size: .86rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; background: #fbfdff; }
.table-subtext { color: var(--muted); margin-top: .3rem; font-size: .9rem; }
.actions-column { width: 220px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.table-link, .table-button { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 700; cursor: pointer; }
.inline-form { display: inline; }
.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: .45rem .75rem; font-size: .82rem; font-weight: 800; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #eef2f7; color: #475569; }
.empty-state { display: grid; place-items: center; text-align: center; padding: 3rem 1.5rem; }
.empty-state.compact { padding: 1rem 0; text-align: left; color: var(--muted); }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.details-grid--single { grid-template-columns: 1fr 1fr; }
.details-list { display: grid; gap: 1rem; margin: 0; }
.details-list div { display: grid; gap: .25rem; padding-bottom: .85rem; border-bottom: 1px solid var(--border); }
.details-list div:last-child { border-bottom: 0; padding-bottom: 0; }
.details-list dt { color: var(--muted); font-weight: 700; }
.details-list dd { margin: 0; font-weight: 600; }
.section-badge { display: inline-flex; align-items: center; border-radius: 999px; background: var(--primary-soft); color: var(--primary); padding: .45rem .75rem; font-size: .82rem; font-weight: 800; }
.landing-section, .login-shell { min-height: 100vh; display: grid; align-items: center; padding: 2rem; }
.landing-hero { padding: 2rem; margin-bottom: 1rem; }
.landing-hero h1, .login-copy h1 { margin: 1rem 0 .75rem; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.1; }
.login-panel { max-width: 1120px; margin: 0 auto; display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center; }
.login-copy ul { margin: 1.25rem 0 0; padding-left: 1.2rem; color: var(--muted); line-height: 1.8; }
.login-form-area { background: var(--surface-soft); border: 1px solid var(--border); border-radius: 18px; padding: 1.5rem; }
.public-shell { min-height: 100vh; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.summary-card { border: 1px solid var(--border); background: var(--surface-soft); border-radius: 16px; padding: 1rem; display: grid; gap: .45rem; }
.summary-card-warning { border-color: #fdba74; background: #fff7ed; }
.summary-card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.summary-card-subtitle, .summary-card-foot { color: var(--muted); font-size: .92rem; }
.summary-card-value { font-size: 1.5rem; font-weight: 800; }
.embedded-section { margin-top: 1.5rem; display: grid; gap: .85rem; }
.form-table-card { overflow-x: auto; }
@media (max-width: 1200px) {
    .stats-grid--dashboard, .stats-grid--dashboard-wide, .dashboard-grid, .dashboard-grid--wide, .quick-actions-grid, .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-span-2 { grid-column: auto; }
}
@media (max-width: 992px) {
    .app-shell { grid-template-columns: 1fr; }
    .topbar { position: static; padding: 1rem 1.25rem; }
    .page-content, .landing-section, .login-shell { padding: 1.25rem; }
    .filter-form, .filter-form--single-row, .filter-form--three, .form-grid, .stats-grid, .details-grid, .details-grid--single, .login-panel, .dashboard-grid, .dashboard-grid--wide, .quick-actions-grid, .summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .topbar, .page-header, .topbar-actions, .filter-actions, .inline-actions, .form-actions { flex-direction: column; align-items: stretch; }
    .actions-column { width: auto; }
    .data-table { display: block; overflow-x: auto; }
}
.nav-section-title { margin: .35rem .2rem; color: rgba(226,232,240,.55); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.topbar-chip { display: inline-flex; align-items: center; justify-content: center; padding: .45rem .75rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.button-danger { background: var(--danger); color: #fff; }
.button-danger:hover { background: #991b1b; }
.feature-switch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.feature-card { border: 1px solid var(--border); border-radius: 18px; background: var(--surface-soft); padding: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.feature-card-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .35rem; }
.feature-card p { margin: 0; color: var(--muted); }
.inline-toggle { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; }
.inline-toggle input { width: auto; }
.quick-actions-grid--single { grid-template-columns: 1fr; }
@media (max-width: 992px) {
    .feature-switch-grid { grid-template-columns: 1fr; }
    .feature-card { flex-direction: column; align-items: stretch; }
}

.print-card { display: grid; gap: 1.5rem; }
.print-header { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-start; }
.print-header h1 { margin: .5rem 0; }
.print-header p { margin: .2rem 0; color: var(--muted); }
.print-summary { min-width: 280px; display: grid; gap: .8rem; }
.print-summary div { border: 1px solid var(--border); border-radius: 14px; padding: .85rem 1rem; background: var(--surface-soft); display: grid; gap: .25rem; }
.print-summary span { color: var(--muted); font-size: .9rem; font-weight: 700; }
.print-summary strong { font-size: 1.05rem; }
.print-notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.print-notes div { border: 1px solid var(--border); border-radius: 14px; padding: 1rem; background: var(--surface-soft); }
.print-notes p { margin: .5rem 0 0; color: var(--muted); line-height: 1.6; }
@media print {
    body, .public-shell, .page-content { background: #fff !important; }
    .sidebar, .topbar, .no-print, .button, .ghost-link, .logout-form, .sidebar-footer, .sidebar-brand, .nav-section-title, .sidebar-nav { display: none !important; }
    .app-shell, .content-shell, .page-content { display: block !important; padding: 0 !important; margin: 0 !important; }
    .card-surface, .print-card { box-shadow: none !important; border: 0 !important; padding: 0 !important; }
    .data-table th { background: #fff !important; }
    .print-header, .print-notes { grid-template-columns: 1fr !important; display: grid !important; }
}


.report-toolbar { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; }
.report-toolbar .inline-actions { justify-content:flex-end; }
.report-grid-2 { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:1rem; }
.surface-accent { background: linear-gradient(135deg, #eff6ff, #ffffff); border: 1px solid #bfdbfe; }
.stat-card--premium { background: linear-gradient(135deg, #0f172a, #1d4ed8); color:#fff; }
.stat-card--premium .stat-label, .stat-card--premium p { color: rgba(255,255,255,.82); }
.table-highlight td { background:#fffdf5; }
@media (max-width: 992px) { .report-grid-2 { grid-template-columns: 1fr; } }


.audit-filter-form { grid-template-columns: repeat(5, minmax(0, 1fr)) auto; }
.audit-table td { vertical-align: top; }
.audit-details { min-width: 280px; }
.audit-details summary { cursor: pointer; color: var(--primary); font-weight: 700; }
.audit-json { margin-top: .75rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); padding: .85rem; }
.audit-json pre { margin: .5rem 0 0; white-space: pre-wrap; word-break: break-word; font-size: .82rem; color: #334155; }
.page-header .header-chip-group { display:flex; gap:.5rem; flex-wrap:wrap; margin-top:.65rem; }
.header-chip { display:inline-flex; align-items:center; padding:.42rem .78rem; border-radius:999px; background:#fff; border:1px solid var(--border); color:var(--muted); font-weight:700; }
.toolbar-card { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; background:linear-gradient(135deg, #eff6ff, #ffffff); }
.toolbar-card h2 { margin:0; }
.toolbar-card p { margin:.35rem 0 0; color:var(--muted); }
@media (max-width: 992px) { .audit-filter-form { grid-template-columns: 1fr; } }


.app-body { background: radial-gradient(circle at top right, rgba(37, 99, 235, .10), transparent 24%), linear-gradient(180deg, #f3f6fb 0%, #eef4ff 100%); }
.app-body::before { content:""; position:fixed; inset:0; pointer-events:none; background: radial-gradient(circle at top left, rgba(59, 130, 246, .08), transparent 20%), radial-gradient(circle at bottom right, rgba(14, 165, 233, .08), transparent 24%); }
.premium-content { position: relative; z-index: 1; }
.button-premium { background: linear-gradient(135deg, #2563eb, #1d4ed8); box-shadow: 0 12px 24px rgba(37, 99, 235, .22); }
.button-premium:hover { background: linear-gradient(135deg, #1d4ed8, #1e40af); }
.premium-panel { border: 1px solid rgba(37, 99, 235, .14); box-shadow: 0 20px 40px rgba(15, 23, 42, .08); }
.summary-card-integration { background: linear-gradient(180deg, #ffffff, #f8fbff); }
.summary-card-integration .summary-card-value { font-size: 1.15rem; }
.integration-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.topbar { backdrop-filter: blur(16px); }
.page-header--with-actions { align-items: flex-start; }
.quick-action { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.quick-action:hover, .summary-card:hover, .card-surface:hover { transform: translateY(-2px); }
.sidebar-brand { background: linear-gradient(180deg, rgba(37,99,235,.18), rgba(255,255,255,.04)); border: 1px solid rgba(255,255,255,.08); }
.sidebar-footer { border: 1px solid rgba(255,255,255,.06); }
@media (max-width: 1200px) { .integration-summary-grid { grid-template-columns: 1fr; } }

.system-center-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.page-section-tight { display: grid; gap: 1rem; margin-top: 1.25rem; }
.check-list { margin: 0; padding-left: 1.2rem; display: grid; gap: .75rem; color: var(--muted); }
.details-list--spacious div { padding-bottom: 1rem; }
.helper-text { display: block; margin-top: .35rem; color: var(--muted); font-size: .88rem; }
@media (max-width: 1200px) { .system-center-grid { grid-template-columns: 1fr; } }
