:root{
  --bg: #f7f5ec;
  --text: #222;
  --muted: rgba(34,34,34,.65);
  --line: rgba(34,34,34,.14);

  --card: rgba(255,255,255,.75);
  --cardSolid: #ffffff;

  --shadow1: 0 8px 18px rgba(0,0,0,.08);
  --shadow2: 0 18px 45px rgba(0,0,0,.10);

  --radius: 18px;
  --radius2: 22px;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1,h2,h3{
  margin:0;
  font-weight: 800; /* headings bold */
  letter-spacing: -0.02em;
}
p{ margin:0; }
small{ color: var(--muted); }
.meta{ color: var(--muted); }

/* Layout shell */
.shell{
  display:flex;
  min-height:100vh;
}

.sidebar{
  width: 260px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,.45);
  backdrop-filter: blur(6px);
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding: 10px 10px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.badge{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(34,34,34,.10);
  box-shadow: var(--shadow1);
}

.brand h1{
  font-size: 16px;
  font-weight: 900;
}
.brand p{
  font-size: 12px;
  color: var(--muted);
}

.nav{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top: 12px;
}
.nav a{
  text-decoration:none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 600;
}
.nav a:hover{
  background: rgba(34,34,34,.06);
  border-color: rgba(34,34,34,.10);
}
.nav a.active{
  background: rgba(34,34,34,.10);
  border-color: rgba(34,34,34,.18);
  font-weight: 800;
}

.main{
  flex:1;
  padding: 18px;
}

.container{
  max-width: 1150px;
  margin: 0 auto;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

/* Span helpers (keep using your existing classes) */
.span-12{ grid-column: span 12; }
.span-8{ grid-column: span 8; }
.span-7{ grid-column: span 7; }
.span-6{ grid-column: span 6; }
.span-5{ grid-column: span 5; }
.span-4{ grid-column: span 4; }
.span-3{ grid-column: span 3; }
.span-2{ grid-column: span 2; }

/* Card base */
.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius2);
  box-shadow: var(--shadow1);
  padding: 14px 16px;
  backdrop-filter: blur(6px);

  transform: translateY(0) perspective(900px) rotateX(0deg);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  will-change: transform;
}

/* Card headers (used on Transactions page too) */
.card-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.card-head .meta{
  margin: 0;
}

/* Recurring Rules card */
.rr-card .table{
  margin-top: 0; /* table already has its own framing */
}

.rr-actions{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content:flex-end;
  align-items:center;
}

/* Optional: slightly tighter table in rules area */
.rr-card .table thead th{
  padding: 10px 12px;
}

.rr-card .table tbody td{
  padding: 10px 12px;
}

/* 3D hover + zoom */
.card:hover{
  transform: translateY(-4px) perspective(900px) rotateX(1.2deg) scale(1.02);
  box-shadow: var(--shadow2);
  background: rgba(255,255,255,.85);
}

/* Ensure cards stack correctly (so Save/Cancel never hide behind other cards) */
.card{
  position: relative;
  z-index: 1;
}

.card:hover{
  z-index: 20;
}

/* When you click into inputs/buttons inside a card, keep it on top */
.card:focus-within{
  z-index: 30;
}

