/* ═══════════════════════════════════════════
   CSS CUSTOM PROPERTIES
═══════════════════════════════════════════ */
:root {
  /* ── Colour tokens ── */
  --bg:        #0b0d11;
  --surface:   #111318;
  --surface2:  #171a22;
  --surface3:  #1e222e;
  --border:    #222634;
  --border2:   #2c3145;
  --text:      #dde1ee;
  --text2:     #7f8aa6;
  --text3:     #444c66;
  --accent:    #1a9955;
  --accent-h:  #147a42;
  --accent-dim: rgba(26,153,85,0.12);
  --gold:      #e8a318;
  --gold-dim:  rgba(232,163,24,0.12);
  --red:       #d94040;
  --red-dim:   rgba(217,64,64,0.12);
  --green:     #28c775;
  --green-dim: rgba(40,199,117,0.1);

  /* ── Layout ── */
  --header-h:  60px;
  --sidebar-w: 200px;   /* JS may override via drag */
  --radius:    10px;

  /* ── UI Scale — change this one value to resize the whole app ──
     100 = original design density
     130 = recommended (comfortable reading)
     150 = large / accessibility             */
  --ui-scale: 130;

  /* ── Derived font sizes (scale × base ÷ 100) ──
     Base sizes are the original design values.
     calc() can't multiply two var()s, so we use
     a single unitless scale factor via font-size
     on :root and em units below.               */
  --f-base:  calc(14px * var(--ui-scale) / 100);   /* 18.2px @ 130 */
  --f-sm:    calc(12px * var(--ui-scale) / 100);   /* 15.6px */
  --f-xs:    calc(10px * var(--ui-scale) / 100);   /* 13.0px */
  --f-xxs:   calc( 9px * var(--ui-scale) / 100);   /* 11.7px */
  --f-micro: calc( 8px * var(--ui-scale) / 100);   /* 10.4px */
  --f-lg:    calc(16px * var(--ui-scale) / 100);   /* 20.8px */
  --f-xl:    calc(20px * var(--ui-scale) / 100);   /* 26.0px */
  --f-2xl:   calc(24px * var(--ui-scale) / 100);   /* 31.2px */
}

/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--f-base);
  -webkit-font-smoothing: antialiased;
}

/* Subtle noise grain overlay on body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ═══════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ═══════════════════════════════════════════
   HEADER
═══════════════════════════════════════════ */
#header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px 0 0;
  gap: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 300;
}

/* Brand */
.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}
.brand-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--f-xl);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1;
}
.brand-sub {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text3);
  line-height: 1;
}

/* Header left block — tracks sidebar width via --sidebar-w, border aligns with sidebar */
.header-left {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-right: 1px solid var(--border2);
  height: 100%;
  transition: width 0s, min-width 0s; /* instant during drag */
}

/* ── Sidebar drag handle ── */
#sidebar-drag-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 200;
  background: transparent;
  transition: background 0.15s;
}
#sidebar-drag-handle:hover,
#sidebar-drag-handle.dragging {
  background: var(--accent);
  opacity: 0.5;
}

/* Status pills sit to the right of the divider line */
.status-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  flex-shrink: 0;
}
.pill {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-xxs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 5px;
}
.pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pill.auth-signed-in  { color: var(--green); border-color: rgba(40,199,117,0.25); background: var(--green-dim); }
.pill.auth-signed-out { color: var(--text3); border-color: var(--border); background: transparent; }
.pill.tier-pro  { color: var(--gold); border-color: rgba(232,163,24,0.3); background: var(--gold-dim); }
.pill.tier-free { color: var(--text3); border-color: var(--border); background: transparent; }

/* Header actions pushed to right */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding-left: 14px;
}

/* Buttons */
.btn {
  font-size: var(--f-sm);
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  transition: background 0.13s, color 0.13s, border-color 0.13s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; }

.btn-edit { }
.btn-edit.active { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }

