/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #f0f4f8; color: #1e293b; font-size: 15px; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.navbar {
  background: #1a3c6b; color: #fff; padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15); position: sticky; top: 0; z-index: 100;
}
.navbar .brand { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.navbar .brand span { font-size: 1.3rem; }
.nav-links { display: flex; gap: 8px; align-items: center; }
.nav-links a {
  color: #b0c4de; text-decoration: none; padding: 6px 14px; border-radius: 6px;
  font-size: 0.87rem; font-weight: 500; transition: background 0.2s, color 0.2s;
}
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,0.12); color: #fff; }
.btn-logout {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; padding: 6px 14px; border-radius: 6px; font-size: 0.85rem;
  cursor: pointer; transition: background 0.2s;
}
.btn-logout:hover { background: rgba(220,38,38,0.7); }

.main-content { flex: 1; padding: 28px 28px 48px; max-width: 1100px; margin: 0 auto; width: 100%; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); padding: 28px; margin-bottom: 24px; }
.card-title { font-size: 1.1rem; font-weight: 700; color: #1a3c6b; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }

/* ── Form Controls ─────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.four { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.8rem; font-weight: 600; color: #374151; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], textarea, select {
  padding: 9px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px; font-size: 0.92rem;
  color: #1e293b; background: #fff; outline: none; transition: border 0.2s;
  font-family: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
textarea { resize: vertical; min-height: 70px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border: none; border-radius: 8px; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.18s; text-decoration: none; }
.btn-primary { background: #1a3c6b; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; border: 1.5px solid #cbd5e1; color: #475569; }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-icon { padding: 6px 10px; }

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid #e2e8f0; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { background: #1a3c6b; color: #fff; padding: 11px 14px; text-align: left; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.03em; }
td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; color: #374151; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.monospace { font-family: 'Consolas', monospace; font-size: 0.85rem; }

/* ── Badge / Status ─────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; }
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-paid { background: #dcfce7; color: #15803d; }

/* ── Invoice Items Table ────────────────────────────────────────────────────── */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.items-table th { background: #1a3c6b; color: #fff; padding: 9px 10px; font-size: 0.8rem; font-weight: 600; text-align: left; }
.items-table th.right { text-align: right; }
.items-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.items-table tr:last-child td { border-bottom: none; }
.items-table input { padding: 6px 8px; font-size: 0.88rem; border: 1.5px solid #e2e8f0; border-radius: 6px; }
.items-table .rm-btn { background: none; border: none; cursor: pointer; color: #dc2626; font-size: 1.1rem; padding: 2px 6px; border-radius: 4px; }
.items-table .rm-btn:hover { background: #fee2e2; }

/* ── Totals box ─────────────────────────────────────────────────────────────── */
.totals-box { margin-top: 12px; display: flex; justify-content: flex-end; }
.totals-inner { min-width: 260px; }
.totals-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 0.9rem; color: #64748b; border-bottom: 1px solid #f1f5f9; }
.totals-row.total { font-weight: 700; font-size: 1.05rem; color: #1a3c6b; border-bottom: none; padding-top: 10px; border-top: 2px solid #1a3c6b; margin-top: 6px; }

/* ── Page Header ────────────────────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h2 { font-size: 1.4rem; color: #1a3c6b; font-weight: 700; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; right: 28px; padding: 14px 22px;
  border-radius: 10px; font-weight: 600; font-size: 0.9rem; color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18); z-index: 9999; display: none;
  animation: slideUp 0.25s ease;
}
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
@keyframes slideUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 1rem; margin-bottom: 20px; }

/* ── Loading ─────────────────────────────────────────────────────────────────── */
.loading { text-align: center; padding: 40px; color: #64748b; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .form-grid, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
  .navbar { padding: 0 16px; }
}