/* KPI styling (keep compatible) */
.kpi .label{
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.kpi .value{
  font-size: 22px;
  font-weight: 900;
  margin-top: 6px;
}
.kpi .sub{
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* Keep existing behaviour for other dashboard clickable cards (Main/UW etc.) */
/* (Leave your current .dash-clickable.is-active rule in place if Main/UW rely on it) */

/* Override ONLY the KPI cards when active */
.dash-clickable.kpi-clickable.is-active {
  background: rgba(110,168,254,.18) !important;
  border-color: rgba(110,168,254,.45) !important;
  box-shadow: 0 0 0 2px rgba(110,168,254,.25), var(--shadow1) !important;
}

/* KPI cards: don't force white text */
.dash-clickable.kpi-clickable.is-active * {
  color: var(--text) !important;
}

/* ---------------------------
   Goals: Monthly saved trend
--------------------------- */
.saved-chart{
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.02);
  padding: 12px;
}

.saved-chart-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.saved-bars{
  height: 180px;
  display:flex;
  align-items:flex-end;
  gap:8px;
  padding: 6px 2px 2px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.saved-bar{
  flex: 1 1 0;
  min-width: 10px;
  border-radius: 10px 10px 4px 4px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(110,168,254,.18); /* your accent blue */
  position:relative;
}

.saved-bar.dim{
  opacity: .35;
}

.saved-bar .tip{
  position:absolute;
  left:50%;
  transform: translateX(-50%);
  bottom: calc(100% + 8px);
  background: rgba(18,20,28,.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 11px;
  color: #fff;
  white-space:nowrap;
  opacity:0;
  pointer-events:none;
  transition: opacity .12s ease;
}

.saved-bar:hover .tip{
  opacity:1;
}

.saved-x{
  display:flex;
  gap:8px;
  margin-top:8px;
  font-size:11px;
  color: var(--muted);
}

.saved-x span{
  flex: 1 1 0;
  text-align:center;
}

/* Tables */
.table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 12px;
  overflow:hidden;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.table thead th{
  text-align:left;
  font-size: 12px;
  color: rgba(34,34,34,.70);
  font-weight: 800;
  background: rgba(34,34,34,.05);
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
}
.table tbody td{
  padding: 12px 12px;
  border-bottom: 1px solid rgba(34,34,34,.08);
  font-size: 13px;
  font-weight: 500;
}
.table tbody tr:last-child td{ 
  border-bottom: none; 
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
}

.table-wrap .table {
  min-width: 980px; /* tweak if needed */
}

.table th, .table td {
  white-space: nowrap;
}

.table td:first-child {
  white-space: normal; /* allow Bucket name to wrap */
  min-width: 220px;
}

/* Transactions table tweaks */
.table.transactions-table {
  font-size: 13px; /* drop 1 size */
}

.table.transactions-table th,
.table.transactions-table td {
  padding: 10px 10px;
  vertical-align: middle;
}

.table.transactions-table th.col-date,
.table.transactions-table td.col-date {
  width: 92px;              /* narrower date */
  white-space: nowrap;
}

.table.transactions-table th.col-actions,
.table.transactions-table td.col-actions {
  width: 180px;
  white-space: nowrap;
}

.table.transactions-table td.col-account {
  max-width: 260px;         /* prevents pushing table */
  white-space: normal;      /* allow wrap */
  word-break: break-word;
}

/* Soft collapse for Recurring Rules */
#rr-body {
  overflow: hidden;
  max-height: 2000px;              /* big enough for content */
  opacity: 1;
  transform: translateY(0);
  transition: max-height 280ms ease, opacity 220ms ease, transform 220ms ease;
}

#rr-card.is-collapsed #rr-body {
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}


/* Inputs */
input, select{
  font-family: inherit;
  color: var(--text);
}

/* Pills (if you use them) */
.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(34,34,34,.06);
  font-weight: 800;
  font-size: 12px;
}

/* Ensure pills render correctly inside tables too */
.table .pill,
.table-wrap .pill,
tbody .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

/* Green = On track */
.table .pill.good,
.table-wrap .pill.good,
tbody .pill.good {
  background: rgba(52, 156, 96, 0.464);
  border-color: rgba(52, 156, 96, 0.464);
  color: rgba(255, 255, 255, 0.95);
}

/* Red = Off track */
.table .pill.bad,
.table-wrap .pill.bad,
tbody .pill.bad {
  background: rgba(252, 50, 32, 0.468);
  border-color: rgba(252, 50, 32, 0.468);
  color: rgba(255, 255, 255, 0.95);
}

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background: rgba(110,168,254,.18);
  color: var(--text);
  font-weight:800;
  cursor:pointer;
  font-family: inherit;
  line-height:1;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.btn:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow1);
  background: rgba(110,168,254,.24);
}

.btn:active{
  transform: translateY(0);
  box-shadow: none;
}

.btn:focus{
  outline: none;
}

.btn:focus-visible{
  box-shadow: 0 0 0 2px rgba(110,168,254,.35), var(--shadow1);
}

.btn.secondary{
  background: rgba(34,34,34,.06);
}

.btn.secondary:hover{
  background: rgba(34,34,34,.10);
}

.btn.danger{
  background: rgba(255,80,80,.14);
  border-color: rgba(255,80,80,.22);
}

