/* ── Reset & base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; background: #f4f6f8; color: #1a1a2e; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ── Login ──────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #1a1a2e; }
.login-box { background: #fff; border-radius: 12px; padding: 40px; width: 360px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.login-box h1 { font-size: 26px; text-align: center; color: #1a1a2e; margin-bottom: 6px; }
.login-box input { padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; }
.login-box input:focus { outline: none; border-color: #4f6ef7; }

/* ── Layout ─────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

#sidebar { width: 200px; min-width: 200px; background: #1a1a2e; color: #c8d0e7; display: flex; flex-direction: column; padding: 0; }
.logo { font-size: 20px; font-weight: 700; color: #fff; padding: 20px 20px 10px; letter-spacing: 1px; }

#biz-selector-wrap select { width: calc(100% - 24px); margin: 0 12px 8px; padding: 6px 8px; background: #2a2a4a; border: 1px solid #3a3a5a; color: #c8d0e7; border-radius: 4px; font-size: 12px; }

#sidebar ul { list-style: none; flex: 1; }
#sidebar ul li a { display: block; padding: 11px 20px; transition: background .15s; font-size: 13px; }
#sidebar ul li a:hover,
#sidebar ul li a.active { background: #2e3462; color: #fff; }

.nav-footer { padding: 16px 20px; font-size: 12px; border-top: 1px solid #2a2a4a; }
#nav-user-name { display: block; color: #8890b0; margin-bottom: 6px; }
.btn-link { background: none; border: none; color: #7a8fd4; font-size: 12px; padding: 0; }
.btn-link:hover { color: #fff; }

#page-content { flex: 1; padding: 28px 32px; overflow-y: auto; max-height: 100vh; }

/* ── Page header ────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 22px; font-weight: 600; }
.page-actions { display: flex; gap: 10px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary { background: #4f6ef7; color: #fff; border: none; padding: 9px 18px; border-radius: 6px; font-weight: 600; }
.btn-primary:hover { background: #3d5ce5; }
.btn-secondary { background: #e8ebf5; color: #1a1a2e; border: none; padding: 9px 18px; border-radius: 6px; }
.btn-secondary:hover { background: #d0d6ee; }
.btn-danger { background: #e74c3c; color: #fff; border: none; padding: 7px 14px; border-radius: 6px; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 4px; }

/* ── Search bar ─────────────────────────────────────────── */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-bar input, .search-bar select { padding: 8px 12px; border: 1px solid #dde2f0; border-radius: 6px; background: #fff; min-width: 180px; }
.search-bar input:focus, .search-bar select:focus { outline: none; border-color: #4f6ef7; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #f0f2fa; padding: 11px 14px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #5a6080; border-bottom: 1px solid #e0e4f0; }
tbody td { padding: 11px 14px; border-bottom: 1px solid #f0f2fa; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f9fd; }

/* ── Status badges ──────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-draft     { background: #f0f2fa; color: #666; }
.badge-sent      { background: #e0f0ff; color: #1a6fb5; }
.badge-paid      { background: #e0f9ed; color: #1a8a4a; }
.badge-overdue   { background: #fff0f0; color: #cc3333; }
.badge-cancelled { background: #f5f5f5; color: #999; }

/* ── Modal / drawer ─────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: flex; align-items: flex-start; justify-content: flex-end; }
.drawer { background: #fff; width: 520px; max-width: 95vw; height: 100vh; overflow-y: auto; padding: 28px 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: -4px 0 20px rgba(0,0,0,.15); }
.drawer h3 { font-size: 18px; margin-bottom: 4px; }
.drawer-actions { display: flex; gap: 10px; margin-top: auto; padding-top: 16px; border-top: 1px solid #f0f2fa; }

/* ── Form fields ────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: #5a6080; }
.field input, .field select, .field textarea { padding: 9px 12px; border: 1px solid #dde2f0; border-radius: 6px; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: #4f6ef7; }
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ── Multi-entry (phones, emails) ───────────────────────── */
.multi-entry { display: flex; flex-direction: column; gap: 6px; }
.multi-entry-row { display: flex; gap: 8px; align-items: center; }
.multi-entry-row input { flex: 1; padding: 7px 10px; border: 1px solid #dde2f0; border-radius: 5px; }
.multi-entry-row button { padding: 6px 10px; }
.add-row-btn { background: none; border: 1px dashed #aab; color: #667; border-radius: 5px; padding: 5px 12px; font-size: 12px; }
.add-row-btn:hover { background: #f0f2fa; }

/* ── Invoice line items table ───────────────────────────── */
.line-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.line-table th { background: #f0f2fa; padding: 7px 8px; text-align: left; font-size: 11px; }
.line-table td { padding: 5px 4px; border-bottom: 1px solid #f0f2fa; }
.line-table input { padding: 5px 6px; border: 1px solid #dde2f0; border-radius: 4px; width: 100%; }
.line-table .col-code  { width: 80px; }
.line-table .col-qty   { width: 55px; }
.line-table .col-price { width: 90px; }
.line-table .col-amt   { width: 90px; text-align: right; font-weight: 600; }
.line-table .col-del   { width: 36px; text-align: center; }

/* ── Totals bar ─────────────────────────────────────────── */
.totals-bar { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-top: 8px; }
.totals-bar .total-row { display: flex; gap: 16px; font-size: 13px; }
.totals-bar .total-row span:first-child { color: #666; }
.totals-bar .grand { font-weight: 700; font-size: 15px; }

/* ── Error / info messages ──────────────────────────────── */
.error-msg { background: #fff0f0; color: #cc3333; padding: 9px 14px; border-radius: 6px; font-size: 13px; }
.info-msg  { background: #e8f4ff; color: #1a5fa0; padding: 9px 14px; border-radius: 6px; font-size: 13px; }
.success-msg { background: #e8fdf0; color: #1a7a45; padding: 9px 14px; border-radius: 6px; font-size: 13px; }

/* ── Notes flag ─────────────────────────────────────────── */
.note-flag { display: inline-block; width: 8px; height: 8px; background: #f7c94b; border-radius: 50%; margin-left: 5px; vertical-align: middle; }

/* ── Statement ──────────────────────────────────────────── */
.statement-header { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.balance-positive { color: #cc3333; font-weight: 700; }
.balance-zero     { color: #1a8a4a; font-weight: 700; }
