:root {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: #172033;
    background: #f3f6fa;
    font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f3f6fa; color: #172033; }
a { color: #155fa0; text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { background: #102a43; color: white; padding: 24px 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.15); }
.brand-mark, .login-brand { width: 46px; height: 46px; border-radius: 12px; background: #dbeafe; color: #102a43; display: grid; place-items: center; font-weight: 800; }
.brand strong { display: block; font-size: 16px; }
.brand span { display: block; font-size: 12px; color: #bdd1e4; margin-top: 4px; }
.nav-menu { margin-top: 18px; display: grid; gap: 6px; }
.nav-menu a { color: #d8e8f6; padding: 11px 13px; border-radius: 8px; font-weight: 600; }
.nav-menu a:hover, .nav-menu a.active { background: #1d4f75; color: white; text-decoration: none; }

.main-content { min-width: 0; }
.topbar { height: 68px; background: white; border-bottom: 1px solid #e3e8ef; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; position: sticky; top: 0; z-index: 10; }
.topbar-title { font-weight: 700; }
.user-box { display: flex; gap: 14px; align-items: center; font-size: 14px; }
.page-content { padding: 28px 30px 48px; }
h1 { margin: 0 0 6px; font-size: 28px; }
h2 { margin: 0; font-size: 18px; }
.page-subtitle { margin: 0 0 24px; color: #64748b; }
.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 20px; }
.page-heading .page-subtitle { margin-bottom: 0; }

.btn { border: 1px solid #cbd5e1; background: white; color: #172033; border-radius: 7px; padding: 9px 14px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: #155fa0; border-color: #155fa0; color: white; }
.btn-primary:hover { background: #0f4f89; }
.btn-danger { color: #b42318; border-color: #fecaca; }
.btn-small { padding: 6px 9px; font-size: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: white; border: 1px solid #e2e8f0; border-radius: 12px; padding: 18px; }
.stat-card span { display: block; color: #64748b; font-size: 13px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 28px; }
.stat-card.danger { border-left: 4px solid #dc2626; }
.stat-card.success { border-left: 4px solid #16a34a; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel, .form-panel { background: white; border: 1px solid #e2e8f0; border-radius: 12px; }
.panel { overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid #e2e8f0; }
.table-panel { margin-top: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #edf1f5; vertical-align: top; font-size: 13px; }
th { background: #f8fafc; color: #475569; font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: #fbfdff; }
.summary-cell { min-width: 260px; max-width: 480px; }
.actions { white-space: nowrap; display: flex; gap: 6px; }
.empty-cell { text-align: center; color: #64748b; padding: 30px; }
.row-overdue { background: #fff7f7; }

.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-neutral { background: #e8eef5; color: #334155; }
.status-success { background: #dcfce7; color: #166534; }
.status-warning { background: #fef3c7; color: #92400e; }
.status-danger { background: #fee2e2; color: #991b1b; }

.filter-bar { display: flex; gap: 10px; margin: 16px 0; }
.filter-bar input { flex: 1; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 7px; padding: 10px 11px; font: inherit; color: #172033; background: white; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: #3b82f6; }
.form-panel { padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 13px; font-weight: 700; color: #334155; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid #e2e8f0; }
.validation-message, .validation-summary { color: #b42318; font-size: 12px; }

.catalog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 16px; }
.stack-form { display: grid; gap: 8px; padding: 16px; }
.catalog-list { list-style: none; margin: 0; padding: 0 16px 16px; }
.catalog-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid #edf1f5; }
.catalog-list small { display: block; color: #64748b; margin-top: 3px; }
.user-create-panel { padding: 20px; margin-bottom: 18px; }
.user-create-panel h2 { margin-bottom: 16px; }
.form-message { margin-left: 12px; color: #166534; font-weight: 600; }

.loading, .empty-state, .auth-message { background: white; border: 1px solid #e2e8f0; padding: 30px; border-radius: 12px; text-align: center; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #e8f0f8, #f8fafc); }
.login-card { width: min(420px, 100%); background: white; border: 1px solid #dce3eb; border-radius: 16px; padding: 30px; box-shadow: 0 20px 60px rgba(15, 42, 67, .12); }
.login-card h1 { margin-top: 16px; font-size: 24px; }
.login-card p { color: #64748b; margin: 6px 0 22px; }
.login-card form { display: grid; gap: 9px; }
.login-card label { font-weight: 700; font-size: 13px; margin-top: 6px; }
.login-button { margin-top: 12px; width: 100%; }

@media (max-width: 1200px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .catalog-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 850px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .nav-menu { grid-template-columns: repeat(2, 1fr); }
    .topbar { position: static; padding: 0 18px; }
    .page-content { padding: 20px 16px 36px; }
    .stat-grid, .panel-grid, .catalog-grid, .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .page-heading, .filter-bar { flex-direction: column; }
    .filter-bar > * { width: 100%; }
}
