/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; background: #f0f2f5; color: #1a1a2e; }
a { color: #1d6fa4; text-decoration: none; } a:hover { text-decoration: underline; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; border-bottom: 1px solid #e5e7eb; text-align: left; }
th { background: #f8f9fa; font-weight: 600; color: #555; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
tr:hover td { background: #fafbfc; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; background: #fff; }
input:focus, select:focus { outline: none; border-color: #1d6fa4; box-shadow: 0 0 0 3px rgba(29,111,164,.1); }
label { display: block; font-weight: 600; font-size: 12px; color: #555; margin-bottom: 4px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ── Navigation ──────────────────────────────── */
nav { background: #1a1a2e; color: #fff; display: flex; align-items: center; padding: 0 24px; height: 52px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.brand { font-size: 18px; font-weight: 700; color: #fff; margin-right: 32px; letter-spacing: -0.5px; }
.brand:hover { text-decoration: none; }
.nav-links a { color: rgba(255,255,255,.75); padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.nav-links a:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }

/* ── Main layout ─────────────────────────────── */
main { max-width: 1200px; margin: 0 auto; padding: 24px; }

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

/* ── Cards ───────────────────────────────────── */
.card { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: #1a1a2e; }
.card h3 { font-size: 13px; font-weight: 700; margin: 16px 0 10px; color: #444; }

/* ── Two-column grid ─────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

/* ── Stat cards ──────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: #fff; border-radius: 10px; padding: 18px 20px; box-shadow: 0 1px 4px rgba(0,0,0,.08); border-left: 4px solid #ccc; }
.stat-card.blue  { border-color: #1d6fa4; }
.stat-card.green { border-color: #16a34a; }
.stat-card.red   { border-color: #dc2626; }
.stat-card.grey  { border-color: #6b7280; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #888; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.stat-card a { font-size: 12px; color: #1d6fa4; }

/* ── Dashboard ── */
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.month-summary { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.08); padding: 16px 20px; margin-bottom: 20px; border-left: 4px solid #1d6fa4; }
.month-summary-head { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #888; margin-bottom: 12px; font-weight: 600; }
.month-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.ms-item { text-align: center; padding: 4px 16px; border-right: 1px solid #eef0f3; }
.ms-item:last-child { border-right: none; }
.ms-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: #888; margin-bottom: 4px; }
.ms-value { font-size: 24px; font-weight: 700; }
.ms-prev  { font-size: 11px; color: #9ca3af; margin-top: 3px; }
.card-more { display: inline-block; margin-top: 10px; font-size: 12px; color: #1d6fa4; }
@media (max-width: 640px) {
  .month-summary-grid { grid-template-columns: 1fr; gap: 10px; }
  .ms-item { border-right: none; border-bottom: 1px solid #eef0f3; padding-bottom: 10px; }
  .ms-item:last-child { border-bottom: none; }
  .ms-value { font-size: 20px; }
}

/* ── Buttons ─────────────────────────────────── */
.btn { display: inline-block; padding: 8px 16px; background: #1d6fa4; color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.4; }
.btn:hover { background: #155d8a; color: #fff; text-decoration: none; }
.btn-outline { background: transparent; border: 1.5px solid #1d6fa4; color: #1d6fa4; }
.btn-outline:hover { background: #eef4fa; color: #1d6fa4; }
.btn-green { background: #16a34a; }
.btn-green:hover { background: #15803d; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn + .btn, .btn + a { margin-left: 8px; }

/* ── Badges ──────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge-green  { background: #dcfce7; color: #16a34a; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-orange  { background: #ffedd5; color: #c2410c; }
.badge-purple  { background: #ede9fe; color: #6d28d9; }
.badge-grey   { background: #f3f4f6; color: #6b7280; }

/* ── AI prompt box (copy-paste prompts on import screens) ── */
.ai-prompt { border: 1px solid #e0d9f5; background: #faf8ff; border-radius: 8px; margin-bottom: 14px; overflow: hidden; }
.ai-prompt-summary { cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 13px; color: #5b3fbf; display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none; }
.ai-prompt-summary::-webkit-details-marker { display: none; }
.ai-prompt-summary::before { content: '▸'; margin-right: 6px; transition: transform .15s; color: #8b6fd6; }
.ai-prompt[open] .ai-prompt-summary::before { transform: rotate(90deg); }
.ai-prompt-hint { font-weight: 400; font-size: 11px; color: #998; text-transform: none; letter-spacing: 0; }
.ai-prompt-body { padding: 0 14px 14px; }
.ai-prompt-sub { font-size: 12px; color: #666; margin: 0 0 8px; }
.ai-prompt-toolbar { margin-bottom: 6px; }
.ai-prompt-text { width: 100%; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11px; line-height: 1.45; color: #333; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px; resize: vertical; white-space: pre; }

/* ── Alerts ──────────────────────────────────── */
.alert { padding: 10px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-dismiss { opacity: 0; transform: translateY(-6px); transition: opacity .4s, transform .4s; }

/* ── Forms ───────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.filter-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row select, .filter-row input { width: auto; min-width: 160px; }

/* ── Totals box ──────────────────────────────── */
.totals-box { margin-top: 16px; border-top: 1px solid #e5e7eb; padding-top: 12px; max-width: 300px; margin-left: auto; }
.totals-box div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.total-row { font-weight: 700; font-size: 15px; border-top: 2px solid #e5e7eb; padding-top: 8px; margin-top: 4px; }

/* ── Amount colours ──────────────────────────── */
.amt-pos { color: #16a34a; font-weight: 600; }
.amt-neg { color: #dc2626; font-weight: 600; }
.hidden  { display: none !important; }

/* ── Reconciliation cards ────────────────────── */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.match-card { border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.match-sides { display: grid; grid-template-columns: 1fr 80px 1fr; gap: 12px; align-items: center; }
.match-side { padding: 10px 12px; border-radius: 6px; }
.match-side.left  { background: #f0f7ff; }
.match-side.right { background: #f0fdf4; }
.match-arrow { text-align: center; font-size: 18px; color: #888; }
.match-label { font-size: 10px; text-transform: uppercase; color: #888; letter-spacing: .5px; }
.match-date  { font-size: 12px; color: #555; }
.match-desc  { font-weight: 600; font-size: 13px; margin: 2px 0; }
.match-ref   { font-size: 11px; color: #777; }
.match-amount { font-size: 16px; font-weight: 700; margin-top: 4px; }
.match-reasons { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.tag { background: #f3f4f6; color: #555; padding: 2px 8px; border-radius: 12px; font-size: 11px; }
.match-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.alt-select { width: auto; min-width: 220px; font-size: 12px; }
.score-badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.score-high { background: #dcfce7; color: #16a34a; }
.score-mid  { background: #fef9c3; color: #854d0e; }

/* ── Table helpers ───────────────────────────── */
.row-reconciled td { color: #aaa; }
.group-header td { background: #f8f9fa; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #888; padding: 6px 12px; }
th.num, td.num { text-align: right; white-space: nowrap; }
td.date { white-space: nowrap; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: #f3f7fb; }

/* ── Dropdown menu (e.g. Export ▾ on list pages) ── */
.menu-drop { position: relative; display: inline-block; }
.menu-drop summary { list-style: none; cursor: pointer; }
.menu-drop summary::-webkit-details-marker { display: none; }
.menu-drop[open] > .menu-drop-list { display: block; }
.menu-drop-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 200;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  min-width: 190px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px 0;
}
.menu-drop-list a { display: block; padding: 8px 14px; font-size: 13px; color: #1a1a2e; white-space: nowrap; }
.menu-drop-list a:hover { background: #eef2f7; text-decoration: none; }

/* ── Detail grid ─────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.detail-grid label { font-size: 11px; text-transform: uppercase; color: #888; display: block; margin-bottom: 2px; }
.detail-grid strong, .detail-grid span { font-size: 14px; }

/* ── Quick actions ───────────────────────────── */
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.quick-actions h2 { margin-bottom: 0; margin-right: 8px; }

/* ── Misc ────────────────────────────────────── */
.muted { color: #888; font-size: 13px; }

/* ── Back link ───────────────────────────────────────────────────────── */
.back-link { font-size: 13px; color: #888; }
.back-link:hover { color: #1d6fa4; text-decoration: none; }

/* ── Scrollable table wrapper ─────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 540px; }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE NAV — hamburger + slide-down menu
   ═══════════════════════════════════════════════════════════════════════ */

.nav-hamburger {
  display: none; margin-left: auto;
  background: none; border: none; cursor: pointer; padding: 8px;
  flex-direction: column; justify-content: center; gap: 5px;
}
.nav-hamburger span {
  display: block; width: 22px; height: 2px;
  background: rgba(255,255,255,.85); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-mobile-menu {
  display: none; background: #1e1e38;
  border-top: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.nav-mobile-menu.open { display: block; }
.nav-mobile-menu a, .nav-mobile-menu .nav-mob-btn {
  display: block; padding: 13px 20px;
  color: rgba(255,255,255,.82); font-size: 14px; font-weight: 500;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none; background: none;
  border-left: none; border-right: none; border-top: none;
  width: 100%; text-align: left; cursor: pointer;
}
.nav-mobile-menu a:hover, .nav-mobile-menu .nav-mob-btn:hover {
  background: rgba(255,255,255,.07); color: #fff; text-decoration: none;
}
.nav-mob-section {
  padding: 8px 20px 4px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .6px; color: rgba(255,255,255,.35);
}
.nav-mob-danger { color: #f87171 !important; }

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Narrow desktop (≤ 1100px) — tighten nav so it doesn't wrap ────── */
@media (max-width: 1100px) {
  nav { padding: 0 14px; }
  .brand { margin-right: 14px; font-size: 16px; }
  .nav-links a, .nav-drop-btn { padding: 6px 8px; font-size: 12px; }
  .biz-name { max-width: 90px; }
}

/* ── Tablet (≤ 900px) ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile (≤ 768px) — nav collapses to hamburger ─────────────────── */
@media (max-width: 768px) {
  nav { flex-wrap: wrap; height: auto; min-height: 52px; padding: 0 16px; }
  .nav-links { display: none !important; }
  nav > form  { display: none !important; }   /* hide inline desktop logout */
  .biz-switcher { display: none !important; }
  .nav-hamburger { display: flex; }
  .brand { margin-right: 0; }
}

/* ── Mobile (≤ 640px) — layout & touch sizing ──────────────────────── */
@media (max-width: 640px) {
  /* spacing */
  main  { padding: 12px; }
  .card { padding: 14px 12px; }
  .two-col { grid-template-columns: 1fr; gap: 14px; }
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* page header — stack title above actions */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header h1 { font-size: 18px; }
  .page-header > div,
  .page-header > form { flex-wrap: wrap; gap: 6px; }

  /* stat cards */
  .stat-grid  { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat-card  { padding: 14px 12px; }
  .stat-value { font-size: 20px; }

  /* filter rows — stack vertically */
  .filter-row { flex-direction: column; align-items: stretch; gap: 8px !important; }
  .filter-row select,
  .filter-row input[type="text"],
  .filter-row input[type="date"] { width: 100% !important; min-width: unset !important; }

  /* forms */
  .form-row   { grid-template-columns: 1fr; }
  .totals-box { max-width: 100%; }

  /* tables */
  table   { font-size: 12px; }
  th, td  { padding: 7px 8px; white-space: nowrap; }

  /* touch-friendly sizing */
  .btn { min-height: 40px; padding: 9px 14px; }
  select,
  input[type="text"], input[type="date"], input[type="number"],
  input[type="email"], input[type="password"], textarea { min-height: 40px; font-size: 14px !important; }

  /* quick-actions — 2-up grid */
  .quick-actions { flex-wrap: wrap; gap: 8px; }
  .quick-actions .btn { flex: 1 1 calc(50% - 4px); text-align: center; }

  /* reconcile */
  .section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .match-sides    { grid-template-columns: 1fr; gap: 8px; }
  .match-arrow    { display: none; }
}