.btn-signout { }
.btn-signout:hover { background: var(--red-dim); border-color: rgba(217,64,64,0.4); color: var(--red); }

.btn-signin { }
.btn-signin:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* Mobile: hide sign out label, keep sign in label visible */
@media (max-width: 600px) {
  #btn-auth-toggle.btn-signout .btn-label { display: none; }
  #btn-auth-toggle.btn-signin .btn-label  { display: inline; }
}

.btn-danger { background: var(--red-dim); border-color: rgba(217,64,64,0.4); color: var(--red); }
.btn-danger:hover { background: rgba(217,64,64,0.2); }

.btn svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ═══════════════════════════════════════════
   MAIN BODY
═══════════════════════════════════════════ */
#body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  overflow: hidden;
  transition: transform 0.25s ease;
  position: relative; /* needed for absolute team-section */
}
#sidebar.hidden {
  transform: translateX(calc(-1 * var(--sidebar-w)));
  width: 0;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.sb-section { flex-shrink: 0; }

/* Transactions: capped at 50vh so teams always visible */
#tx-list-wrap {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
  max-height: calc(50vh - 88px); /* 50vh minus header bar + label row */
  flex-shrink: 0;
}

/* Teams: absolutely pinned to start at exactly 50vh */
#team-section {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  z-index: 2;
}

#team-list-wrap {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
  flex: 1;
}

.sb-label {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
}

.sb-count {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-xxs);
  color: var(--text3);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 10px;
}

.sb-list {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
  flex: 1;
}

/* Transaction row */
.tx-row {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  gap: 9px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.12s;
  cursor: default;
  position: relative;
}
.tx-row:hover { background: var(--surface2); }
.tx-row.edit-highlight {
  cursor: pointer;
  outline: 1px solid var(--gold);
  outline-offset: -1px;
  background: var(--gold-dim);
}
.tx-row.edit-highlight:hover { background: rgba(232,163,24,0.18); }

/* Past-closing greyed state */
.tx-row.tx-closed {
  opacity: 0.38;
  filter: grayscale(0.7);
  pointer-events: auto;
}
.tx-row.tx-closed:hover { background: var(--surface2); opacity: 0.48; }
.tx-closed-label {
  font-size: var(--f-xxs);
  font-family: 'DM Mono', monospace;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.tx-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tx-info { flex: 1; min-width: 0; }
.tx-name {
  font-size: var(--f-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.tx-sub {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-xxs);
  color: var(--text3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Notification bubble */
.notif-btn {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-size: var(--f-xs);
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  transition: transform 0.15s, background 0.15s;
  position: relative;
}
.notif-btn:hover { transform: scale(1.12); background: #b83030; }
.notif-btn.empty {
  background: transparent;
  border: 1px dashed var(--border2);
  color: var(--text3);
  font-size: var(--f-xxs);
}
.notif-btn.empty:hover { border-color: var(--text3); color: var(--text2); }

/* Team row */
.team-row {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  gap: 9px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.12s;
  cursor: default;
}
.team-row:hover { background: var(--surface2); }
.team-row.edit-highlight {
  cursor: pointer;
  outline: 1px solid var(--gold);
  outline-offset: -1px;
  background: var(--gold-dim);
}

.team-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--f-base);
  flex-shrink: 0;
}

.team-info { flex: 1; min-width: 0; }
.team-name {
  font-size: var(--f-sm);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-meta {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-xxs);
  color: var(--text3);
  margin-top: 2px;
}

.pro-tag {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(232,163,24,0.3);
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sb-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.sb-empty {
  padding: 16px 14px;
  font-size: var(--f-sm);
  color: var(--text3);
  font-style: italic;
  text-align: center;
}


/* ═══════════════════════════════════════════
   CALENDAR AREA
═══════════════════════════════════════════ */
#cal-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* overflow must NOT be hidden — it breaks sticky and squareCalendar measurements */
  overflow: hidden;
  position: relative;
  min-width: 0;
}

/* ═══════════════════════════════════════════
   PRO TOOLS TOOLBAR
   — normal flex child, flex-shrink:0 keeps it
     pinned at top of the column naturally
═══════════════════════════════════════════ */
#pro-toolbar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  height: 46px;
  /* no position:sticky — flex column order handles this */
}

/* Each tool slot */
.pro-tool {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 100%;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.13s;
  position: relative;
  min-width: 0;
}
.pro-tool:last-child { border-right: none; }
.pro-tool:hover { background: var(--surface2); }
.pro-tool.disabled { cursor: not-allowed; opacity: 1; }
.pro-tool.disabled:hover { background: transparent; }

/* Tool icon circle */
.pro-tool-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--f-base);
  flex-shrink: 0;
  background: var(--surface3);
  border: 1px solid var(--border2);
  transition: background 0.13s, border-color 0.13s;
}
.pro-tool:hover:not(.disabled) .pro-tool-icon {
  background: var(--gold-dim);
  border-color: rgba(232,163,24,0.3);
}