.btn.danger:hover{
  background: rgba(255,80,80,.20);
}

.btn.tiny{
  padding:8px 10px;
  border-radius:12px;
  font-size:12px;
  font-weight:800;
}

/* Make plain <button> behave consistently too */
button{
  font-family: inherit;
}

/* ===== Page-load animation =====
   We animate text elements inside cards on page load.
*/
.reveal-ready .card{
  opacity: 0;
  transform: translateY(10px) scale(.99);
}
.reveal-ready.revealed .card{
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity .40s ease, transform .40s ease;
}

/* Stagger effect (first 18 cards) */
.reveal-ready.revealed .card:nth-child(1){ transition-delay: .02s; }
.reveal-ready.revealed .card:nth-child(2){ transition-delay: .05s; }
.reveal-ready.revealed .card:nth-child(3){ transition-delay: .08s; }
.reveal-ready.revealed .card:nth-child(4){ transition-delay: .11s; }
.reveal-ready.revealed .card:nth-child(5){ transition-delay: .14s; }
.reveal-ready.revealed .card:nth-child(6){ transition-delay: .17s; }
.reveal-ready.revealed .card:nth-child(7){ transition-delay: .20s; }
.reveal-ready.revealed .card:nth-child(8){ transition-delay: .23s; }
.reveal-ready.revealed .card:nth-child(9){ transition-delay: .26s; }
.reveal-ready.revealed .card:nth-child(10){ transition-delay: .29s; }
.reveal-ready.revealed .card:nth-child(11){ transition-delay: .32s; }
.reveal-ready.revealed .card:nth-child(12){ transition-delay: .35s; }
.reveal-ready.revealed .card:nth-child(13){ transition-delay: .38s; }
.reveal-ready.revealed .card:nth-child(14){ transition-delay: .41s; }
.reveal-ready.revealed .card:nth-child(15){ transition-delay: .44s; }
.reveal-ready.revealed .card:nth-child(16){ transition-delay: .47s; }
.reveal-ready.revealed .card:nth-child(17){ transition-delay: .50s; }
.reveal-ready.revealed .card:nth-child(18){ transition-delay: .53s; }

/* Mobile */
@media (max-width: 980px){
  .sidebar{ display:none; }
  .main{ padding: 14px; }
  .grid{ grid-template-columns: repeat(6, 1fr); }
  .span-12{ grid-column: span 6; }
  .span-8{ grid-column: span 6; }
  .span-7{ grid-column: span 6; }
  .span-6{ grid-column: span 6; }
  .span-5{ grid-column: span 6; }
  .span-4{ grid-column: span 3; }
  .span-3{ grid-column: span 3; }
  .span-2{ grid-column: span 3; }
}

/* ===== Transactions: force table to fit card (override global table-wrap/nowrap) ===== */

.table-wrap .table.transactions-table {
  min-width: 0;            /* override min-width:980px */
}

.table.transactions-table {
  width: 100%;
  table-layout: fixed;     /* critical: prevents long content expanding table */
}

