/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: #f1f5f9; color: #1e293b; min-height: 100vh; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Layout === */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #1e293b; color: #cbd5e1; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.sidebar-header { padding: 20px 16px; border-bottom: 1px solid #334155; }
.sidebar-header h2 { font-size: 1rem; font-weight: 700; color: #f8fafc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: #94a3b8; font-size: .9rem; font-weight: 500; transition: background .15s, color .15s; text-decoration: none; }
.nav-item:hover { background: #334155; color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: #2563eb; color: #fff; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid #334155; font-size: .8rem; }
.sidebar-user { display: block; color: #94a3b8; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-link { font-size: .8rem; padding: 6px 0; color: #ef4444 !important; }
.logout-link:hover { color: #f87171 !important; }

.main-content { margin-left: 240px; flex: 1; min-height: 100vh; }
.page-header { background: #fff; padding: 20px 30px; border-bottom: 1px solid #e2e8f0; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; color: #0f172a; }
.page-body { padding: 24px 30px; }

/* === Cards === */
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 1rem; font-weight: 600; color: #334155; margin-bottom: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 16px 20px; }
.stat-label { font-size: .8rem; font-weight: 500; color: #64748b; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #0f172a; margin-top: 4px; }

/* === Tables === */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #e2e8f0; }
th { font-size: .8rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .5px; background: #f8fafc; }
td { font-size: .9rem; }
tr:hover td { background: #f8fafc; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #94a3b8; }
.text-sm { font-size: .8rem; }

/* === Badges === */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.reconciled-ok { color: #16a34a; font-weight: 700; }
.reconciled-ko { color: #dc2626; font-weight: 700; }

/* === Buttons === */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 6px; font-size: .85rem; font-weight: 600; font-family: inherit; cursor: pointer; transition: background .15s; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; color: #475569; margin-bottom: 4px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .9rem; font-family: inherit; background: #fff; color: #1e293b; }
.form-control:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
select.form-control { appearance: auto; }
.form-inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* === Alerts === */
.alert { padding: 12px 20px; border-radius: 6px; margin: 0 30px 0 30px; font-size: .9rem; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* === Pagination === */
.pagination { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 20px; padding: 12px 0; }
.pagination-btn { padding: 6px 14px; background: #e2e8f0; color: #334155; border-radius: 6px; font-size: .85rem; font-weight: 500; }
.pagination-btn:hover { background: #cbd5e1; text-decoration: none; }
.pagination-info { font-size: .85rem; color: #64748b; }

/* === Filters === */
.filters-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.filters-bar .form-group { margin-bottom: 0; min-width: 140px; }
.filters-bar .form-control { font-size: .85rem; padding: 6px 10px; }
.filters-bar .btn { align-self: flex-end; }

/* === Detail page === */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.detail-item { }
.detail-label { font-size: .8rem; font-weight: 500; color: #64748b; text-transform: uppercase; letter-spacing: .3px; }
.detail-value { font-size: 1rem; font-weight: 600; color: #0f172a; margin-top: 2px; }

/* === Login page === */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f1f5f9; }
.login-card { background: #fff; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,.08); max-width: 400px; width: 100%; padding: 40px; }
.login-card h1 { font-size: 1.3rem; font-weight: 700; color: #0f172a; margin-bottom: 4px; text-align: center; }
.login-card .subtitle { color: #64748b; text-align: center; margin-bottom: 24px; font-size: .9rem; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.login-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: .85rem; text-align: center; }

/* === Misc === */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state p { font-size: 1rem; }
.loading { text-align: center; padding: 40px; color: #94a3b8; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h2, .sidebar-nav .nav-item span:not(.nav-icon), .sidebar-user { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .main-content { margin-left: 60px; }
    .page-body { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; }
}