.pro-tool-text { flex: 1; min-width: 0; }
.pro-tool-name {
  font-size: var(--f-sm);
  font-weight: 500;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}
.pro-tool:hover:not(.disabled) .pro-tool-name { color: var(--text); }

.pro-tool-hint {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-micro);
  color: var(--text3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lock badge */
.tool-lock {
  font-size: var(--f-xs);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  font-size: var(--f-micro);
  letter-spacing: 0.06em;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}
.tool-lock.unlocked {
  background: var(--gold-dim);
  border-color: rgba(232,163,24,0.25);
  color: var(--gold);
}

/* Drop zone inline (for import loop) */
#loop-dropzone {
  flex: 1;
  height: 28px;
  border: 1.5px dashed var(--border2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface2);
  font-size: var(--f-sm);
  color: var(--text3);
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
}
#loop-dropzone:hover,
#loop-dropzone.dragover {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--text2);
}
#loop-dropzone.dragover { border-style: solid; }
#loop-dropzone.file-loaded {
  border-color: var(--green);
  border-style: solid;
  background: var(--green-dim);
  color: var(--green);
}

/* Hidden file input */
#loop-file-input { display: none; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Calendar nav bar — centered */
#cal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.cal-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  font-size: var(--f-lg);
  line-height: 1;
}
.cal-nav-btn:hover { background: var(--surface3); color: var(--text); }

#cal-month-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--f-xl);
  font-weight: 600;
  color: var(--text);
  min-width: 190px;
  text-align: center;
  line-height: 1;
}

.cal-today-btn {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-xxs);
  letter-spacing: 0.08em;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  transition: all 0.12s;
}
.cal-today-btn:hover { color: var(--text2); border-color: var(--text3); }

/* Calendar grid wrap — grid pins to top, centered horizontally */
#cal-grid-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  padding: 12px 16px 12px;
}

/* cal-inner: width AND height set by squareCalendar() in JS */
#cal-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
}

#cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  padding: 0 0 4px;
  flex-shrink: 0;
}

.cal-weekday {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-xxs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  text-align: center;
  padding: 3px 0;
}

/* Grid: columns fixed, rows fixed — both driven by JS */
#cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 3px;
  flex-shrink: 0;
  /* width + height set by squareCalendar() */
}

/* Calendar day cell */
.cal-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 7px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  transition: background 0.12s;
  position: relative;
  min-height: 0;
}
.cal-day:hover { background: var(--surface2); }

.cal-day.other-month { opacity: 0.35; }

.cal-day.today {
  border-color: var(--accent);
  background: rgba(40,199,117,0.07);
}
.cal-day.today .cal-day-num {
  color: var(--accent);
  font-weight: 600;
}

.cal-day-num {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-sm);
  color: var(--text3);
  line-height: 1;
  flex-shrink: 0;
}

.cal-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}