.table.transactions-table th,
.table.transactions-table td {
  white-space: normal;     /* override global nowrap */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Prefer wrapping in description + account */
.table.transactions-table td.col-desc,
.table.transactions-table td.col-account {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}

/* Keep these compact */
.table.transactions-table th.col-date,
.table.transactions-table td.col-date,
.table.transactions-table th.col-actions,
.table.transactions-table td.col-actions {
  white-space: nowrap;
}

.dash-clickable { cursor: pointer; }
.dash-clickable.is-active {
  background: #FF4F40 !important;
  border-color: rgba(255,255,255,.22) !important;
}
.dash-clickable.is-active * {
  color: white !important;
}

.chart-wrap { position: relative; }
.chart-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ---------------------------
   Cashflow calendar (Budget)
--------------------------- */
.cf-summary{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:10px;
  margin-bottom:12px;
}
@media (max-width: 980px){
  .cf-summary{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.cf-kpi{
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(255,255,255,.02);
  padding:10px 12px;
}
.cf-kpi .big{ font-weight:900; font-size:18px; margin-top:4px; }

.cf-calendar{
  margin-top:12px;
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(255,255,255,.02);
  overflow:hidden;
}

.cf-weekhead, .cf-week{
  display:grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cf-weekhead div{
  padding:10px 10px;
  font-weight:900;
  font-size:12px;
  color: var(--muted);
  border-bottom:1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.02);
}

.cf-day{
  min-height:110px;
  padding:10px 10px;
  border-right:1px solid rgba(255,255,255,.06);
  border-bottom:1px solid rgba(255,255,255,.06);
  cursor:pointer;
  position:relative;
}
.cf-day:nth-child(7n){ border-right:none; }

.cf-day .d-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
}
.cf-day .d-num{
  font-weight:900;
  font-size:12px;
}
.cf-day .d-tag{
  font-size:11px;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  color: var(--muted);
  background: rgba(255,255,255,.04);
}

.cf-day .d-rows{ margin-top:8px; font-size:12px; }
.cf-row{ display:flex; justify-content:space-between; gap:10px; }
.cf-row .k{ color: var(--muted); }
.cf-row .v{ font-weight:800; }

.cf-day.dim{ opacity:.35; cursor:default; }
.cf-day:hover{ background: rgba(110,168,254,.06); }

.cf-netpos{ color: rgba(90, 200, 120, .95); }
.cf-netneg{ color: rgba(252, 50, 32, .95); }

.cf-run{
  position:absolute;
  right:10px;
  bottom:10px;
  font-size:11px;
  color: var(--muted);
}

/* Drawer */
.cf-drawer{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.35);
  display:none;
  z-index: 999;
}
.cf-drawer.open{ display:block; }
.cf-drawer-panel{
  position:absolute;
  right:0;
  top:0;
  height:100%;
  width: min(520px, 92vw);
  background: rgba(245,248,255,.96);
  border-left: 1px solid var(--line);
  padding: 14px;
  overflow:auto;
}
.cf-drawer-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  padding-bottom:10px;
  border-bottom:1px solid rgba(0,0,0,.06);
}
.cf-drawer-body{ padding-top:10px; }
.cf-drawer-kpis{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:10px;
}
.cf-drawer-kpis .mini{
  border:1px solid rgba(0,0,0,.10);
  border-radius:14px;
  padding:10px 12px;
  background: rgba(255,255,255,.6);
}
.cf-drawer-kpis .mini div:last-child{
  font-weight:900;
  margin-top:4px;
}
.cf-lines{
  margin-top:8px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.cf-line{
  border:1px solid rgba(0,0,0,.10);
  border-radius:14px;
  padding:10px 12px;
  background: rgba(255,255,255,.6);
}
.cf-line .top{
  display:flex;
  justify-content:space-between;
  gap:10px;
}
.cf-line .lbl{ font-weight:900; }
.cf-line .amt{ font-weight:900; }
.cf-line .meta{ margin-top:4px; font-size:11px; color: rgba(0,0,0,.55); 
}

.cf-add{ margin-top:8px; }
.cf-add-row{ margin-top:10px; }
.cf-add-actions{ display:flex; gap:10px; flex-wrap:wrap; margin-top:10px; }

/* =========================================================
   Transactions page — match Budget layout + calendar styling
   (CSS-only fixes)
========================================================= */

/* 1) Match Budget's max-width container on pages that don't wrap in .container */
.main > .topbar,
.main > header.topbar,
.main > section.grid {
  max-width: 1150px;
  margin-left: auto;
  margin-right: auto;
}

/* Give the Transactions header a little breathing room like Budget */
.main > .topbar,
.main > header.topbar {
  margin-bottom: 16px;
}

/* 2) Recurring Rules collapse: your HTML uses .rr-body, not #rr-body */
.rr-body {
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 280ms ease, opacity 220ms ease, transform 220ms ease;
}

#rr-card.is-collapsed .rr-body {
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

/* 3) Drawer open state: support both .open (Budget) and .is-open (some tx code) */
.cf-drawer.is-open { display: block; }

/* 4) Calendar compatibility:
      Budget uses: .cf-weekhead / .cf-week / .cf-day
      Some Transactions renderers use: .cf-cal-grid / .cf-cal-cell (etc.)
      These aliases ensure Transactions still looks like Budget.
*/

/* Calendar wrapper already styled as .cf-calendar in your CSS — keep it. */

/* If a renderer outputs a grid container */
.cf-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

/* Optional header row */
.cf-cal-head,
.cf-cal-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cf-cal-head > div,
.cf-cal-header > div {
  padding: 10px 10px;
  font-weight: 900;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.02);
}

