/* CARM Analyzer — Synergy Products
   Plain CSS, no build step. Mirrors the Synergy portal house style:
   deep blue header, clean white content cards, generous padding. */

:root {
  --blue-900: #0F2A47;
  --blue-700: #1f4068;
  --blue-500: #2762ad;
  --blue-100: #e6efff;
  --green-600: #1e7c4a;
  --red-600: #b3261e;
  --amber-600: #b86d00;
  --gray-900: #1a1816;
  --gray-700: #4a4a4a;
  --gray-500: #8a8a8a;
  --gray-200: #e5e5e5;
  --gray-100: #f4f5f7;
  --gray-50:  #fafbfc;
  --bg: #f4f5f7;
  --card: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 42, 71, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 42, 71, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, "Segoe UI", "Inter", system-ui, sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--bg);
  line-height: 1.4;
}

.hidden { display: none !important; }

/* ── Top bar ───────────────────────────────────────── */
.topbar {
  background: var(--blue-900);
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand-mark { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.brand-sub { color: rgba(255,255,255,0.7); font-size: 13px; }
.topbar-right { display: flex; gap: 8px; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  font: inherit;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-900);
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--gray-100); }
.btn-primary {
  background: var(--blue-500);
  color: white;
  border-color: var(--blue-500);
  font-weight: 600;
}
.btn-primary:hover { background: var(--blue-700); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: rgba(255,255,255,0.85);
}
.topbar .btn-ghost { color: rgba(255,255,255,0.85); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,0.1); }

/* ── Drop zone ─────────────────────────────────────── */
.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 40px;
}
.dropzone-inner {
  background: var(--card);
  border: 2px dashed var(--gray-200);
  border-radius: 12px;
  padding: 60px 80px;
  text-align: center;
  max-width: 600px;
  transition: all 0.2s;
}
.dropzone-inner.dragover {
  border-color: var(--blue-500);
  background: var(--blue-100);
}
.dropzone-icon { font-size: 64px; margin-bottom: 16px; }
.dropzone h2 { margin: 0 0 12px; color: var(--blue-900); }
.dropzone p { margin: 8px 0; color: var(--gray-700); }
.dropzone-hint { color: var(--green-600); font-size: 13px; }
.dropzone-meta { font-size: 12px; color: var(--gray-500); margin-top: 24px; }
.dropzone .btn-primary { margin: 16px 0 8px; padding: 12px 28px; font-size: 15px; }

/* ── App layout ────────────────────────────────────── */
.app {
  padding: 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Summary cards */
.summary-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.card-primary {
  background: var(--blue-900);
  color: white;
  border-color: var(--blue-900);
}
.card-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); margin-bottom: 4px; }
.card-primary .card-label { color: rgba(255,255,255,0.7); }
.card-value { font-size: 28px; font-weight: 700; color: var(--gray-900); font-variant-numeric: tabular-nums; }
.card-primary .card-value { color: white; }
.card-sub { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.card-primary .card-sub { color: rgba(255,255,255,0.7); }

/* Date range presets */
.filters-row {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  margin-bottom: 20px;
}
.filter-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.preset {
  font: inherit;
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--gray-200);
  background: var(--gray-100);
  color: var(--gray-900);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.1s;
}
.preset:hover { background: var(--blue-100); border-color: var(--blue-500); }
.preset.active {
  background: var(--blue-500);
  color: white;
  border-color: var(--blue-500);
}
.custom-range { display: flex; gap: 16px; align-items: center; }
.custom-range label { font-size: 13px; color: var(--gray-700); display: flex; gap: 8px; align-items: center; }
.custom-range input[type=date] { padding: 4px 8px; border: 1px solid var(--gray-200); border-radius: 4px; font: inherit; }

/* Grid: filter rail + content */
.main-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
}