/* Event pill inside calendar day */
.cal-event-pill {
  font-size: var(--f-xxs);
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  line-height: 1.3;
  opacity: 0.9;
  cursor: pointer;
  transition: opacity 0.12s;
}
.cal-event-pill:hover { opacity: 1; }

.cal-event-more {
  font-size: var(--f-xxs);
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  padding: 1px 5px;
}

/* ═══════════════════════════════════════════
   OVERLAY SYSTEM — calendar always shows behind
═══════════════════════════════════════════ */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 14, 0.75);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadein 0.18s ease;
  transition: opacity 0.15s ease;
}
.overlay-backdrop.hidden {
  display: none;
}
/* Auth overlay specifically gets a faster hide when restoring session */
#auth-overlay.hiding {
  opacity: 0;
  pointer-events: none;
}

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: slideup 0.2s ease;
  position: relative;
}

@keyframes slideup {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  padding: 20px 22px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--f-xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.modal-sub {
  font-size: var(--f-sm);
  color: var(--text3);
  margin-top: 3px;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--f-lg);
  flex-shrink: 0;
  transition: all 0.12s;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body { padding: 18px 22px 22px; }

/* Form elements */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: var(--f-sm);
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}
.form-label .req { color: var(--red); margin-left: 2px; }
.form-label .opt {
  font-size: var(--f-xxs);
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.08em;
  margin-left: 5px;
}

.form-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: var(--f-base);
  transition: border-color 0.13s;
  appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
}
.form-input::placeholder { color: var(--text3); }

/* Color swatches */
.color-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* iOS-style toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface3);
  border-radius: 22px;
  border: 1px solid var(--border2);
  transition: background 0.2s, border-color 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text3);
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: #fff;
}
.toggle-switch input:disabled + .toggle-track {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Reminder row highlight when team assigned */
.reminder-row-lit {
  border-color: rgba(26,153,85,0.5) !important;
  background: rgba(26,153,85,0.06) !important;
}

/* Pro gate overlay flex fix */
#tx-team-gate, #tx-reminder-gate {
  display: none;
}
#tx-team-gate.active, #tx-reminder-gate.active {
  display: flex;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  position: relative;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected {
  border-color: #fff;
  transform: scale(1.1);
}
.color-swatch.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: var(--f-sm);
  font-weight: 700;
}

/* Deadlines section */
.deadlines-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text2);
  font-size: var(--f-sm);
  text-align: left;
  transition: all 0.12s;
}
.deadlines-toggle:hover { background: var(--surface2); color: var(--text); }
.deadlines-toggle .toggle-arrow { margin-left: auto; transition: transform 0.2s; }
.deadlines-toggle.open .toggle-arrow { transform: rotate(180deg); }

.deadlines-body {
  display: none;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}
.deadlines-body.open { display: block; }

.deadline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  align-items: start; /* prevent cells stretching to match tallest sibling */
}
@media (max-width: 480px) {
  .deadline-grid { grid-template-columns: 1fr; }
}

/* Deadline completion toggle row */
.deadline-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.deadline-complete-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  margin-bottom: 2px;
}
.deadline-complete-row label {
  font-size: 10px;
  color: var(--text3);
  cursor: pointer;
  user-select: none;
  line-height: 1.3;
}
.deadline-complete-row input[type=checkbox] {
  accent-color: var(--accent);
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  cursor: pointer;
}
/* Tighten form-group spacing inside deadline grid and required row */
.deadline-grid .form-group,
.form-row .form-group {
  margin-bottom: 0;
}
/* "optional" tag on its own line under deadline label */
.dl-opt {
  display: block;
  font-size: var(--f-xxs);
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.08em;
  margin: 1px 0 4px 0;
  padding: 0;
  line-height: 1;
}

