:root {
  --af-primary: #2563eb;
  --af-primary-dark: #1d4ed8;
  --af-sidebar: #0f172a;
  --af-bg: #f5f7fb;
  --af-border: #e5e7eb;
  --af-text: #172033;
  --af-muted: #667085;
  --af-radius: 16px;
  --af-shadow: 0 8px 30px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--af-bg); color: var(--af-text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--af-primary); }
.min-w-0 { min-width: 0; }

.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { background: var(--af-primary); border-color: var(--af-primary); box-shadow: 0 6px 16px rgba(37, 99, 235, .18); }
.btn-primary:hover, .btn-primary:focus { background: var(--af-primary-dark); border-color: var(--af-primary-dark); }
.btn-light { background: #fff; border-color: var(--af-border); color: #344054; }
.btn-light:hover { background: #f8fafc; border-color: #d0d5dd; }
.btn-icon { width: 42px; height: 42px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.form-control, .form-select, .input-group-text { border-color: #d8dee9; border-radius: 10px; min-height: 44px; }
.form-control:focus, .form-select:focus { border-color: #8cb2ff; box-shadow: 0 0 0 .22rem rgba(37, 99, 235, .12); }
.input-group > .form-control { border-radius: 0 10px 10px 0; }
.input-group > .input-group-text { border-radius: 10px 0 0 10px; background: #f8fafc; }
.form-label { color: #344054; font-size: .88rem; font-weight: 650; margin-bottom: .45rem; }
.form-label.required::after { content: " *"; color: #dc2626; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; padding: 24px 18px; background: var(--af-sidebar); color: #fff; z-index: 1030; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-size: 1.1rem; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--af-primary); color: white; box-shadow: 0 6px 15px rgba(37, 99, 235, .26); }
.brand-mark-light { background: rgba(255,255,255,.16); box-shadow: none; }
.sidebar-nav { margin-top: 38px; }
.nav-section { padding: 0 12px 10px; color: #64748b; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .11em; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 12px; margin: 4px 0; padding: 11px 12px; border-radius: 11px; color: #9ca9bc; font-weight: 600; transition: .18s ease; }
.sidebar-nav .nav-link i { width: 20px; font-size: 1.05rem; }
.sidebar-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav .nav-link.active { color: #fff; background: linear-gradient(135deg, rgba(37,99,235,.95), rgba(59,130,246,.72)); box-shadow: 0 8px 18px rgba(37,99,235,.2); }
.sidebar-footer { margin-top: auto; padding: 18px 14px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.07); border-radius: 14px; }
.mobile-sidebar .offcanvas-body { background: #f8fafc; }
.mobile-nav { margin-top: 0; }
.mobile-nav .nav-link { color: #475467; }
.mobile-nav .nav-link.active { color: #fff; }

.main-area { margin-left: 260px; min-height: 100vh; }
.topbar { height: 72px; display: flex; align-items: center; padding: 0 34px; background: rgba(255,255,255,.88); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(229,231,235,.9); position: sticky; top: 0; z-index: 1020; }
.avatar { width: 30px; height: 30px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: #e8efff; color: var(--af-primary); font-weight: 800; }
.avatar-soft { width: 40px; height: 40px; background: #edf3ff; }
.content-area { padding: 30px 34px 46px; max-width: 1600px; margin: 0 auto; }
.flash-stack { position: fixed; right: 24px; top: 88px; width: min(430px, calc(100vw - 48px)); z-index: 1080; }
.flash-stack .alert { border: 0; border-radius: 12px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 22px; margin-bottom: 26px; }
.page-header.compact { align-items: flex-start; }
.page-header h1 { margin: 3px 0 5px; font-size: clamp(1.75rem, 2.4vw, 2.35rem); line-height: 1.16; font-weight: 800; letter-spacing: -.035em; }
.page-header p { margin: 0; color: var(--af-muted); }
.eyebrow { color: var(--af-primary); font-size: .7rem; font-weight: 800; letter-spacing: .12em; }
.back-link { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 10px; color: var(--af-muted); text-decoration: none; font-weight: 650; font-size: .88rem; }
.back-link:hover { color: var(--af-primary); }

.stat-card, .panel-card, .project-card, .invoice-paper { background: #fff; border: 1px solid var(--af-border); border-radius: var(--af-radius); box-shadow: var(--af-shadow); }
.stat-card { padding: 20px; min-height: 154px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 96px; height: 96px; border-radius: 50%; right: -40px; top: -42px; background: #f8fafc; }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; margin-bottom: 15px; }
.stat-label { color: var(--af-muted); font-size: .82rem; font-weight: 650; }
.stat-value { margin-top: 4px; font-size: 1.45rem; font-weight: 800; letter-spacing: -.03em; }
.stat-foot { margin-top: 9px; font-size: .75rem; font-weight: 600; }
.panel-card { overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 20px 22px; border-bottom: 1px solid var(--af-border); }
.panel-header h2 { margin: 0; font-size: 1rem; font-weight: 800; }
.panel-header p { margin: 3px 0 0; color: var(--af-muted); font-size: .8rem; }
.panel-toolbar { min-height: 66px; padding: 12px 18px; border-bottom: 1px solid var(--af-border); display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.search-form { min-width: min(430px, 70vw); display: flex; align-items: center; gap: 10px; padding: 0 13px; background: #f8fafc; border: 1px solid var(--af-border); border-radius: 10px; }
.search-form input { width: 100%; height: 40px; border: 0; outline: 0; background: transparent; }
.search-form i { color: #98a2b3; }
.app-table { --bs-table-bg: transparent; }
.app-table thead th { padding: 13px 18px; background: #f8fafc; color: #667085; font-size: .7rem; text-transform: uppercase; letter-spacing: .055em; border-bottom-color: var(--af-border); white-space: nowrap; }
.app-table tbody td { padding: 16px 18px; border-color: #edf0f4; font-size: .88rem; }
.app-table tbody tr:last-child td { border-bottom: 0; }
.app-table tbody tr:hover { background: #fbfcff; }
.empty-state { text-align: center; color: var(--af-muted); }
.empty-state i { display: block; margin-bottom: 10px; color: #98a2b3; font-size: 2rem; }
.empty-state h3 { color: var(--af-text); font-size: 1rem; font-weight: 750; }
.empty-state p { margin-bottom: 13px; }
.count-pill, .category-chip { display: inline-flex; min-width: 30px; align-items: center; justify-content: center; padding: 4px 9px; border-radius: 999px; background: #f2f4f7; color: #475467; font-size: .76rem; font-weight: 700; }

.status-badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: .7rem; font-weight: 800; text-transform: capitalize; white-space: nowrap; }
.status-unpaid, .status-draft { background: #f2f4f7; color: #475467; }
.status-partial, .status-waiting { background: #fff7e6; color: #b54708; }
.status-paid, .status-done { background: #ecfdf3; color: #027a48; }
.status-overdue, .status-cancelled { background: #fef3f2; color: #b42318; }
.status-active { background: #eff4ff; color: #1d4ed8; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; width: fit-content; border: 1px solid var(--af-border); border-radius: 12px; background: #fff; }
.filter-tabs a { padding: 7px 12px; color: #667085; border-radius: 8px; text-decoration: none; font-size: .8rem; font-weight: 700; }
.filter-tabs a.active, .filter-tabs a:hover { color: var(--af-primary); background: #eff4ff; }

.deadline-list { padding: 8px 15px 15px; }
.deadline-item { display: flex; align-items: center; gap: 13px; padding: 12px 6px; color: inherit; text-decoration: none; border-bottom: 1px solid #eef1f5; }
.deadline-item:last-child { border-bottom: 0; }
.deadline-date { width: 46px; height: 52px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #eff4ff; color: var(--af-primary); }
.deadline-date strong { font-size: 1rem; line-height: 1; }
.deadline-date span { font-size: .68rem; text-transform: uppercase; margin-top: 4px; }

.form-layout { max-width: 1040px; }
.form-card { padding: 24px; margin-bottom: 18px; }
.section-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-size: 1rem; font-weight: 800; }
.section-heading p { margin: 3px 0 0; color: var(--af-muted); font-size: .8rem; }
.section-icon { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; background: #eff4ff; color: var(--af-primary); display: inline-flex; align-items: center; justify-content: center; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 4px; }

.project-card { padding: 20px; height: 100%; }
.project-card h2 { margin: 18px 0 8px; font-size: 1.05rem; font-weight: 800; }
.project-client { display: flex; align-items: center; gap: 7px; color: #475467; font-size: .82rem; }
.project-desc { min-height: 44px; color: var(--af-muted); font-size: .82rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 15px; border-top: 1px solid #edf0f4; }
.project-meta div { display: flex; flex-direction: column; gap: 3px; }
.project-meta span { color: var(--af-muted); font-size: .7rem; }
.project-meta strong { font-size: .82rem; }

.invoice-items { display: flex; flex-direction: column; gap: 12px; }
.invoice-item-row { display: grid; grid-template-columns: minmax(250px, 2fr) 90px minmax(150px, 1fr) minmax(150px, 1fr) 42px; gap: 10px; align-items: end; padding: 14px; border: 1px solid var(--af-border); border-radius: 13px; background: #fbfcfe; }
.item-total-display { display: flex; align-items: center; background: #f5f7fa; font-weight: 700; color: #344054; }
.item-remove-wrap { padding-bottom: 1px; }
.invoice-summary-preview { margin: 22px 0 0 auto; width: min(390px, 100%); }
.invoice-summary-preview > div { display: flex; justify-content: space-between; padding: 7px 0; font-size: .86rem; }
.invoice-summary-preview span { color: var(--af-muted); }
.invoice-summary-preview .grand-total { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--af-border); font-size: 1rem; }
.invoice-summary-preview .grand-total strong { color: var(--af-primary); }

.invoice-paper { padding: clamp(24px, 4vw, 44px); }
.invoice-paper-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 30px; border-bottom: 1px solid var(--af-border); }
.invoice-label { font-size: clamp(1.8rem, 4vw, 2.65rem); line-height: 1; color: var(--af-primary); font-weight: 850; letter-spacing: -.04em; }
.invoice-parties { display: grid; grid-template-columns: 1.25fr .75fr; gap: 30px; padding: 30px 0; }
.invoice-parties span, .invoice-notes span, .invoice-payment-info span { display: block; margin-bottom: 7px; color: #98a2b3; font-size: .65rem; font-weight: 800; letter-spacing: .08em; }
.invoice-parties strong { display: block; margin-bottom: 4px; font-size: .95rem; }
.invoice-parties p { white-space: pre-line; color: var(--af-muted); font-size: .82rem; }
.invoice-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.invoice-table thead th { padding: 12px 10px; background: #172033; color: #fff; border: 0; font-size: .72rem; }
.invoice-table tbody td { padding: 15px 10px; border-color: #edf0f4; font-size: .85rem; }
.invoice-totals { width: min(420px, 100%); margin: 15px 0 0 auto; }
.invoice-totals > div { display: flex; justify-content: space-between; padding: 7px 0; font-size: .86rem; }
.invoice-totals span { color: var(--af-muted); }
.invoice-totals .total { margin-top: 4px; padding-top: 13px; border-top: 1px solid var(--af-border); font-size: 1rem; }
.invoice-totals .balance { margin-top: 5px; padding: 12px 14px; border-radius: 10px; background: #eff4ff; color: var(--af-primary); }
.invoice-totals .balance span { color: #4568a8; }
.invoice-notes { margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--af-border); }
.invoice-notes p { white-space: pre-line; color: var(--af-muted); font-size: .82rem; }
.invoice-payment-info { display: flex; gap: 12px; align-items: center; margin-top: 20px; padding: 14px; background: #f8fafc; border: 1px solid var(--af-border); border-radius: 12px; }
.invoice-payment-info i { color: var(--af-primary); font-size: 1.2rem; }
.invoice-payment-info span { margin-bottom: 2px; }
.invoice-payment-info strong { font-size: .8rem; }
.summary-list { padding: 14px 20px 20px; }
.summary-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid #eef1f5; font-size: .84rem; }
.summary-list > div:last-child { border-bottom: 0; }
.summary-list span { color: var(--af-muted); }
.payment-list { padding: 8px 16px 16px; }
.payment-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #eef1f5; }
.payment-item:last-child { border-bottom: 0; }
.payment-icon { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #ecfdf3; color: #027a48; }

.chart-card { padding-bottom: 14px; }
.chart-wrap { height: 340px; padding: 18px 20px 6px; }
.chart-wrap-small { height: 340px; }
.error-page { padding: 12vh 20px; text-align: center; }
.error-code { color: #dbe7ff; font-size: clamp(5rem, 15vw, 10rem); line-height: .85; font-weight: 900; }
.error-page h1 { margin-top: 20px; font-weight: 800; }
.error-page p { color: var(--af-muted); }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: #fff; }
.auth-visual { align-items: center; padding: 70px; color: #fff; background: radial-gradient(circle at 20% 10%, rgba(74,128,255,.38), transparent 35%), linear-gradient(145deg, #111d39, #0f172a 55%, #172554); overflow: hidden; position: relative; }
.auth-visual::after { content: ""; position: absolute; width: 480px; height: 480px; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; right: -180px; bottom: -220px; box-shadow: 0 0 0 80px rgba(255,255,255,.025), 0 0 0 160px rgba(255,255,255,.02); }
.auth-visual-content { max-width: 650px; position: relative; z-index: 1; }
.auth-feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.auth-feature-grid > div { display: flex; align-items: center; gap: 9px; color: #dbe4f3; }
.auth-feature-grid i { color: #78a5ff; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-form-card { width: min(440px, 100%); }
.auth-form-card h2 { letter-spacing: -.025em; }
.demo-note { display: flex; align-items: flex-start; gap: 9px; padding: 12px 14px; background: #f8fafc; border: 1px solid var(--af-border); border-radius: 11px; color: #667085; font-size: .78rem; }

@media (max-width: 1199.98px) {
  .invoice-item-row { grid-template-columns: minmax(220px, 2fr) 80px minmax(130px, 1fr) minmax(130px, 1fr) 42px; }
}
@media (max-width: 991.98px) {
  .main-area { margin-left: 0; }
  .topbar { padding: 0 20px; }
  .content-area { padding: 24px 20px 40px; }
  .auth-page { grid-template-columns: 1fr; }
  .page-header { align-items: flex-start; }
}
@media (max-width: 767.98px) {
  .page-header { flex-direction: column; }
  .page-header > div:last-child, .page-header > a.btn { width: 100%; }
  .page-header > a.btn { text-align: center; }
  .invoice-item-row { grid-template-columns: 1fr 1fr; }
  .item-description { grid-column: 1 / -1; }
  .item-remove-wrap { position: absolute; right: 12px; margin-top: -54px; }
  .invoice-item-row { position: relative; padding-top: 18px; }
  .invoice-parties { grid-template-columns: 1fr; }
  .invoice-paper-header { flex-direction: column; }
  .invoice-paper-header .text-end { text-align: left !important; }
  .auth-form-wrap { padding: 28px 20px; }
  .form-card { padding: 18px; }
  .panel-toolbar { align-items: stretch; flex-direction: column; }
  .search-form { min-width: 100%; }
}
@media (max-width: 480px) {
  .content-area { padding-left: 14px; padding-right: 14px; }
  .invoice-item-row { grid-template-columns: 1fr; }
  .item-description { grid-column: auto; }
  .project-meta { grid-template-columns: 1fr; }
  .invoice-dates { grid-template-columns: 1fr; }
  .auth-feature-grid { grid-template-columns: 1fr; }
}
