*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:   #1a56a0;
  --brand2:  #1347880;
  --accent:  #e8f0fb;
  --green:   #1a8a4a;
  --red:     #c0392b;
  --amber:   #d97706;
  --bg:      #f4f6fa;
  --card:    #ffffff;
  --border:  #dde3ec;
  --text:    #1c2636;
  --muted:   #6b7a93;
  --radius:  8px;
  --shadow:  0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Layout ── */
header {
  background: var(--brand);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
header h1 { font-size: 18px; font-weight: 600; letter-spacing: .3px; flex: 1; }
header a  { color: rgba(255,255,255,.82); text-decoration: none; font-size: 14px; }
header a:hover { color: #fff; }

main { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-header h2 { font-size: 16px; font-weight: 600; flex: 1; }
.card-body  { padding: 20px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: filter .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { filter: brightness(.95); }

.btn-primary  { background: var(--brand); color: #fff; }
.btn-success  { background: var(--green); color: #fff; }
.btn-danger   { background: var(--red);   color: #fff; }
.btn-ghost    { background: transparent; color: var(--brand); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--accent); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-icon { padding: 6px 8px; }

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-full { grid-column: 1 / -1; }

label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }

input[type=text], input[type=email], input[type=date], input[type=number],
textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,160,.12);
}
textarea { resize: vertical; min-height: 72px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7f9fc; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 13px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-invoiced { background: #d1fae5; color: #065f46; }

/* ── Client list grid ── */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.client-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, border-color .15s;
}
.client-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  border-color: var(--brand);
}
.client-card .name  { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.client-card .meta  { font-size: 13px; color: var(--muted); line-height: 1.7; }
.client-card .pill  {
  display: inline-block;
  margin-top: 10px;
  background: var(--accent);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
}
.client-card .pill.amber { background: #fef3c7; color: #92400e; }

/* ── Page header row ── */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 22px; font-weight: 700; flex: 1; }

/* ── Totals bar ── */
.totals-bar {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--accent);
  border: 1px solid #c7d9f5;
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
}
.totals-bar .item label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.totals-bar .item .val  { font-size: 20px; font-weight: 700; color: var(--brand); }

/* ── Modal ── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
}
.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.modal-header h3 { flex: 1; font-size: 17px; font-weight: 600; }
.modal-body  { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c2636;
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.error { background: var(--red); }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty .icon { font-size: 40px; margin-bottom: 10px; }
.empty p { font-size: 15px; }

/* ── Search bar ── */
.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-row input { flex: 1; min-width: 180px; }

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 2px;
}
.tab-btn {
  padding: 9px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-btn:hover  { color: var(--text); }

/* ── Invoice print styles ── */
@media print {
  header, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: 100%; }
  .card { border: none; box-shadow: none; }
  table th, table td { padding: 7px 8px; }
}