/* Greyed state: completed or no date entered */
.deadline-field-wrap.dl-complete .form-label,
.deadline-field-wrap.dl-empty .form-label {
  color: var(--text3);
}
.deadline-field-wrap.dl-complete input[type=date] {
  opacity: 0.4;
  text-decoration: line-through;
}
.deadline-field-wrap.dl-empty input[type=date] {
  opacity: 0.4;
}
.deadline-field-wrap.dl-complete .deadline-complete-row label {
  color: var(--accent);
}

/* Form row (two columns) */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Form actions */
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Section divider inside modal */
.modal-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ─── AUTH MODAL specific ─── */
#auth-modal .auth-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border2);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  color: var(--text3);
  font-size: var(--f-sm);
  font-weight: 500;
  transition: all 0.15s;
}
.auth-tab.active { background: var(--accent); color: #fff; }

.auth-brand {
  text-align: center;
  margin-bottom: 22px;
  padding-top: 4px;
}
.auth-brand-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--f-2xl);
  font-weight: 700;
  color: var(--text);
}
.auth-brand-sub {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-xxs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text3);
  margin-top: 4px;
}

/* ─── EDIT ACTION PANEL ─── */
#edit-panel {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7,9,14,0.75);
  backdrop-filter: blur(4px);
  animation: fadein 0.15s ease;
}
#edit-panel.hidden { display: none; }

.edit-panel-modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 380px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: slideup 0.18s ease;
  overflow: hidden;
}
.edit-panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.edit-panel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.edit-panel-name {
  font-size: var(--f-base);
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.edit-panel-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.edit-panel-cancel {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

/* ─── NOTIFICATION POPOVER ─── */
.notif-popover {
  position: fixed;
  z-index: 600;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  width: 240px;
  overflow: hidden;
  animation: fadein 0.15s ease;
}
.notif-popover.hidden { display: none; }

.notif-pop-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: var(--f-sm);
  font-weight: 600;
  color: var(--text2);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.06em;
}

.notif-pop-item {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  gap: 8px;
}
.notif-pop-item:last-child { border-bottom: none; }

.notif-pop-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.notif-pop-label {
  flex: 1;
  font-size: var(--f-sm);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-pop-days {
  font-family: 'DM Mono', monospace;
  font-size: var(--f-xs);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  flex-shrink: 0;
}
.notif-pop-days.urgent { background: var(--red-dim); color: var(--red); }
.notif-pop-days.soon   { background: var(--gold-dim); color: var(--gold); }
.notif-pop-days.ok     { background: rgba(40,199,117,0.1); color: var(--green); }

.notif-pop-empty {
  padding: 14px 12px;
  font-size: var(--f-sm);
  color: var(--text3);
  text-align: center;
  font-style: italic;
}

/* ─── Day event popover ─── */
.day-popover {
  position: fixed;
  z-index: 600;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  width: 200px;
  overflow: hidden;
  animation: fadein 0.15s ease;
}
.day-popover.hidden { display: none; }

.day-pop-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: var(--f-xs);
  font-family: 'DM Mono', monospace;
  color: var(--text3);
  letter-spacing: 0.08em;
}
.day-pop-item {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  gap: 8px;
}
.day-pop-item:last-child { border-bottom: none; }
.day-pop-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.day-pop-text { font-size: var(--f-sm); color: var(--text); }
.day-pop-type { font-size: var(--f-xxs); color: var(--text3); font-family: 'DM Mono', monospace; }

/* ─── PRO upgrade prompt ─── */
#pro-modal .pro-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}
.pro-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--f-base);
  color: var(--text2);
}
.pro-feature-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--gold-dim);
  border: 1px solid rgba(232,163,24,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--f-base);
  flex-shrink: 0;
}