/* Calendar cells */
.cf-cal-cell,
.cf-cal-day {
  min-height: 110px;
  padding: 10px 10px;
  border-right: 1px solid rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.06);
  cursor: pointer;
  position: relative;
}

.cf-cal-cell:nth-child(7n),
.cf-cal-day:nth-child(7n) { border-right: none; }

.cf-cal-cell.dim,
.cf-cal-day.dim { opacity: .35; cursor: default; }

.cf-cal-cell:hover,
.cf-cal-day:hover { background: rgba(110,168,254,.06); }

/* Common inner layout helpers used by Budget calendar */
.cf-cal-cell .d-top,
.cf-cal-day .d-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.cf-cal-cell .d-num,
.cf-cal-day .d-num {
  font-weight: 900;
  font-size: 12px;
}

.cf-cal-cell .d-tag,
.cf-cal-day .d-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  color: var(--muted);
  background: rgba(255,255,255,.04);
}

.cf-cal-cell .d-rows,
.cf-cal-day .d-rows {
  margin-top: 8px;
  font-size: 12px;
}

/* Net colouring same as Budget */
.cf-cal-cell .cf-netpos,
.cf-cal-day .cf-netpos { color: rgba(90, 200, 120, .95); }

.cf-cal-cell .cf-netneg,
.cf-cal-day .cf-netneg { color: rgba(252, 50, 32, .95); }

/* =========================================================
   Transactions calendar (cf-cal-*) — style to match Budget
   Your Budget uses .cf-day grid.
   Transactions uses .cf-cal-grid + .cf-cal-cell button grid.
========================================================= */

/* Make drawer show for both states (Budget uses .open, tx JS uses .is-open) */
.cf-drawer.is-open { display: block; }
.cf-drawer.open { display: block; } /* keep as-is */

/* Header row on Transactions calendar */
.cf-cal-head{
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:12px 12px;
  border-bottom:1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.02);
}
.cf-cal-title{
  font-weight:900;
  font-size:14px;
}
.cf-cal-legend{
  font-size:12px;
}

/* Grid wrapper */
.cf-cal-grid{
  display:grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

/* DOW labels */
.cf-cal-dow{
  padding:10px 10px;
  font-weight:900;
  font-size:12px;
  color: var(--muted);
  border-bottom:1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.02);
}

/* Day cell buttons — reset button defaults + match .cf-day */
.cf-cal-cell{
  /* reset button look */
  appearance:none;
  -webkit-appearance:none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;

  /* match budget day cell */
  min-height:110px;
  padding:10px 10px;
  border-right:1px solid rgba(255,255,255,.06);
  border-bottom:1px solid rgba(255,255,255,.06);
  cursor:pointer;
  position:relative;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.cf-cal-cell:nth-child(7n){ border-right:none; }

.cf-cal-cell:hover{
  background: rgba(110,168,254,.06);
}

.cf-cal-cell:focus{
  outline: 2px solid rgba(110,168,254,.35);
  outline-offset: -2px;
}

/* Out-of-month look */
.cf-cal-cell.is-out{
  opacity:.35;
}

/* The "day number" row */
.cf-cal-day{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  font-weight:900;
  font-size:12px;
}

/* Badge same vibe as Budget pills/tags */
.cf-cal-day .cf-badge{
  font-size:11px;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  color: var(--muted);
  background: rgba(255,255,255,.04);
}

/* Totals */
.cf-cal-total{
  font-weight:900;
  font-size:13px;
  line-height:1.1;
}

/* Sub line */
.cf-cal-sub{
  font-size:12px;
}

/* Make sure calendar inherits the same framed container as Budget */
#tx-calendar.cf-calendar{
  margin-top:12px; /* already in .cf-calendar, but keep consistent */
}

/* Optional: remove the “thick black grid” feeling on some browsers */
.cf-cal-cell{
  box-shadow: none;
}

/* =========================================================
   Form controls — make Transactions inputs match Savings/Pots
========================================================= */

