/* ── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: #111827; background: #f7f8fa; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Login ───────────────────────────────────────────────────────────── */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f7f8fa; }
.login-box { background: #fff; border: 1px solid #e5e7eb; border-radius: 16px; padding: 40px; width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,.06); }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-sub { color: #6b7280; font-size: 13px; margin-bottom: 28px; }
.login-error { color: #dc2626; font-size: 13px; margin-bottom: 12px; background: #fef2f2; border-radius: 6px; padding: 8px 12px; }
.btn-full { width: 100%; justify-content: center; margin-top: 4px; }

/* ── Navbar ──────────────────────────────────────────────────────────── */
.navbar { background: #111827; height: 52px; display: flex; align-items: center; position: sticky; top: 0; z-index: 100; }
.nav-inner { max-width: 1400px; width: 100%; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; }
.nav-brand { color: #fff; display: flex; align-items: center; flex-shrink: 0; }
.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-link { color: #9ca3af; padding: 6px 12px; border-radius: 6px; font-size: 14px; transition: color .15s, background .15s; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-link.active { color: #fff; }
.nav-signout { background: none; border: none; color: #9ca3af; cursor: pointer; padding: 6px; border-radius: 6px; display: flex; align-items: center; transition: color .15s; margin-left: auto; }
.nav-signout:hover { color: #fff; }

/* ── Main ────────────────────────────────────────────────────────────── */
.main-content { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ── Page layout ─────────────────────────────────────────────────────── */
.page-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.list-panel { background: #fff; border-radius: 12px; border: 1px solid #e5e7eb; overflow: hidden; }
.detail-panel { background: #fff; border-radius: 12px; border: 1px solid #e5e7eb; padding: 24px; min-height: 300px; }
.detail-placeholder h3 { font-size: 16px; margin-bottom: 8px; }
.detail-placeholder p { color: #6b7280; font-size: 13px; line-height: 1.5; }

/* ── List header ─────────────────────────────────────────────────────── */
.list-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 20px 0; gap: 12px; flex-wrap: wrap; }
.list-title { font-size: 20px; font-weight: 700; }
.invoice-count { font-size: 12px; color: #9ca3af; display: block; margin-top: 2px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── Tabs ────────────────────────────────────────────────────────────── */
.filter-tabs { display: flex; padding: 12px 20px 0; border-bottom: 1px solid #e5e7eb; gap: 2px; }
.tab { padding: 8px 14px; font-size: 13px; color: #6b7280; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: color .15s; background: none; border-top: none; border-left: none; border-right: none; }
.tab:hover { color: #111; }
.tab.active { color: #059669; border-bottom-color: #059669; font-weight: 600; }

/* ── Invoice table ───────────────────────────────────────────────────── */
.invoice-table { width: 100%; border-collapse: collapse; }
.invoice-table th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; color: #6b7280; letter-spacing: .05em; text-transform: uppercase; border-bottom: 1px solid #f3f4f6; }
.invoice-table td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #f3f4f6; }
.invoice-table tbody tr:last-child td { border-bottom: none; }
.inv-row:hover { background: #f9fafb; }
.inv-row.hidden { display: none; }
.month-row td { padding: 8px 16px; font-size: 11px; font-weight: 700; color: #6b7280; background: #f9fafb; text-transform: uppercase; letter-spacing: .05em; }
.table-footer { display: flex; justify-content: space-between; padding: 14px 20px; border-top: 2px solid #e5e7eb; font-weight: 700; font-size: 14px; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-created { background: #e0e7ff; color: #3730a3; }
.badge-draft { background: #f3f4f6; color: #6b7280; }

/* ── Row actions ─────────────────────────────────────────────────────── */
.row-actions { display: flex; gap: 10px; }
.action-link { color: #059669; font-size: 12px; font-weight: 500; cursor: pointer; background: none; border: none; padding: 0; }
.action-link:hover { text-decoration: underline; }
.action-danger { color: #dc2626; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary { background: #111827; color: #fff; border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn-primary:hover { background: #1f2937; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger { background: #fff; color: #dc2626; border: 1px solid #fca5a5; border-radius: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer; }
.btn-danger:hover { background: #fef2f2; }
.btn-large { padding: 10px 24px; font-size: 14px; }

/* ── Search ──────────────────────────────────────────────────────────── */
.search-input { border: 1px solid #d1d5db; border-radius: 8px; padding: 7px 12px 7px 32px; font-size: 13px; width: 200px; background: #f9fafb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center; outline: none; }
.search-input:focus { border-color: #6b7280; background-color: #fff; }

/* ── Form elements ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-input, .form-select, .form-textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 6px; padding: 8px 10px; font-size: 13px; outline: none; transition: border .15s; background: #fff; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: #6b7280; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: #9ca3af; margin-top: 4px; display: block; }
.char-count { font-weight: 400; color: #9ca3af; }

/* ── Invoice form ────────────────────────────────────────────────────── */
.invoice-form-wrap { background: #fff; border-radius: 12px; border: 1px solid #e5e7eb; overflow: hidden; }
.form-topbar { display: flex; align-items: center; gap: 16px; padding: 16px 24px; border-bottom: 1px solid #e5e7eb; }
.close-btn { color: #6b7280; font-size: 20px; line-height: 1; background: none; border: none; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.close-btn:hover { background: #f3f4f6; color: #111; }
.form-title { font-size: 18px; font-weight: 700; flex: 1; }
.form-top-actions { display: flex; gap: 8px; }
.invoice-form-body { padding: 28px 32px; }

/* ── Two-col layout ──────────────────────────────────────────────────── */
.form-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 20px; }

/* ── Customer display ────────────────────────────────────────────────── */
.address-name { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.address-line { font-size: 13px; color: #4b5563; line-height: 1.6; }

/* ── Invoice meta ────────────────────────────────────────────────────── */
.invoice-meta-block { text-align: right; }
.invoice-heading { font-size: 30px; font-weight: 800; }
.meta-grid { display: grid; grid-template-columns: auto auto; gap: 5px 16px; margin-top: 14px; justify-content: end; align-items: center; }
.meta-label { font-size: 12px; font-weight: 700; color: #374151; }
.meta-input { width: 160px; text-align: right; border: 1px solid #d1d5db; border-radius: 5px; padding: 5px 8px; font-size: 13px; }
.meta-val { font-size: 13px; }
.meta-val-wrap { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }

/* ── Line items ──────────────────────────────────────────────────────── */
.items-section { margin-top: 28px; }
.items-table { width: 100%; border-collapse: collapse; }
.items-table th { font-size: 12px; font-weight: 600; color: #6b7280; padding: 8px 8px; border-bottom: 1px solid #e5e7eb; text-align: left; }
.items-table td { padding: 5px 4px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.item-input { width: 100%; border: 1px solid transparent; border-radius: 5px; padding: 6px 8px; font-size: 13px; background: transparent; }
.item-input:focus { border-color: #d1d5db; background: #fff; outline: none; }
.item-select { border: 1px solid #d1d5db; border-radius: 5px; padding: 6px 6px; font-size: 13px; width: 100%; background: #fff; }
.item-total { text-align: right; font-size: 13px; padding-right: 8px !important; white-space: nowrap; }
.remove-item { background: none; border: none; color: #d1d5db; cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 4px; }
.remove-item:hover { color: #dc2626; background: #fef2f2; }
.btn-add-item { margin-top: 10px; background: #111827; color: #fff; border: none; border-radius: 7px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-add-item:hover { background: #1f2937; }

/* ── Totals ──────────────────────────────────────────────────────────── */
.totals-block { display: flex; justify-content: flex-end; margin-top: 20px; }
.totals-inner { width: 300px; }
.total-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; color: #374151; border-bottom: 1px solid #f3f4f6; }
.total-due { font-weight: 700; font-size: 14px; border-top: 2px solid #e5e7eb; border-bottom: none; padding-top: 10px; margin-top: 4px; }

/* ── Invoice view/preview ────────────────────────────────────────────── */
.invoice-preview { padding: 32px; }
.inv-preview-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.inv-logo-img { max-height: 56px; max-width: 180px; }
.inv-company-name { font-size: 16px; font-weight: 800; }
.inv-big-title { font-size: 32px; font-weight: 800; }
.inv-address-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.inv-customer-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.inv-bill-to p { font-size: 13px; line-height: 1.6; color: #374151; }
.inv-meta-right { text-align: right; }
.inv-meta-row { display: flex; justify-content: flex-end; gap: 16px; margin-bottom: 5px; font-size: 13px; }
.inv-meta-label { font-weight: 700; }
.inv-divider { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0; }
.inv-items-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.inv-items-table th { font-size: 12px; font-weight: 700; padding: 10px 12px; background: #f9fafb; border-bottom: 1px solid #e5e7eb; text-align: left; }
.inv-items-table th:not(:first-child), .inv-items-table td:not(:first-child) { text-align: right; }
.inv-items-table td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid #f3f4f6; }
.inv-totals { max-width: 320px; margin-left: auto; }
.inv-total-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.inv-total-due { font-weight: 700; border-top: 1px solid #e5e7eb; padding-top: 10px; margin-top: 4px; }
.inv-notes { margin: 16px 0; }
.notes-label { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.inv-footer { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-top: 8px; }
.inv-footer-col p { font-size: 12px; line-height: 1.8; color: #374151; }
.footer-title { font-weight: 700 !important; }
.inv-status-bar { display: flex; align-items: center; gap: 12px; padding: 12px 0; margin-bottom: 4px; }

/* ── Settings ────────────────────────────────────────────────────────── */
.settings-wrap { max-width: 1100px; }
.settings-title { font-size: 22px; font-weight: 700; margin-bottom: 24px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.settings-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 24px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 1px solid #f3f4f6; }
.settings-actions { margin-top: 24px; display: flex; align-items: center; gap: 16px; }
.save-status { color: #059669; font-weight: 600; font-size: 13px; }
.logo-preview { margin-bottom: 12px; padding: 12px; background: #f9fafb; border-radius: 8px; }
.logo-preview img { max-height: 60px; max-width: 200px; }

/* ── Customers ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px; color: #9ca3af; }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: #fff; border-radius: 12px; padding: 28px; width: 420px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-wide { width: 640px; }
.modal-box h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; }
  .detail-panel { display: none; }
  .form-two-col { grid-template-columns: 1fr; }
  .inv-address-meta { grid-template-columns: 1fr; }
  .inv-footer { grid-template-columns: 1fr; }
}