/* ─── Upgrade banner in sidebar ─── */
.upgrade-nudge {
  margin: 10px 14px;
  padding: 10px 12px;
  background: var(--gold-dim);
  border: 1px solid rgba(232,163,24,0.2);
  border-radius: 8px;
  font-size: var(--f-sm);
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.upgrade-nudge:hover { background: rgba(232,163,24,0.2); }

/* ─── Toast notification ─── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: var(--f-sm);
  color: var(--text);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideup 0.2s ease, fadeout 0.3s ease 2.5s forwards;
  pointer-events: none;
  min-width: 200px;
  max-width: 320px;
}
.toast-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
@keyframes fadeout { to { opacity: 0; transform: translateY(6px); } }

/* ═══════════════════════════════════════════
   UTILITIES
═══════════════════════════════════════════ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt4 { margin-top: 4px; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.w100 { width: 100%; }
.flex-center { display: flex; align-items: center; justify-content: center; }

/* ─── Scrollbar styling ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ═══════════════════════════════════════════
   MOBILE & RESPONSIVE
   Breakpoints:
     Tablet  ≤ 900px  — sidebar becomes a drawer
     Mobile  ≤ 600px  — bottom tab bar, FAB, full-width layout
═══════════════════════════════════════════ */

/* ── Hamburger button (hidden on desktop) ── */
.btn-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
}
.btn-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text2);
  border-radius: 2px;
  transition: background 0.15s;
}
.btn-hamburger:hover span { background: var(--text); }

/* ── Sidebar close button (hidden on desktop) ── */
.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text3);
  font-size: var(--f-base);
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.12s;
}
.sidebar-close-btn:hover { background: var(--surface3); color: var(--text); }

/* ── Sidebar overlay (mobile tap-to-close) ── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7,9,14,0.6);
  backdrop-filter: blur(2px);
  z-index: 90;
}
#sidebar-overlay.active { display: block; }

/* ── Mobile FAB speed-dial ── */
#fab-container {
  display: none;
  position: fixed;
  bottom: calc(56px + 16px);
  right: 16px;
  z-index: 200;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 10px;
}
/* Main + button */
.mobile-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  box-shadow: 0 4px 20px rgba(26,153,85,0.45);
  align-items: center;
  justify-content: center;
  transition: background 0.13s, transform 0.2s;
  display: flex;
  flex-shrink: 0;
  cursor: pointer;
}
.mobile-fab:hover { background: var(--accent-h); }
.mobile-fab svg { width: 22px; height: 22px; }
/* Rotate + to × when open */
#fab-container.open .mobile-fab { transform: rotate(45deg); }

/* Speed-dial action buttons */
.fab-actions {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 8px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  pointer-events: none;
}
#fab-container.open .fab-actions {
  max-height: 300px;
  opacity: 1;
  pointer-events: auto;
}
.fab-action {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.fab-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  transition: background 0.13s, color 0.13s;
  flex-shrink: 0;
}
.fab-action:hover .fab-action-btn { background: var(--surface3); color: var(--text); }
.fab-action-label {
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.06em;
  color: var(--text2);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 4px 8px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.fab-action-edit-active .fab-action-btn {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}

/* ── Mobile bottom tab bar ── */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 300;
  flex-direction: row;
}
.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 9px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 0;
  transition: color 0.13s;
  cursor: pointer;
}
.mobile-tab svg { width: 18px; height: 18px; }
.mobile-tab.active { color: var(--accent); }
.mobile-tab.active svg { stroke: var(--accent); }

/* ═══════════════════════════════════════════
   TABLET — ≤ 900px
   Sidebar becomes a slide-in drawer
═══════════════════════════════════════════ */
@media (max-width: 900px) {

  /* Show hamburger */
  .btn-hamburger { display: flex; }

  /* Show sidebar close button */
  .sidebar-close-btn { display: flex; }

  /* Header-left becomes just the brand, no fixed width */
  .header-left {
    width: auto;
    min-width: 0;
    border-right: none;
    padding: 0 12px;
  }

  /* Drag handle hidden on tablet/mobile — sidebar is a drawer */
  #sidebar-drag-handle { display: none; }

  /* Sidebar: fixed drawer, slides in from left */
  #sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100% - var(--header-h));
    width: 280px !important; /* fixed drawer width, ignore --sidebar-w */
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
    box-shadow: 4px 0 32px rgba(0,0,0,0.4);
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Calendar takes full width */
  #cal-area { width: 100%; }

  /* Pro toolbar: 2-column grid on tablet */
  #pro-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: auto;
  }
  .pro-tool {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    height: 44px;
  }
  .pro-tool:nth-child(2) { border-right: none; }
  .pro-tool:last-child {
    grid-column: 1 / -1;
    border-bottom: none;
    border-right: none;
  }

  /* Shrink button labels on tablet */
  .btn-label { display: none; }
  .btn { padding: 8px 10px; }
  .btn svg { width: 15px; height: 15px; }

  /* Status pills — hide tier pill to save space */
  #tier-pill { display: none; }

  /* Modal: full-width with margin */
  .modal {
    max-width: calc(100vw - 32px);
    margin: 0 16px;
  }
}

