/* ═══════════════════════════════════════════════════
   components.css — Cards, modals, tables, forms, buttons
   ═══════════════════════════════════════════════════ */

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  touch-action: manipulation; /* prevent double-tap zoom */
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Filled buttons use the darker *-bg tokens so their white label keeps >= 4.5:1 in every theme */
.btn-primary {
  background: var(--btn-primary-bg);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--btn-primary-hover); }

.btn-success {
  background: var(--btn-success-bg);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: var(--btn-success-hover); }

.btn-danger {
  background: var(--btn-danger-bg);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--btn-danger-hover); }

.btn:focus-visible { outline: 2px solid var(--color-link); outline-offset: 2px; }

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; min-width: 36px; justify-content: center; }
.btn-icon-sm { padding: 5px; min-width: 28px; justify-content: center; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
  gap: 8px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.card-subtitle:empty { display: none; }

/* Stat card (dashboard summary) */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.stat-card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Card tones (Colored theme tints them; Dark and Light keep them neutral through the same tokens). Text colours inside are the theme's own
   --color-income / --color-expense / --text-* tokens, verified >= 4.5:1 on these tints. */
.stat-card.tone-income  { background: var(--tone-income-bg);  border-color: var(--tone-income-border); }
.stat-card.tone-expense { background: var(--tone-expense-bg); border-color: var(--tone-expense-border); }
.stat-card.tone-net     { background: var(--tone-net-bg);     border-color: var(--tone-net-border); }
.stat-card.tone-savings { background: var(--tone-savings-bg); border-color: var(--tone-savings-border); }

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card-icon.income  { background: rgba(34,197,94,.15);  color: var(--color-income); }
.stat-card-icon.expense { background: rgba(239,68,68,.15);  color: var(--color-expense); }
.stat-card-icon.balance { background: rgba(59,130,246,.15); color: var(--color-primary); }
.stat-card-icon.savings { background: rgba(139,92,246,.15); color: var(--color-purple); }

/* ─── Tables ────────────────────────────────────────────────────────────── */
/* Bounded horizontal scroller for genuinely wide tables. Vertical page scroll and pinch-zoom stay with the browser
   (no touch-action override); overscroll-behavior-x stops a sideways swipe at the edge from chaining to the page.
   app.js makes the wrapper keyboard-focusable only while it actually overflows. */
.table-wrapper {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.table-wrapper:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  background: var(--table-head-bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-hover); }

.table .amount-income  { color: var(--color-income);  font-weight: 600; }
.table .amount-expense { color: var(--color-expense); font-weight: 600; }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ≥ 16px on ALL inputs prevents iOS Safari from auto-zooming on focus */
input, select, textarea,
.form-control {
  font-size: 1rem !important;
  -webkit-text-size-adjust: 100%;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  touch-action: manipulation; /* prevent double-tap zoom on mobile */
}

.form-control:focus {
  outline: none;
  border-color: var(--color-link);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-control.is-invalid { border-color: var(--color-danger); }

.form-error {
  font-size: 0.78rem;
  color: var(--color-danger);
  margin-top: 4px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* Range/Slider */
input[type="range"] {
  width: 100%;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ─── Modals ────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  padding: 16px;
  overscroll-behavior: contain;      /* a scroll gesture at the end of the modal never chains to the page behind */
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  max-height: 90dvh;                /* follows the visible viewport when browser bars/keyboard change it */
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease;
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 380px; }

@keyframes modalIn {
  from { transform: scale(0.95) translateY(-10px); opacity: 0; }
  to   { transform: scale(1) translateY(0);        opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header { gap: 12px; }
.modal-title { font-size: 1.05rem; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.modal-close { flex: 0 0 auto; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  line-height: 0;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
}

.modal-close { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; cursor: pointer; }
.modal:focus { outline: none; }   /* the dialog itself takes focus when it has no field to focus (modal_a11y.js) */

.modal-footer {
  padding: 14px 20px max(18px, env(safe-area-inset-bottom));   /* the footer buttons stay clear of a phone's home indicator */
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-income  { background: rgba(34,197,94,.15);   color: var(--color-income); }
.badge-expense { background: rgba(239,68,68,.15);   color: var(--color-expense); }
.badge-success { background: rgba(34,197,94,.15);   color: var(--color-success); }
.badge-warning { background: rgba(245,158,11,.15);  color: var(--color-warning); }
.badge-danger  { background: rgba(239,68,68,.15);   color: var(--color-danger); }
.badge-info    { background: rgba(59,130,246,.15);  color: var(--color-info); }
.badge-gray    { background: var(--bg-hover);       color: var(--text-secondary); }

/* ─── Work / Personal & Home choice (typeToggleHtml in app.js) and its table badge ───────────────────────────────
   Selection is shown by border + weight + a check mark in addition to colour, so it never relies on colour alone. */
.type-toggle { display: flex; gap: 8px; flex-wrap: wrap; }
.type-opt {
  flex: 1 1 140px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  touch-action: manipulation;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.type-opt:hover { background: var(--bg-hover); color: var(--text-primary); }
.type-opt:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.type-opt svg { flex: 0 0 auto; }
.type-opt .type-opt-check { display: none; }
.type-opt[aria-pressed="true"] { color: var(--text-primary); border-width: 2px; padding: 7.5px 13.5px; }
.type-opt[aria-pressed="true"] .type-opt-check { display: block; }
.type-opt[data-type-group="work"] > svg:first-child { color: var(--color-work); }
.type-opt[data-type-group="personal_home"] > svg:first-child { color: var(--color-personal); }
.type-opt[data-type-group="work"][aria-pressed="true"] { border-color: var(--color-work); background: var(--color-work-bg); }
.type-opt[data-type-group="personal_home"][aria-pressed="true"] { border-color: var(--color-personal); background: var(--color-personal-bg); }

.badge-work, .badge-personal { gap: 4px; }
.badge-work     { background: var(--color-work-bg);     color: var(--color-work); }
.badge-personal { background: var(--color-personal-bg); color: var(--color-personal); }

/* ─── Progress Bar ──────────────────────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.progress-fill.ok       { background: var(--color-success); }
.progress-fill.warning  { background: var(--color-warning); }
.progress-fill.exceeded { background: var(--color-danger); }

/* ─── Filters Bar ───────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters-bar .form-control { width: auto; min-width: 140px; }

/* ─── Pagination ────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.pagination-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.pagination-btn.active { background: var(--btn-primary-bg); color: #fff; border-color: var(--btn-primary-bg); }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.pagination-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0 8px;
}

/* ─── Alerts (inline) ───────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid;
}
.alert-error   { background: rgba(239,68,68,.08);   border-color: rgba(239,68,68,.3);   color: var(--color-danger); }
.alert-success { background: rgba(34,197,94,.08);   border-color: rgba(34,197,94,.3);   color: var(--color-success); }
.alert-warning { background: rgba(245,158,11,.08);  border-color: rgba(245,158,11,.3);  color: var(--color-warning); }
.alert-info    { background: rgba(59,130,246,.08);  border-color: rgba(59,130,246,.3);  color: var(--color-info); }

/* ─── Color Dot ─────────────────────────────────────────────────────────── */
.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ─── Shared group + period controls (scope_bar.js, UX batch 2) ─────────────────────────────────────────────────
   Selected state is border + weight + text colour (not colour alone); the buttons keep their words. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.scope-bar { padding: 12px 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--scope-bg); }
.scope-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.scope-seg { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.scope-opt {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 600; touch-action: manipulation; cursor: pointer;
}
.scope-opt:hover { background: var(--bg-hover); color: var(--text-primary); }
.scope-opt:focus-visible { outline: 2px solid var(--color-link); outline-offset: 2px; }
.scope-opt[aria-pressed="true"] { color: var(--text-primary); border-color: var(--color-link); border-width: 2px; padding: 5.5px 11px; background: var(--bg-hover); font-weight: 700; }
.scope-period .form-control { width: auto; min-width: 140px; min-height: 40px; }
.scope-custom { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.scope-custom[hidden], .scope-error[hidden] { display: none; }
.scope-date { display: flex; flex-direction: column; gap: 2px; font-size: 0.8rem; color: var(--text-secondary); min-width: 0; }
.scope-date .form-control { min-height: 40px; min-width: 0; }
.scope-error { color: var(--color-danger); font-size: 0.85rem; font-weight: 600; }
.scope-note { font-size: 0.8rem; color: var(--text-secondary); overflow-wrap: anywhere; }

/* Compact empty state (a short sentence and one action instead of a tall illustration) */
.empty-compact { padding: 10px 0; color: var(--text-secondary); font-size: 0.875rem; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.empty-compact a { font-weight: 600; }

/* Small explanatory text under a card figure or a chart title */
.fine-print { font-size: 0.8rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.fine-print:empty { display: none; }
.fine-print.is-error { color: var(--color-danger); font-weight: 600; }

/* Info popover (info_pop.js / info_pop_html()): a muted icon button that opens a short explanation on click or tap.
   The tap target is 44x44 px; the glyph stays small (14px) and muted but visible (--text-muted is >= 4.5:1 in every theme). The body is
   position:fixed and placed by info_pop.js from the icon's rectangle, so card / dialog / table overflow can never clip it; it is invisible
   until placed (no flash at the corner) and is capped to the viewport width. */
.info-pop { position: relative; display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.info-pop > summary { list-style: none; }
.info-pop > summary::-webkit-details-marker { display: none; }
.info-pop-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px;
  border-radius: 50%; cursor: pointer; color: var(--text-muted); touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.info-pop-btn:hover, .info-pop[open] > .info-pop-btn { color: var(--text-primary); }
.info-pop-btn:focus-visible { outline: 2px solid var(--color-link); outline-offset: -2px; }
.info-pop-i { display: inline-flex; line-height: 0; }
.info-pop-body {
  position: fixed; left: 0; top: 0; z-index: 60; width: max-content; max-width: min(280px, calc(100vw - 32px)); overflow-y: auto;
  background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 10px 12px; font-size: 0.8rem; font-weight: 400; line-height: 1.45; text-transform: none; letter-spacing: normal;
  overflow-wrap: anywhere; white-space: normal; text-align: left;
}
.info-pop[open] > .info-pop-body:not([data-placed]) { visibility: hidden; }
.info-pop-body p { margin: 0; }
.info-pop-body p + p { margin-top: 6px; }
/* The 44px target must not make the line it sits on taller: the icon box overlaps the line above and below (its glyph is centred) */
.stat-card-sub .info-pop, .stat-card-label .info-pop, .title-with-info .info-pop, .card-title .info-pop { margin-block: -12px; }
.title-with-info .info-pop { margin-inline-start: -8px; }
.title-with-info { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; min-width: 0; }

/* Values behind a chart, readable without colour */
.chart-values { margin-top: 10px; font-size: 0.85rem; }
.chart-values > summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; font-weight: 600; color: var(--text-secondary); }
.chart-values .table-wrapper { margin-top: 6px; }

/* Export menu: one button, three formats; the scope it exports is written inside */
.export-menu { position: relative; }
.export-menu > summary { list-style: none; cursor: pointer; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(320px, calc(100vw - 32px));
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.export-panel .btn { justify-content: flex-start; min-height: 40px; }
.export-panel label { font-size: 0.8rem; color: var(--text-secondary); display: flex; flex-direction: column; gap: 2px; }

@media (prefers-reduced-motion: reduce) {
  .scope-opt, .export-panel { transition: none; animation: none; }
}
@media (max-width: 480px) {
  /* Phone group + period container, two rows (320 / 375 / 390 / 430):
       row 1  All | Work | Personal & Home          (one line, the three options share the width)
       row 2  [ period select — takes the remaining width ] [ info, 44px, at the end of the row ]
     A grid keeps the info cell in row 2 at every phone width (no wrap to a third row) and every track can shrink (minmax(0,…)), so nothing scrolls sideways.
     The custom From / To inputs stay a separate block, shown only while "Custom" is selected. */
  .scope-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; grid-template-areas: "seg seg" "period info"; gap: 6px 4px; align-items: center; }
  .scope-seg { grid-area: seg; display: flex; flex-wrap: nowrap; gap: 6px; width: 100%; }
  .scope-opt { flex: 1 1 auto; min-width: 0; justify-content: center; text-align: center; padding-inline: 8px; font-size: 0.8125rem; line-height: 1.2; }
  .scope-opt[aria-pressed="true"] { padding-inline: 6.5px; }
  .scope-period { grid-area: period; min-width: 0; }
  .scope-period .form-control { width: 100%; }
  .scope-row > .info-pop { grid-area: info; justify-self: end; }
  .scope-custom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .scope-custom .btn { grid-column: 1 / -1; justify-content: center; }
  .export-panel { right: auto; left: 0; }
}
@media (max-width: 359px) {
  .scope-bar { padding: 10px; }
  .scope-opt svg { display: none; }       /* 320px: the words matter more than the decorative icons */
}

/* ─── Income / Expenses filter row (Phase 03Y) ─────────────────────────────────────────────────────────────────
   Every field has a visible label (From / To included). Wide screens: one wrapping row. Phone (<= 600px): search full width, From | To side by
   side, then "More filters" (category / type / source — collapsed by filters_logic only while none is active), then Clear filters. */
.tx-filters-card { padding: 16px; }
.tx-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 0; }
.tx-filters .filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 0 1 170px; }
.tx-filters .filter-field-grow { flex: 1 1 220px; }
.tx-filters .filter-label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.tx-filters .filter-field .form-control { width: 100%; min-width: 0; min-height: 42px; }
.tx-filters .filters-advanced { display: contents; }
.tx-filters .filters-advanced[hidden] { display: none; }
.tx-filters .filters-toggle { display: none; min-height: 44px; justify-content: center; }
.tx-filters .filter-actions { display: flex; align-items: flex-end; }
.tx-filters .filter-actions .btn { min-height: 42px; }
.tx-filters .filters-advanced-note { flex: 1 1 100%; }

/* Empty list states: nothing matches the filters (Clear filters + Add) / nothing recorded (Add) */
.tx-empty { padding: 36px 20px; }
.tx-empty-title { color: var(--text-primary); font-weight: 600; }
.tx-empty-detail, .tx-empty-hint { font-size: 0.85rem; margin-top: 6px; overflow-wrap: anywhere; }
.tx-empty-detail { color: var(--text-secondary); }
.tx-empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.tx-empty-actions .btn { min-height: 44px; }

@media (max-width: 600px) {
  .tx-filters-card { padding: 12px; }
  .tx-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
  .tx-filters .filter-field, .tx-filters .filter-field-grow { flex: none; }
  .tx-filters .filter-field-grow { grid-column: 1 / -1; }
  .tx-filters .filters-toggle { display: inline-flex; grid-column: 1 / -1; }
  .tx-filters .filters-advanced { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tx-filters .filters-advanced[hidden] { display: none; }
  .tx-filters .filter-actions { grid-column: 1 / -1; }
  .tx-filters .filter-actions .btn { width: 100%; justify-content: center; min-height: 44px; }
  .tx-filters .filters-advanced-note { grid-column: 1 / -1; }
}

/* ─── Colored theme: the remaining sections follow the same calm palette ───────────────────────────────────────── */
.theme-colored .card, .theme-colored .table-wrapper { border-color: var(--border); }
.theme-colored .page-header h2, .theme-colored .page-header h1.page-title { color: var(--text-primary); }
.theme-colored .card-header { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.theme-colored .table tbody tr:hover td { background: var(--bg-hover); }
.theme-colored .badge-gray { background: var(--bg-hover); color: var(--text-secondary); }

@media (prefers-reduced-motion: reduce) {
  .theme-feedback, .modal { transition: none; animation: none; }
}

/* ─── Responsive form rows ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; max-height: 95vh; max-height: 95dvh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-body { -webkit-overflow-scrolling: touch; }
}