.input,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="email"],
input[type="search"],
input[type="tel"],
input[type="url"],
textarea,
select{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.35);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: box-shadow .12s ease, border-color .12s ease, background .12s ease;
}

/* Slightly “flatter” look in cards, like Savings */
.card .input,
.card input,
.card textarea,
.card select{
  background: rgba(255,255,255,.30);
}

/* Placeholder */
.input::placeholder,
input::placeholder,
textarea::placeholder{
  color: rgba(34,34,34,.45);
}

/* Focus ring consistent with the rest of the UI */
.input:focus,
input:focus,
textarea:focus,
select:focus{
  border-color: rgba(110,168,254,.55);
  box-shadow: 0 0 0 2px rgba(110,168,254,.25);
  background: rgba(255,255,255,.42);
}

/* Select dropdown arrow spacing */
select{
  cursor: pointer;
}

/* Ensure date/month don’t shrink text or look “native ugly” */
input[type="date"],
input[type="month"]{
  min-height: 40px;
}

/* Labels above inputs (you already use .muted for these) */
label.muted,
.muted{
  font-size: 12px;
}

/* Stop chrome/yellow autofill wrecking the cream theme */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill{
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px rgba(255,255,255,.35) inset;
  transition: background-color 9999s ease-in-out 0s;
}

/* Fix Transactions content being pulled under the header */
#tx-calendar {
  scroll-margin-top: 80px;
}

.main > section.grid {
  padding-top: 70px; /* adjust if needed */
}

/* ===== TRANSACTION CALENDAR ===== */

.calendar-header{
display:flex;
justify-content:space-between;
align-items:center;
margin-bottom:10px;
}

.calendar-grid{
display:grid;
grid-template-columns:repeat(7,1fr);
gap:8px;
}

.cal-day{
border:1px solid #e5e5e5;
border-radius:10px;
padding:8px;
min-height:90px;
cursor:pointer;
background:white;
}

.cal-day:hover{
background:#fafafa;
}

.cal-date{
font-weight:700;
margin-bottom:4px;
}

.cal-stat{
font-size:12px;
display:flex;
justify-content:space-between;
}

.cal-in{
color:#1f8f4f;
}

.cal-out{
color:#c93b3b;
}

/* ===== DRAWER ===== */

.drawer{
position:fixed;
right:-420px;
top:0;
width:420px;
height:100%;
background:white;
box-shadow:-3px 0 15px rgba(0,0,0,.1);
transition:.3s;
z-index:100;
}

.drawer.open{
right:0;
}

.drawer-inner{
padding:20px;
height:100%;
overflow:auto;
}

.drawer-header{
display:flex;
justify-content:space-between;
align-items:center;
margin-bottom:10px;
}

.drawer-summary{
font-size:13px;
margin-bottom:16px;
}

.tx-pill{
display:inline-block;
padding:3px 8px;
border-radius:8px;
font-size:11px;
margin-right:6px;
}

