:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --accent: #7c3aed;
  --accent-2: #8b5cf6;
  --green: #10b981;
  --red: #ef4444;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .04);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.ta-r { text-align: right; }
.nowrap { white-space: nowrap; }
.amt-red { color: var(--red); font-weight: 600; }
.amt-green { color: var(--green); font-weight: 600; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
  padding: 0 8px;
}
.brand strong { display: block; color: #fff; font-size: 15px; }
.brand small { color: #94a3b8; font-size: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  color: #fff; font-weight: 800; display: grid; place-items: center;
  font-size: 14px; flex-shrink: 0;
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  color: var(--sidebar-text);
  padding: 11px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}
.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-link.is-active {
  background: rgba(124, 58, 237, .22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent-2);
}

.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.user-name { color: #e2e8f0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.logout-link { color: #94a3b8; }
.logout-link:hover { color: #fff; }

.main {
  flex: 1;
  padding: 28px 32px 48px;
  min-width: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.page-sub { margin: 0; color: var(--muted); font-size: 14px; }

.filters, .filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 16px; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h3 { margin: 0; }
.link-muted { color: var(--muted); font-size: 13px; font-weight: 600; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.kpi-label { display: block; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { display: block; font-size: 24px; font-weight: 800; margin: 6px 0 4px; letter-spacing: -.02em; }
.kpi-sub { display: block; color: var(--muted); font-size: 12px; }
.kpi-red { color: var(--red); }
.kpi-green { color: var(--green); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.chart-box { position: relative; height: 300px; }

.btn {
  appearance: none;
  border: none;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-xs { padding: 5px 8px; font-size: 12px; border-radius: 8px; }
.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}
.btn-ghost:hover { background: #f8fafc; filter: none; }
.btn-danger {
  background: #fff;
  color: var(--red);
  border: 1px solid #fecaca;
  font-weight: 600;
}
.btn-danger:hover { background: #fef2f2; filter: none; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
input[type="text"], input[type="password"], input[type="date"], input[type="search"],
input[type="number"], input[type="file"], select, textarea, .field-inline {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .15);
}
.field-inline { width: auto; min-width: 160px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.file-note { margin-top: 6px; color: var(--muted); font-weight: 500; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }

.tx-deductions {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 12px 14px;
}
.ded-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 10px;
}
.ded-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.tx-net-summary {
  margin-top: 12px;
  padding: 9px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
}
.tx-net-summary:empty { display: none; }
.tx-net-summary strong { font-size: 13.5px; }

.amt-detail {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
  white-space: normal;
}

details.cat-details {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
details.cat-details summary {
  list-style: none;
  cursor: pointer;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  user-select: none;
}
details.cat-details summary::-webkit-details-marker { display: none; }
details.cat-details summary:hover { background: #f8fafc; }
details.cat-details summary strong { font-size: 15px; }
details.cat-details .cat-count { font-size: 12.5px; font-weight: 500; }
.cat-chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform .2s ease;
  font-size: 14px;
}
details.cat-details[open] .cat-chevron { transform: rotate(180deg); }
.cat-body {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--border);
}

.goals-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.goals-group-title {
  margin: 6px 0 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.goals-group-title:first-child { margin-top: 0; }
.goal { margin-bottom: 2px; }
.goal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 5px;
}
.goal-label { font-weight: 600; }
.goal-label .muted { font-weight: 500; }
.goal-nums { color: var(--muted); font-weight: 600; white-space: nowrap; font-size: 12.5px; }
.goal-pct { color: var(--text); font-weight: 700; }
.goal-track {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.goal-fill {
  height: 100%;
  border-radius: 999px;
  min-width: 2px;
  transition: width .4s ease;
}
.goal-fill.goal-accent { background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.goal-fill.goal-green { background: linear-gradient(90deg, #34d399, var(--green)); }
.goal-fill.goal-blue { background: linear-gradient(90deg, #38bdf8, #0ea5e9); }
.goal-fill.goal-over { background: linear-gradient(90deg, #f97316, var(--red)); }
.goals-foot { margin-top: 4px; font-size: 13px; }

.goal-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}
.goal-row:last-child { border-bottom: none; }
.goal-row-main { flex: 1; min-width: 0; }
.goal-row-main .goal { margin-bottom: 6px; }
.goal-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.goal-current-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.goal-current-form input[type="text"] {
  width: 110px;
  padding: 6px 9px;
  font-size: 13px;
}
@media (max-width: 700px) {
  .goal-row { flex-direction: column; }
  .goal-row-actions { justify-content: flex-start; }
}

.filters-bar {
  padding: 14px 16px;
}
.filters-bar > * { min-width: 0; }
.filters-bar select,
.filters-bar input[type="date"],
.filters-bar input[type="search"] {
  width: auto;
  min-width: 140px;
  flex: 1 1 140px;
}

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  white-space: nowrap;
}
.table td {
  padding: 12px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8fafc; }
.table-compact td, .table-compact th { padding: 8px 6px; }
.desc-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.inline-form { display: inline; margin: 0; }

.proj-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; margin-right: 7px; vertical-align: middle;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}
.badge-gasto { background: #fef2f2; color: #b91c1c; }
.badge-ingreso { background: #ecfdf5; color: #047857; }

.flash {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
}
.flash-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.empty { color: var(--muted); margin: 8px 0; }
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding-top: 14px;
  font-size: 14px;
  color: var(--muted);
}

.cat-col h4 {
  margin: 0 0 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.cat-tree { list-style: none; margin: 0 0 14px; padding: 0; }
.cat-tree > li { margin-bottom: 8px; }
.cat-tree-sub { margin: 6px 0 0 18px; padding-left: 10px; border-left: 2px solid var(--border); }
.cat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  background: #f8fafc;
}
.cat-rename { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 180px; }
.cat-rename input[type="text"] { padding: 7px 10px; }
.cat-stats { color: var(--muted); font-size: 12px; white-space: nowrap; }
.add-cat-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.add-cat-form select, .add-cat-form input[type="text"] { flex: 1 1 140px; min-width: 120px; }

.info-list { list-style: none; margin: 0 0 16px; padding: 0; }
.info-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.info-list span { color: var(--muted); }

/* Login */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1000px 500px at 10% 10%, rgba(124,58,237,.35), transparent 60%),
    radial-gradient(800px 400px at 90% 80%, rgba(14,165,233,.28), transparent 55%),
    #0f172a;
  padding: 24px;
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 28px 26px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { margin: 0 auto 12px; width: 48px; height: 48px; font-size: 16px; }
.login-brand h1 { margin: 0 0 4px; font-size: 22px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }


/* ===== Expert dashboard extras ===== */
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #64748b;
  margin: 14px 8px 6px;
  font-weight: 700;
}
.nav-project { display: flex; align-items: center; gap: 2px; }
.sidebar { overflow-y: auto; }

.project-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--pill, var(--accent));
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow);
  min-width: 160px;
}
.pill:hover { text-decoration: none; transform: translateY(-1px); }
.pill-go { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 600; }

.project-title { display: flex; align-items: center; gap: 10px; }
.project-title h1 { margin: 0; }
.proj-dot.lg { width: 14px; height: 14px; }

.kpis { grid-template-columns: repeat(3, 1fr); }
.kpis-5 { grid-template-columns: repeat(5, 1fr); }


.insights {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.insight {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
}
.insight-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.insight-warn { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.insight-info { background: #f5f3ff; border-color: #ddd6fe; color: #5b21b6; }

.chart-card .card-head { margin-bottom: 8px; flex-wrap: wrap; }
.chart-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { border-color: #c4b5fd; color: var(--text); }
.chip.is-on {
  background: #ede9fe;
  border-color: #c4b5fd;
  color: #5b21b6;
}

.chart-box.tall { height: 380px; }
.filters-advanced { max-width: 100%; }

.mini-bar {
  height: 5px;
  background: #e2e8f0;
  border-radius: 999px;
  margin-top: 4px;
  overflow: hidden;
  min-width: 70px;
}
.mini-bar span { display: block; height: 100%; border-radius: 999px; }

.quick-cats { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.quick-cats h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}
.tag small { color: var(--muted); }
.small { font-size: 12px; }


/* ===== Global overflow safety ===== */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}
.app {
  max-width: 100%;
  overflow-x: hidden;
}
.main {
  max-width: 100%;
  overflow-x: hidden;
  min-width: 0;
}
img, canvas, svg, video, iframe {
  max-width: 100%;
}
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.card, .kpi, .flash, .insight, .pill, .filters, .filters-bar, .page-head {
  max-width: 100%;
}
.desc-cell {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}
.nowrap {
  white-space: nowrap;
}
.table td, .table th {
  word-break: break-word;
}

/* Mobile topbar + drawer (hidden on desktop) */
.mobile-topbar,
.sidebar-backdrop,
.sidebar-close {
  display: none;
}
.brand-mark.sm {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 12px;
}

/* Chip buttons */
button.chip, .chip {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  margin: 0;
}
button.chip:hover, .chip:hover {
  border-color: #c4b5fd;
  color: #0f172a;
  background: #f8fafc;
}
button.chip.is-on, .chip.is-on {
  background: #ede9fe;
  border-color: #a78bfa;
  color: #5b21b6;
}
.chart-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: 100%;
}
.chart-box {
  position: relative;
  height: 300px;
  width: 100%;
  max-width: 100%;
}
.chart-box.tall { height: 380px; }
.chart-box canvas {
  max-width: 100% !important;
}

/* Desktop KPI grids */
.kpis { grid-template-columns: repeat(3, 1fr); }
.kpis-5 { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 1200px) {
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .kpis-5 { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 901px) and (max-width: 1199px) {
  .kpis, .kpis-5 { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Tablet / Mobile drawer layout ===== */
@media (max-width: 900px) {
  .app {
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 60;
    height: 56px;
    padding: 0 12px;
    background: #0f172a;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .mobile-topbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
  }
  .mobile-topbar-title strong {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-logout {
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    padding: 8px 6px;
    flex-shrink: 0;
  }

  .menu-toggle {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
  }
  .menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 70;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  body.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.nav-open {
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(300px, 86vw);
    max-width: 300px;
    height: 100vh;
    height: 100dvh;
    z-index: 80;
    transform: translateX(-105%);
    transition: transform .22s ease;
    padding: 16px 12px 20px;
    box-shadow: 8px 0 30px rgba(0,0,0,.35);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close {
    display: grid;
    place-items: center;
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }
  .brand {
    margin-bottom: 18px;
    padding-right: 0;
  }
  .brand small {
    display: block;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    flex-direction: column;
    overflow: visible;
    gap: 4px;
  }
  .nav-section {
    display: block;
    margin-top: 14px;
  }
  .nav-link {
    white-space: normal;
    padding: 12px 14px;
  }
  .nav-link.is-active {
    box-shadow: inset 3px 0 0 var(--accent-2);
  }
  .sidebar-foot {
    margin-top: 16px;
  }

  .main {
    width: 100%;
    max-width: 100%;
    padding: 14px 12px 40px;
    min-width: 0;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 14px;
  }
  .page-head h1 {
    font-size: 22px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  .page-sub {
    font-size: 13px;
  }
  .filters, .filters-bar, .filters-advanced {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .filters .field-inline,
  .filters-bar select,
  .filters-bar input,
  .filters-advanced .field-inline,
  .filters .btn,
  .filters-bar .btn,
  .filters a.btn {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .filters-bar {
    padding: 12px;
  }

  .project-pills {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .pill {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .kpis, .kpis-5 {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .kpi {
    padding: 12px;
    min-width: 0;
  }
  .kpi-value {
    font-size: 18px;
    overflow-wrap: anywhere;
  }
  .kpi-label {
    font-size: 11px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 {
    grid-column: auto;
  }
  .ded-grid {
    grid-template-columns: 1fr 1fr;
  }

  .card {
    padding: 14px;
    margin-bottom: 12px;
    overflow: hidden;
  }
  .card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .chart-box, .chart-box.tall {
    height: 260px;
  }
  .chart-tools {
    width: 100%;
  }

  .table {
    font-size: 12px;
  }
  .table th, .table td {
    padding: 8px 6px;
  }
  .actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .actions .btn {
    width: auto;
  }

  .cat-row {
    flex-direction: column;
    align-items: stretch;
  }
  .cat-rename {
    width: 100%;
    min-width: 0;
  }
  .add-cat-form {
    flex-direction: column;
  }
  .add-cat-form select,
  .add-cat-form input[type="text"],
  .add-cat-form .btn {
    width: 100%;
    min-width: 0;
  }

  .project-title {
    flex-wrap: wrap;
  }
  .project-title h1 {
    font-size: 22px;
  }

  .login-card {
    width: 100%;
    max-width: 100%;
    padding: 22px 16px;
  }
  .login-body {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  .kpis, .kpis-5 {
    grid-template-columns: 1fr;
  }
  .kpi-value {
    font-size: 20px;
  }
  .main {
    padding: 12px 10px 36px;
  }
  .chart-box, .chart-box.tall {
    height: 240px;
  }
  .page-head h1 {
    font-size: 20px;
  }
  .btn {
    width: 100%;
  }
  .form-actions {
    flex-direction: column;
  }
  .form-actions .btn,
  .form-actions a.btn {
    width: 100%;
  }
  .filters-bar a.btn,
  .filters a.btn {
    text-align: center;
  }
  /* tables: keep horizontal scroll only inside wrapper */
  .table .nowrap {
    white-space: nowrap;
  }
}