/* ═══════════════════════════════════════════
   MOBILE — ≤ 600px
   Bottom tab bar, FAB, full-width everything
═══════════════════════════════════════════ */
@media (max-width: 600px) {

  /* Reduce header height slightly */
  :root { --header-h: 52px; }

  /* Show FAB container and tab bar */
  #fab-container { display: flex; }
  .mobile-tab-bar { display: flex; }

  /* Push body content up above tab bar */
  #body { padding-bottom: 56px; }

  /* Sidebar drawer goes to 85% width on small phones */
  #sidebar { width: 85vw !important; max-width: 320px !important; }

  /* Header: tighter */
  #header { padding: 0 10px 0 0; }
  .status-group { padding: 0 8px; gap: 4px; }

  /* Hide Add Transaction button — FAB replaces it */
  #btn-add-tx { display: none; }

  /* Hide Add Team button — accessible via Teams tab */
  #btn-add-team { display: none; }

  /* Hide Edit button from header — accessible via sidebar on mobile */
  #btn-edit { display: none; }

  /* Hide status pills — redundant with sidebar on phone */
  .status-group { display: none; }

  /* Header-left: just hamburger width, no fixed sidebar width */
  .header-left { width: auto; min-width: 0; border-right: none; padding: 0 8px; }

  /* Hide Add/Edit buttons from header — FAB speed-dial handles these */
  #btn-add-tx  { display: none; }
  #btn-add-team { display: none; }
  #btn-edit    { display: none; }

  /* Auth toggle: icon only for sign out, keep label for sign in */
  #btn-auth-toggle .btn-label { display: none; }

  /* Pro toolbar: stack single column */
  #pro-toolbar {
    grid-template-columns: 1fr;
    height: auto;
  }
  .pro-tool {
    height: 44px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .pro-tool:last-child { border-bottom: none; }

  /* Modals: bottom sheet style */
  .overlay-backdrop {
    align-items: flex-end;
  }
  .modal {
    max-width: 100vw;
    width: 100vw;
    margin: 0;
    border-radius: 18px 18px 0 0;
    max-height: 88vh;
  }

  /* Calendar nav: tighter */
  #cal-nav { padding: 10px 14px; gap: 8px; }
  #cal-month-label { font-size: var(--f-sm); }

  /* Calendar cells: smaller min on mobile for fit */
  /* squareCalendar JS handles sizing — just ensure wrap fills screen */
  #cal-grid-wrap { padding: 8px; }

  /* Mobile tab active state also highlights sidebar section */
  #sidebar .sb-section { padding-top: 44px; } /* space for close button */

  /* Sidebar teams/transactions list — taller max-height since sidebar is full-height */
  #tx-list-wrap { max-height: 45vh; }
}

/* ═══════════════════════════════════════════
   EXTRA SMALL — ≤ 380px (iPhone SE etc.)
═══════════════════════════════════════════ */
@media (max-width: 380px) {
  .brand-title { font-size: var(--f-lg); }
  .brand-sub { display: none; }
  #auth-pill .pill-dot + * { display: none; } /* hide text in pill, keep dot */
}