:root {
    --ba-bg: #f3f6fb;
    --ba-card: #ffffff;
    --ba-card-soft: #f8fafc;
    --ba-text: #0f172a;
    --ba-muted: #64748b;
    --ba-line: #e2e8f0;
    --ba-line-soft: #eef2f7;
    --ba-primary: #2563eb;
    --ba-primary-dark: #1d4ed8;
    --ba-primary-soft: #eff6ff;
    --ba-green: #16a34a;
    --ba-green-soft: #f0fdf4;
    --ba-amber: #d97706;
    --ba-amber-soft: #fffbeb;
    --ba-red: #dc2626;
    --ba-red-soft: #fef2f2;
    --ba-sidebar: #0f172a;
    --ba-sidebar-soft: #111c30;
    --ba-shadow: 0 18px 50px rgba(15, 23, 42, .08);
    --ba-shadow-soft: 0 10px 26px rgba(15, 23, 42, .06);
    --ba-radius: 24px;
    --ba-radius-lg: 32px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ba-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, rgba(37, 99, 235, .12), transparent 34%), radial-gradient(circle at top right, rgba(22, 163, 74, .08), transparent 28%), linear-gradient(180deg, #f8fafc 0%, var(--ba-bg) 48%, #eef3f9 100%);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.ba-app { min-height: 100vh; display: grid; grid-template-columns: 290px minmax(0, 1fr); }
.ba-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 20px 16px;
    color: #dbeafe;
    background: linear-gradient(180deg, var(--ba-sidebar), #101827 55%, #0b1220 100%);
    border-right: 1px solid rgba(255,255,255,.08);
}
.ba-brand { display: flex; align-items: center; gap: 12px; padding: 10px 10px 20px; color: #fff; }
.ba-brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(135deg, var(--ba-primary), #38bdf8); font-weight: 950; box-shadow: 0 18px 34px rgba(37,99,235,.28); }
.ba-brand strong { display: block; font-size: 18px; letter-spacing: -.04em; }
.ba-brand small { display: block; margin-top: 2px; color: #94a3b8; font-size: 12px; font-weight: 800; }
.ba-nav { display: grid; gap: 18px; padding-bottom: 30px; }
.ba-nav-title { display: block; margin: 0 10px 8px; color: #94a3b8; font-size: 11px; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
.ba-nav-link { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border-radius: 14px; color: #cbd5e1; font-size: 14px; font-weight: 850; transition: background .18s ease, color .18s ease, transform .18s ease; }
.ba-nav-link:hover { background: rgba(255,255,255,.07); color: #fff; transform: translateX(2px); }
.ba-nav-link.is-active { background: rgba(37,99,235,.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(96,165,250,.22); }

.ba-main { min-width: 0; }
.ba-topbar { position: sticky; top: 0; z-index: 20; min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 24px; background: rgba(255,255,255,.82); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(226,232,240,.92); }
.ba-menu-btn { display: none; width: 42px; height: 42px; border: 1px solid var(--ba-line); background: #fff; border-radius: 14px; font-weight: 950; }
.ba-topbar-title strong { display: block; font-size: 18px; letter-spacing: -.03em; }
.ba-topbar-title span { display: block; margin-top: 2px; color: var(--ba-muted); font-size: 12px; font-weight: 800; }
.ba-topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.ba-pill, .ba-user-chip { min-height: 38px; display: inline-flex; align-items: center; padding: 0 13px; border-radius: 999px; background: #fff; border: 1px solid var(--ba-line); color: #334155; font-size: 13px; font-weight: 900; }
.ba-user-chip { background: var(--ba-primary-soft); color: var(--ba-primary); border-color: rgba(37,99,235,.18); }
.ba-content { width: min(1800px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 64px; }

.ba-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1.2fr) auto; gap: 24px; align-items: center; padding: 34px; border: 1px solid rgba(226,232,240,.92); background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(248,250,252,.92)), radial-gradient(circle at right top, rgba(37,99,235,.18), transparent 36%); border-radius: var(--ba-radius-lg); box-shadow: var(--ba-shadow); overflow: hidden; }
.ba-hero::after { content: ""; position: absolute; right: -120px; bottom: -160px; width: 360px; height: 360px; border-radius: 999px; background: rgba(37,99,235,.08); pointer-events: none; }
.ba-hero > * { position: relative; z-index: 1; }
.ba-kicker { display: inline-flex; align-items: center; gap: 9px; min-height: 32px; padding: 0 13px; border: 1px solid rgba(37,99,235,.14); background: rgba(37,99,235,.08); border-radius: 999px; color: var(--ba-primary); font-size: 12px; font-weight: 950; letter-spacing: .06em; text-transform: uppercase; }
.ba-kicker::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--ba-primary); box-shadow: 0 0 0 5px rgba(37,99,235,.13); }
.ba-hero h1 { margin: 16px 0 10px; font-size: clamp(36px, 4.2vw, 64px); line-height: .94; letter-spacing: -.065em; }
.ba-hero p { max-width: 860px; margin: 0; color: var(--ba-muted); font-size: 16px; line-height: 1.7; }
.ba-hero-actions, .ba-filter-actions, .ba-row-actions, .ba-form-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.ba-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 16px; border-radius: 999px; border: 1px solid var(--ba-line); background: #fff; color: var(--ba-text); font-size: 14px; font-weight: 950; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.ba-btn:hover { transform: translateY(-1px); border-color: rgba(37,99,235,.28); box-shadow: 0 12px 24px rgba(15,23,42,.08); }
.ba-btn-primary { border-color: transparent; color: #fff; background: linear-gradient(135deg, var(--ba-primary), var(--ba-primary-dark)); box-shadow: 0 14px 24px rgba(37,99,235,.22); }
.ba-btn-danger { border-color: rgba(220,38,38,.18); color: var(--ba-red); background: var(--ba-red-soft); }
.ba-btn-small { min-height: 34px; padding: 0 12px; font-size: 12px; }

.ba-alert { margin-top: 18px; padding: 16px 18px; border-radius: 18px; border: 1px solid var(--ba-line); background: #fff; box-shadow: var(--ba-shadow-soft); line-height: 1.6; }
.ba-alert ul { margin: 8px 0 0; padding-left: 20px; }
.ba-alert-success { border-color: rgba(22,163,74,.22); background: var(--ba-green-soft); color: #166534; }
.ba-alert-error { border-color: rgba(220,38,38,.22); background: var(--ba-red-soft); color: #991b1b; }
.ba-debug { margin-top: 18px; padding: 18px; border-radius: 22px; background: #111827; color: #d1fae5; overflow-x: auto; box-shadow: var(--ba-shadow); }
.ba-debug pre { margin: 0; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; }

.ba-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.ba-dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.ba-stat-card, .ba-dashboard-card { position: relative; padding: 20px; border: 1px solid var(--ba-line); background: rgba(255,255,255,.92); border-radius: 23px; box-shadow: var(--ba-shadow-soft); overflow: hidden; }
.ba-stat-card::before, .ba-dashboard-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--ba-primary), rgba(37,99,235,.1)); }
.ba-stat-card span, .ba-dashboard-card span { display: block; color: var(--ba-muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .055em; }
.ba-stat-card strong, .ba-dashboard-card strong { display: block; margin-top: 8px; font-size: 32px; line-height: 1; letter-spacing: -.045em; }
.ba-dashboard-card p { margin: 10px 0 16px; color: var(--ba-muted); line-height: 1.55; }

.ba-card { margin-top: 18px; border: 1px solid var(--ba-line); background: rgba(255,255,255,.94); border-radius: 26px; box-shadow: var(--ba-shadow); overflow: hidden; }
.ba-filter-card, .ba-form-card { padding: 20px; }
.ba-filter-grid { display: grid; grid-template-columns: 1.5fr repeat(4, minmax(140px, .75fr)) auto; gap: 12px; align-items: end; }
.ba-field span { display: block; margin-bottom: 7px; color: #334155; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.ba-field input, .ba-field select, .ba-field textarea { width: 100%; border: 1px solid var(--ba-line); border-radius: 15px; background: #fff; color: var(--ba-text); padding: 0 13px; outline: none; font-size: 14px; transition: border-color .18s ease, box-shadow .18s ease; }
.ba-field input, .ba-field select { height: 46px; }
.ba-field textarea { padding-top: 12px; min-height: 140px; resize: vertical; }
.ba-field input:focus, .ba-field select:focus, .ba-field textarea:focus { border-color: rgba(37,99,235,.55); box-shadow: 0 0 0 4px rgba(37,99,235,.10); }
.ba-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ba-field.is-wide { grid-column: 1 / -1; }
.ba-form-actions { justify-content: flex-start; margin-top: 18px; }
.ba-card-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--ba-line); background: linear-gradient(180deg, #fff, #f8fafc); }
.ba-card-head h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.ba-card-head p { margin: 4px 0 0; color: var(--ba-muted); font-size: 13px; }
.ba-table-wrap { overflow-x: auto; }
.ba-table { width: 100%; min-width: 1180px; border-collapse: collapse; }
.ba-table th { padding: 14px 16px; background: #f8fafc; border-bottom: 1px solid var(--ba-line); color: #475569; font-size: 12px; text-align: left; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.ba-table td { padding: 14px 16px; border-bottom: 1px solid var(--ba-line-soft); vertical-align: middle; font-size: 14px; }
.ba-table tr:hover td { background: #fbfdff; }
.ba-record-cell { display: flex; align-items: center; gap: 13px; min-width: 300px; }
.ba-record-thumb { width: 54px; height: 54px; flex: 0 0 54px; display: grid; place-items: center; border: 1px solid var(--ba-line); border-radius: 17px; background: linear-gradient(135deg, #f1f5f9, #fff); overflow: hidden; color: #64748b; font-size: 21px; font-weight: 950; }
.ba-record-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 5px; }
.ba-record-cell strong { display: block; max-width: 430px; color: var(--ba-text); font-size: 14px; line-height: 1.35; }
.ba-record-cell span { display: block; margin-top: 5px; color: var(--ba-muted); font-size: 12px; }
.ba-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--ba-line); background: #f8fafc; color: #475569; font-size: 12px; font-weight: 900; white-space: nowrap; }
.ba-badge.is-good { border-color: rgba(22,163,74,.20); background: var(--ba-green-soft); color: #166534; }
.ba-badge.is-warn { border-color: rgba(217,119,6,.22); background: var(--ba-amber-soft); color: #92400e; }
.ba-badge.is-bad { border-color: rgba(220,38,38,.22); background: var(--ba-red-soft); color: #991b1b; }
.ba-badge.is-muted { background: #f1f5f9; color: #64748b; }
.ba-row-actions form { margin: 0; }
.ba-pagination { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 18px 22px; background: #fff; color: var(--ba-muted); font-size: 13px; }
.ba-page-link { min-width: 38px; height: 38px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--ba-line); border-radius: 12px; background: #fff; color: var(--ba-text); font-size: 13px; font-weight: 900; margin-left: 4px; }
.ba-page-link.is-active { border-color: transparent; background: var(--ba-primary); color: #fff; }
.ba-empty { padding: 54px 20px; text-align: center; }
.ba-empty div { width: 76px; height: 76px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 26px; background: var(--ba-primary-soft); color: var(--ba-primary); font-size: 34px; }
.ba-empty h3 { margin: 0 0 8px; font-size: 22px; letter-spacing: -.02em; }
.ba-empty p { margin: 0 auto 18px; max-width: 520px; color: var(--ba-muted); line-height: 1.7; }

@media (max-width: 1400px) {
    .ba-dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ba-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ba-filter-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 980px) {
    .ba-app { grid-template-columns: 1fr; }
    .ba-sidebar { position: fixed; inset: 0 auto 0 0; width: 290px; transform: translateX(-105%); transition: transform .2s ease; z-index: 60; }
    body.ba-sidebar-open .ba-sidebar { transform: translateX(0); }
    .ba-menu-btn { display: inline-grid; place-items: center; }
    .ba-content { width: min(100% - 22px, 1800px); }
    .ba-hero { grid-template-columns: 1fr; }
    .ba-hero-actions { justify-content: flex-start; }
}
@media (max-width: 780px) {
    .ba-topbar, .ba-card-head, .ba-pagination { align-items: flex-start; flex-direction: column; }
    .ba-dashboard-grid, .ba-stats-grid, .ba-filter-grid, .ba-form-grid { grid-template-columns: 1fr; }
    .ba-hero { padding: 22px; border-radius: 24px; }
    .ba-topbar-actions { justify-content: flex-start; }
}