.pill-in{background:#e6f7ed;color:#1f8f4f;}
.pill-out{background:#fde8e8;color:#c93b3b;}
.pill-planned{border:1px dashed #bbb;}
.pill-cleared{border:1px solid #bbb;}

.tx-row{
border-bottom:1px solid #eee;
padding:10px 0;
}
/* ============================================================
   MOBILE OVERHAUL
   - Sidebar becomes an off-canvas drawer with a hamburger
   - Everything stacks to one column on phones
   - Tables fit the screen instead of forcing horizontal scroll
   (Injected hamburger/backdrop elements come from app.js.)
   ============================================================ */

/* Hidden on desktop; enabled inside the media query below */
.ft-hamburger, .ft-navbackdrop { display: none; }

@media (max-width: 980px) {
  /* --- Off-canvas drawer navigation --- */
  .sidebar {
    display: block;                 /* override the old display:none */
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(82vw, 300px);
    z-index: 1400;
    background: var(--bg);          /* solid, not translucent */
    border-right: 1px solid var(--line);
    box-shadow: 0 14px 40px rgba(0,0,0,.20);
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }   /* lock background scroll while menu open */

  .ft-navbackdrop {
    display: block;
    position: fixed; inset: 0; z-index: 1300;
    background: rgba(0,0,0,.4);
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
  }
  body.nav-open .ft-navbackdrop { opacity: 1; pointer-events: auto; }

  .ft-hamburger {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 10px; left: 10px; z-index: 1200;
    width: 46px; height: 46px; border-radius: 13px;
    border: 1px solid var(--line); background: #fff;
    box-shadow: var(--shadow1); cursor: pointer; padding: 0;
  }
  .ft-hamburger span {
    position: relative; display: block;
    width: 20px; height: 2px; background: var(--text); border-radius: 2px;
  }
  .ft-hamburger span::before,
  .ft-hamburger span::after {
    content: ""; position: absolute; left: 0;
    width: 20px; height: 2px; background: var(--text); border-radius: 2px;
  }
  .ft-hamburger span::before { top: -6px; }
  .ft-hamburger span::after  { top: 6px; }

  .main { padding: 14px; padding-top: 66px; } /* clear the fixed hamburger */
  .container { max-width: 100%; }
}

@media (max-width: 620px) {
  /* --- Stack everything to a single column --- */
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .grid > [class*="span-"] { grid-column: 1 / -1; }

  /* --- Topbar stacks; controls go full width --- */
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .topbar > div { width: 100%; }
  .topbar .card { width: 100%; }

  /* --- Tables fit the screen instead of forcing 980px scroll --- */
  .table-wrap .table { min-width: 0; }
  .table th, .table td {
    white-space: normal;
    word-break: break-word;
    padding: 8px 8px;
    font-size: 13px;
  }
  .table td:first-child { min-width: 0; }

  /* iOS: inputs at 16px stop the annoying zoom-on-focus */
  input, select, textarea { font-size: 16px; }

  .main { padding: 12px; padding-top: 64px; }
  h2 { font-size: 20px; }
}

/* ============================================================
   MOBILE OVERHAUL v2
   Form stacking (beats inline grid styles), cardified data
   tables, compact calendars, dashboard panel order.
   ============================================================ */
@media (max-width: 620px) {

  /* --- Force every grid (including inline repeat(12,1fr) forms) to stack --- */
  .grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .grid > * { grid-column: 1 / -1 !important; }
  .input, select, textarea, input { width: 100%; }

  /* Direct-child / submit buttons go full width & easy to tap */
  .grid > button, .grid > .pill, form > button, form .pill { width: 100%; }

  /* Stop stray wide children scrolling the whole page sideways */
  .main { overflow-x: hidden; }

  /* --- CARDIFY: turn wide tables into label:value cards --- */
  table.ft-cardify thead { display: none; }
  table.ft-cardify,
  table.ft-cardify tbody,
  table.ft-cardify tr,
  table.ft-cardify td { display: block; width: 100%; }
  table.ft-cardify tr {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card, #fff);
    padding: 6px 12px;
    margin-bottom: 10px;
  }
  table.ft-cardify td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; text-align: right;
    padding: 7px 0; border: none; min-height: 0;
    white-space: normal; word-break: break-word;
  }
  table.ft-cardify td::before {
    content: attr(data-label);
    font-weight: 700; color: var(--muted);
    text-align: left; white-space: nowrap; margin-right: auto;
  }
  table.ft-cardify td.ft-nolabel { justify-content: center; }
  table.ft-cardify td.ft-nolabel::before { content: none; }
  table.ft-cardify td:empty { display: none; }

  /* --- Transactions calendar: compact 7-col --- */
  .calendar-grid { gap: 4px; }
  .cal-day { min-height: 54px; padding: 5px; border-radius: 8px; }
  .cal-date { font-size: 12px; margin-bottom: 2px; }
  .cal-stat { font-size: 10px; }

  /* --- Budget cashflow calendar: compact --- */
  .cf-summary { grid-template-columns: 1fr 1fr; }
  .cf-weekhead div { padding: 6px 2px; font-size: 10px; }
  .cf-day { min-height: 0; padding: 5px 3px; }
  .cf-day .d-num { font-size: 12px; }
  .cf-day .d-tag { font-size: 9px; }
  .cf-day .d-rows { display: none; } /* too dense on a phone — tap a day for detail */

  /* Wide scroll containers must not exceed the screen */
  .goals-gantt-wrap, .table-wrap { max-width: 100%; }
}