/* Filter rail */
.rail {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  align-self: start;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
.rail-section { margin-bottom: 18px; }
.rail-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin: 0 0 8px;
  font-weight: 600;
}
.checklist { display: flex; flex-direction: column; gap: 4px; }
.checklist label {
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-700);
}
.checklist label:hover { background: var(--gray-100); }
.checklist input[type=checkbox] { margin: 0; }
.checklist .count { color: var(--gray-500); font-size: 11px; margin-left: auto; }
.amount-range { display: flex; gap: 8px; }
.amount-range label { display: flex; flex-direction: column; gap: 2px; flex: 1; font-size: 12px; color: var(--gray-700); }
.amount-range input { padding: 4px 6px; border: 1px solid var(--gray-200); border-radius: 4px; font: inherit; }
.rail-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }

/* Content area */
.content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* Reconciliation card */
.reconcile {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--blue-500);
}
.reconcile-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.reconcile-header h2 { margin: 0; color: var(--blue-900); }
.reconcile-period { color: var(--gray-500); font-size: 13px; }
.reconcile-grid { display: grid; gap: 8px; }
.reconcile-input { padding: 12px 16px; background: var(--gray-50); border-radius: var(--radius); border: 1px solid var(--gray-200); }
.reconcile-input label { display: block; font-size: 12px; text-transform: uppercase; color: var(--gray-500); letter-spacing: 0.5px; margin-bottom: 4px; }
.reconcile-input input {
  width: 100%; max-width: 280px;
  padding: 8px 12px; font-size: 18px; font-weight: 600;
  border: 1px solid var(--gray-200); border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.reconcile-line {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; font-size: 15px;
}
.reconcile-line.minus { color: var(--red-600); }
.reconcile-line.total {
  font-size: 20px; font-weight: 700;
  background: var(--blue-100); border-radius: var(--radius);
  padding: 14px 16px; margin-top: 4px;
  color: var(--blue-900);
}
.reconcile-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.reconcile-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Transaction table */
.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.tx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tx-table thead { background: var(--gray-100); }
.tx-table th, .tx-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
  vertical-align: top;
}
.tx-table th {
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tx-table th:hover { background: var(--gray-200); }
.tx-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tx-table tbody tr:hover { background: var(--gray-50); }
.tx-table tfoot td {
  background: var(--gray-100);
  font-weight: 600;
  border-top: 2px solid var(--gray-200);
}
.tx-table .amount-positive { color: var(--gray-900); }
.tx-table .amount-negative { color: var(--green-600); }
.tx-empty { padding: 60px; text-align: center; color: var(--gray-500); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.tag-paid { background: #d4f0db; color: #1e7c4a; }
.tag-pending { background: #fff4d4; color: #b86d00; }
.tag-other { background: var(--gray-200); color: var(--gray-700); }

/* History drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 24px rgba(15, 42, 71, 0.15);
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--blue-900);
  color: white;
}
.drawer-header h3 { margin: 0; font-size: 15px; }
.drawer-header .btn-ghost { color: white; font-size: 22px; padding: 0 8px; line-height: 1; }
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.drawer-empty { color: var(--gray-500); text-align: center; margin-top: 40px; }
.history-item {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 13px;
}
.history-item-period { font-weight: 600; color: var(--blue-900); }
.history-item-date { color: var(--gray-500); font-size: 11px; }
.history-item-row { display: flex; justify-content: space-between; padding: 2px 0; }
.history-item-actions { display: flex; gap: 6px; margin-top: 6px; }
.history-item .btn { font-size: 11px; padding: 4px 8px; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 42, 71, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-card {
  background: white;
  border-radius: 12px;
  padding: 32px 40px;
  max-width: 600px;
  box-shadow: var(--shadow-md);
}
.modal-card h2 { margin-top: 0; color: var(--blue-900); }
.modal-card ol { padding-left: 20px; line-height: 1.7; }
.modal-card .btn { margin-top: 16px; }

/* Print: reconciliation summary clean */
@media print {
  .topbar, .filters-row, .rail, .reconcile-actions, .table-wrap { display: none !important; }
  .summary-row { display: flex; gap: 12px; }
  .reconcile { border: 2px solid #000; }
  body { background: white; }
}

/* Responsive */
@media (max-width: 1100px) {
  .summary-row { grid-template-columns: 1fr 1fr; }
  .main-grid { grid-template-columns: 1fr; }
  .rail { position: static; max-height: none; }
}
