/* TrackForge — Custom Styles */
/* Brand: Navy #1b2a4a | Orange #e8701a */

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

body { font-family: 'Inter', sans-serif; background: #f8fafc; color: #1e293b; }

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --primary:       #e8701a;
  --primary-hover: #d4620f;
  --primary-light: #fff7ed;
  --primary-mid:   #ffedd5;
  --navy:          #1b2a4a;
  --navy-mid:      #243461;
  --navy-light:    #2e4070;
}

/* ── Layout ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100%;
  width: 240px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: left .25s cubic-bezier(.4,0,.2,1);
  will-change: left;
}
.main-content {
  margin-left: 240px;
  min-height: 100vh;
  padding: 28px 32px;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 39;
}
.sidebar-overlay.active { display: block; }

/* ── Hamburger button (mobile only) ─────────────────────── */
.hamburger-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px; border: 1.5px solid #e5e7eb;
  background: #fff; cursor: pointer; font-size: 18px;
  color: #374151; transition: background .15s;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: #f3f4f6; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 14px;
  padding: 9px 18px; border-radius: 10px; border: none; cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: #374151; font-weight: 600; font-size: 14px;
  padding: 9px 18px; border-radius: 10px;
  border: 1.5px solid #e5e7eb; cursor: pointer;
  transition: border-color .15s, background .15s;
  text-decoration: none; white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--primary); background: var(--primary-light); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fee2e2; color: #dc2626; font-weight: 600; font-size: 14px;
  padding: 9px 18px; border-radius: 10px; border: none; cursor: pointer;
  transition: background .15s; text-decoration: none; white-space: nowrap;
}
.btn-danger:hover { background: #fecaca; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 7px; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: 16px;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: 0 4px 16px rgba(232,112,26,.1); transform: translateY(-2px); }

.card-header {
  padding: 20px 24px 0; font-weight: 700; font-size: 16px; color: #111827;
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 16px 24px 24px; }

/* ── Dashboard Cards ─────────────────────────────────────── */
.dash-card {
  background: #fff; border-radius: 16px; border: 1px solid #f1f5f9;
  overflow: hidden; transition: box-shadow .2s, transform .2s; cursor: pointer;
}
.dash-card:hover { box-shadow: 0 8px 24px rgba(232,112,26,.15); transform: translateY(-3px); }

.dash-card-banner { height: 72px; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.dash-card-body   { padding: 14px 16px; }
.dash-card-name   { font-weight: 700; font-size: 14px; color: #111827; margin-bottom: 3px; }
.dash-card-desc   { font-size: 12px; color: #6b7280; line-height: 1.4; }
.dash-card-footer { padding: 10px 16px; border-top: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; }
.dash-card-stat   { font-size: 12px; color: #6b7280; }
.dash-card-stat strong { color: #111827; font-weight: 600; }

/* New Dashboard card */
.new-dash-card {
  background: #fff; border-radius: 16px; border: 2px dashed #ffedd5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; cursor: pointer; min-height: 180px;
  transition: border-color .2s, background .2s; text-decoration: none;
}
.new-dash-card:hover { border-color: var(--primary); background: var(--primary-light); }
.new-dash-card-icon  { width: 44px; height: 44px; border-radius: 12px; background: #ffedd5; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.new-dash-card-label { font-weight: 600; font-size: 14px; color: var(--primary); }

/* ── Forms ─────────────────────────────────────────────── */
.form-group  { margin-bottom: 18px; }
.form-label  { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-label .req { color: var(--primary); margin-left: 2px; }

.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #e5e7eb; border-radius: 10px;
  font-size: 14px; color: #111827; background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none; font-family: 'Inter', sans-serif;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,112,26,.12); }
.form-control::placeholder { color: #9ca3af; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint  { font-size: 12px; color: #9ca3af; margin-top: 5px; }
.form-error { font-size: 12px; color: #dc2626; margin-top: 5px; }

/* Slider */
.form-slider  { width: 100%; accent-color: var(--primary); height: 6px; }
.slider-value { font-weight: 700; color: var(--primary); font-size: 14px; }

/* Checkbox */
.form-checkbox { width: 18px; height: 18px; border-radius: 5px; accent-color: var(--primary); cursor: pointer; }

/* ── Alert / Toast ─────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #dbeafe; color: #1e40af; }
.alert-warning { background: #fef3c7; color: #92400e; }

.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy); color: #f8fafc; padding: 14px 18px;
  border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  display: flex; align-items: center; gap: 10px;
  animation: slideUp .25s ease; max-width: 320px;
}
.toast.success { background: #059669; }
.toast.error   { background: #dc2626; }
@keyframes slideUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }

/* ── Block Builder ─────────────────────────────────────── */
.block-list { display: flex; flex-direction: column; gap: 10px; }

.block-item {
  background: #fff; border: 1.5px solid #e5e7eb; border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  transition: border-color .15s, box-shadow .15s; cursor: grab;
}
.block-item:hover    { border-color: #fdba74; box-shadow: 0 2px 8px rgba(232,112,26,.1); }
.block-item.dragging { opacity: .5; cursor: grabbing; }
.block-item.drag-over { border-color: var(--primary); background: var(--primary-light); }

.block-drag-handle { color: #d1d5db; font-size: 18px; cursor: grab; padding: 4px; }
.block-icon   { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.block-info   { flex: 1; min-width: 0; }
.block-label  { font-weight: 600; font-size: 14px; color: #111827; }
.block-type   { font-size: 12px; color: #9ca3af; text-transform: capitalize; margin-top: 1px; }
.block-badge  { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.block-badge.required { background: #fef3c7; color: #92400e; }
.block-badge.optional { background: #f3f4f6; color: #6b7280; }
.block-actions { display: flex; gap: 6px; }

/* Block type palette */
.block-palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.block-type-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #fff;
  border: 1.5px solid #e5e7eb; border-radius: 10px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: #374151; text-align: left;
  transition: border-color .15s, background .15s;
}
.block-type-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.block-type-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; }

/* ── Stats / Metrics ─────────────────────────────────────── */
.stat-card { background: #fff; border-radius: 14px; padding: 20px; border: 1px solid #f1f5f9; }
.stat-label { font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; color: #111827; line-height: 1; }
.stat-sub   { font-size: 12px; color: #9ca3af; margin-top: 6px; }
.stat-trend { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.stat-trend.up   { color: #059669; }
.stat-trend.down { color: #dc2626; }

/* ── Calendar ─────────────────────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-header { text-align: center; font-size: 11px; font-weight: 700; color: #9ca3af; text-transform: uppercase; padding: 6px 0; }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s; color: #374151;
}
.cal-day.other-month { color: #d1d5db; }
.cal-day.today       { background: #ffedd5; color: var(--primary); font-weight: 700; }
.cal-day.has-entry   { background: var(--primary); color: #fff; font-weight: 700; }
.cal-day.has-entry:hover { background: var(--primary-hover); }
.cal-day:hover:not(.has-entry):not(.today) { background: #f3f4f6; }

/* ── Dropdown ─────────────────────────────────────────────── */
.dropdown-menu {
  border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.12);
  border: 1px solid #f1f5f9; overflow: hidden;
}

/* ── Table ─────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-size: 12px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; border-bottom: 1.5px solid #f1f5f9; text-align: left; }
.data-table td { padding: 14px 16px; border-bottom: 1px solid #f8fafc; font-size: 14px; color: #374151; }
.data-table tr:hover td { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }

/* ── Auth Pages ─────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%); padding: 24px; }
.auth-card { background: #fff; border-radius: 24px; padding: 44px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(232,112,26,.12); }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; }
.auth-logo-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--navy); display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 11px; letter-spacing: -.5px; line-height: 1;
  position: relative; overflow: hidden;
}
.auth-logo-icon::after {
  content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 45%;
  background: var(--primary);
}
.auth-logo-tf { position: relative; z-index: 1; display: flex; }
.auth-logo-tf span:first-child { color: #fff; }
.auth-logo-tf span:last-child  { color: #fff; margin-left: -1px; }
.auth-logo-name { font-weight: 800; font-size: 22px; color: #111827; }
.auth-logo-name strong { color: var(--primary); }
.auth-title    { font-size: 26px; font-weight: 800; color: #111827; margin-bottom: 6px; }
.auth-subtitle { font-size: 15px; color: #6b7280; margin-bottom: 32px; }
.auth-footer   { text-align: center; font-size: 14px; color: #6b7280; margin-top: 24px; }
.auth-footer a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px; animation: fadeIn .15s ease;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 20px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,.2); animation: scaleIn .15s ease;
}
.modal-header { padding: 24px 28px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 18px; font-weight: 700; color: #111827; }
.modal-close  { width: 30px; height: 30px; border-radius: 8px; border: none; background: #f3f4f6; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #6b7280; transition: background .15s; }
.modal-close:hover { background: #e5e7eb; }
.modal-body   { padding: 24px 28px; }
.modal-footer { padding: 0 28px 24px; display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes scaleIn { from { opacity:0; transform:scale(.96) } to { opacity:1; transform:scale(1) } }

/* ── Upgrade Banner ─────────────────────────────────────── */
.upgrade-banner {
  background: linear-gradient(135deg, var(--navy), var(--navy-mid));
  border-radius: 16px; padding: 24px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #fff;
}
.upgrade-banner-text h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.upgrade-banner-text p  { font-size: 14px; opacity: .85; }
.upgrade-banner-btn {
  background: var(--primary); color: #fff; border: 2px solid rgba(255,255,255,.3);
  font-weight: 700; font-size: 14px; padding: 10px 22px;
  border-radius: 10px; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-block; transition: background .15s;
}
.upgrade-banner-btn:hover { background: var(--primary-hover); }

/* ── Subscription Cards ─────────────────────────────────── */
.plan-card {
  background: #fff; border: 2px solid #e5e7eb; border-radius: 20px; padding: 32px;
  transition: border-color .2s, box-shadow .2s; position: relative; overflow: hidden;
}
.plan-card.popular { border-color: var(--primary); }
.plan-card.popular::before {
  content: '✨ Most Popular';
  position: absolute; top: 16px; right: -28px;
  background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; padding: 4px 40px; transform: rotate(45deg);
}
.plan-price { font-size: 48px; font-weight: 800; color: #111827; line-height: 1; }
.plan-price span { font-size: 18px; font-weight: 500; color: #6b7280; }
.plan-feature { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #374151; margin-bottom: 10px; }
.plan-feature-check { color: #059669; font-size: 16px; }

/* ── Entry Form ─────────────────────────────────────────── */
.entry-block {
  background: #fff; border: 1.5px solid #f1f5f9;
  border-radius: 14px; padding: 20px; transition: border-color .15s;
}
.entry-block:focus-within { border-color: #fed7aa; }
.entry-block-label { font-size: 14px; font-weight: 700; color: #111827; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.badge-purple { background: #ffedd5; color: var(--primary); }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-orange { background: #ffedd5; color: var(--primary); }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ── Progress Ring ──────────────────────────────────────── */
.progress-ring-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: var(--primary); }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(232,112,26,.3); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform:rotate(360deg) } }

/* ── Nav link active accent ─────────────────────────────── */
.nav-link-active { background: var(--primary) !important; color: #fff !important; }

/* ── Sidebar nav override for TrackForge navy ───────────── */
.sidebar { background: var(--navy) !important; }

/* ── Hide sidebar nav scrollbar (still scrollable on tiny screens) ── */
.sidebar nav::-webkit-scrollbar { display: none; }

/* ══════════════════════════════════════════════════════════
   GLOBAL — prevent horizontal overflow on every page
   ══════════════════════════════════════════════════════════ */
html, body { overflow-x: hidden; max-width: 100%; }
img, video, canvas, svg { max-width: 100%; height: auto; }

/* Tables: always scroll horizontally instead of overflowing */
.data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table       { min-width: 480px; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — Tablet  (≤1023px)
   Sidebar slides off-screen; hamburger shown; content full-width
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {

  /* ── Sidebar off-screen ───────────────────────────────── */
  .sidebar     { left: -260px; }
  .sidebar.open { left: 0; }

  /* ── Main: full width, reduced padding ───────────────── */
  .main-content {
    margin-left: 0 !important;
    padding: 20px !important;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* ── Hamburger always visible on tablet+ ─────────────── */
  .hamburger-btn { display: inline-flex !important; }

  /* ── Builder: stack columns ──────────────────────────── */
  .builder-grid { grid-template-columns: 1fr !important; }

  /* ── Settings 2fr/1fr sidebar ────────────────────────── */
  [style*="grid-template-columns:2fr 1fr"]   { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 2fr 1fr"]  { grid-template-columns: 1fr !important; }

  /* ── Entry form + recent sidebar ─────────────────────── */
  [style*="grid-template-columns:1fr 280px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 280px"]{ grid-template-columns: 1fr !important; }

  /* ── Builder right panel ─────────────────────────────── */
  [style*="grid-template-columns:1fr 360px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 360px"]{ grid-template-columns: 1fr !important; }

  /* ── Subscription plan cards (1fr 1fr) ───────────────── */
  [style*="grid-template-columns:1fr 1fr;gap:24px"]   { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 1fr;gap:24px"]  { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1fr 1fr 1fr;gap:24px"]{ grid-template-columns: 1fr !important; }

  /* ── Analytics depth / insight rows ─────────────────── */
  [style*="grid-template-columns:1fr 1fr;gap:20px"]   { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 1fr;gap:20px"]  { grid-template-columns: 1fr !important; }

  /* ── Analytics charts sidebar (1fr 320px) ────────────── */
  [style*="grid-template-columns:1fr 320px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 320px"]{ grid-template-columns: 1fr !important; }
  .tf-charts-grid  { grid-template-columns: 1fr !important; }
  .tf-insights-row { grid-template-columns: 1fr !important; }

  /* ── Correlation: 1fr 1fr auto selector + 4-col stats ── */
  [style*="grid-template-columns:1fr 1fr auto"]  { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 1fr auto"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: 1fr 1fr !important; }
  [style*="grid-template-columns: repeat(4,1fr)"]{ grid-template-columns: 1fr 1fr !important; }

  /* ── Calendar summary sidebar ────────────────────────── */
  [style*="grid-template-columns:1fr 280px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 280px"]{ grid-template-columns: 1fr !important; }

  /* ── Date range form wrap on analytics ──────────────── */
  .tf-date-form { flex-wrap: wrap !important; }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile  (≤767px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

  .main-content { padding: 14px !important; }

  /* ── Topbar ───────────────────────────────────────────── */
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar > div:last-child { width: 100%; justify-content: flex-end; }

  /* ── Collapse ALL inline grid styles to single col ───── */
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* ── Exception: stat pills keep 2-col ────────────────── */
  [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: 1fr 1fr !important; }
  [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr 1fr !important; }

  /* ── Cards ────────────────────────────────────────────── */
  .card { border-radius: 12px; }
  .card-body, .card-header { padding: 14px 16px; }

  /* ── Auth ─────────────────────────────────────────────── */
  .auth-card { padding: 28px 20px; border-radius: 18px; }
  .auth-title { font-size: 22px; }

  /* ── Block palette ────────────────────────────────────── */
  .block-palette { grid-template-columns: 1fr !important; }

  /* ── Calendar ─────────────────────────────────────────── */
  .cal-day { font-size: 11px; border-radius: 7px; }

  /* ── Tables ───────────────────────────────────────────── */
  .data-table { font-size: 12px; min-width: 0; }
  .data-table th, .data-table td { padding: 9px 8px; }
  .hide-mobile { display: none !important; }

  /* ── Stats ────────────────────────────────────────────── */
  .stat-value { font-size: 24px; }
  .stat-card  { padding: 14px; }

  /* ── Toast ────────────────────────────────────────────── */
  .toast-container { bottom: 12px; right: 10px; left: 10px; }
  .toast { max-width: 100%; }

  /* ── Upgrade banner ──────────────────────────────────── */
  .upgrade-banner { flex-direction: column; align-items: flex-start; gap: 12px; }
  .upgrade-banner-btn { width: 100%; text-align: center; display: block; }

  /* ── Plan card popular ribbon ─────────────────────────── */
  .plan-card.popular::before { display: none; }

  /* ── Entry sidebar hidden on mobile ──────────────────── */
  .entry-sidebar-mobile { display: none; }

  /* ── Buttons ──────────────────────────────────────────── */
  .btn-primary, .btn-secondary { font-size: 13px; padding: 8px 14px; }

  /* ── Modals ───────────────────────────────────────────── */
  .modal-box    { border-radius: 14px; }
  .modal-body, .modal-footer { padding: 16px 18px; }
  .modal-header { padding: 18px 18px 0; }

  /* ── Analytics depth heatmap ─────────────────────────── */
  #dowHeatmap > div { min-width: 36px; }
}

/* ── Small phones (≤400px) ───────────────────────────────── */
@media (max-width: 400px) {
  .main-content { padding: 10px !important; }
  .stat-value   { font-size: 20px; }
  .auth-card    { padding: 20px 14px; }
}

/* ── Quick-add floating action button ────────────────────── */
.quick-add-fab {
  position: fixed; right: 24px; bottom: 24px; width: 56px; height: 56px;
  border-radius: 50%; background: var(--primary); color: #fff; font-size: 26px;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 60; transition: transform .15s, background .15s;
}
.quick-add-fab:hover { background: var(--primary-hover); transform: scale(1.08); }
@media (max-width: 768px) { .quick-add-fab { right: 16px; bottom: 16px; width: 50px; height: 50px; font-size: 22px; } }

/* ── Dark mode ────────────────────────────────────────────── */
html.dark { --bg: #0f172a; --surface: #1a2436; --surface-alt: #111a2b; --text: #e5e7eb; --text-muted: #94a3b8; --border: #2b3648; }
html.dark body { background: var(--bg) !important; color: var(--text); }
html.dark .card, html.dark .stat-card, html.dark .modal-box, html.dark .dash-card,
html.dark .auth-card, html.dark .new-dash-card, html.dark .toast {
  background: var(--surface) !important; border-color: var(--border) !important; color: var(--text);
}
html.dark .card-header { border-color: var(--border); color: var(--text); }
html.dark .dash-card-body, html.dark .dash-card-footer { border-color: var(--border); }
html.dark .dash-card-name { color: var(--text); }
html.dark .dash-card-desc, html.dark .stat-label, html.dark .stat-sub,
html.dark .text-gray-500, html.dark .text-sm.text-gray-500 { color: var(--text-muted) !important; }
html.dark .text-gray-900, html.dark h1, html.dark h2, html.dark h3, html.dark .section-title { color: var(--text) !important; }
html.dark .form-control, html.dark select, html.dark textarea, html.dark input {
  background: var(--surface-alt) !important; border-color: var(--border) !important; color: var(--text) !important;
}
html.dark .form-control::placeholder { color: var(--text-muted); }
html.dark .data-table th { background: var(--surface-alt); color: var(--text-muted); border-color: var(--border); }
html.dark .data-table td { border-color: var(--border); color: var(--text); }
html.dark .data-table tr:hover td { background: var(--surface-alt); }
html.dark .topbar, html.dark .bg-white { background: var(--surface) !important; border-color: var(--border) !important; }
html.dark .dropdown-menu { background: var(--surface) !important; border-color: var(--border) !important; }
html.dark .dropdown-menu a { color: var(--text) !important; }
html.dark .border-gray-100, html.dark .border-gray-200 { border-color: var(--border) !important; }
html.dark .empty-state h3 { color: var(--text); }
html.dark .empty-state p { color: var(--text-muted); }
html.dark .badge-gray { background: var(--surface-alt); color: var(--text-muted); }
html.dark ::selection { background: var(--primary); color: #fff; }
