/* =========================================================
   CRM UI – style.css (v2 — polished, responsive, production)
   ========================================================= */

/* -------------------------
   GOOGLE FONTS
------------------------- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700;900&family=DM+Mono:wght@400;500&display=swap');

/* -------------------------
   THEME TOKENS
------------------------- */
:root{
  /* Core */
  --bg:#05080f;
  --surface: rgba(17,26,46,.65);
  --surface-2: rgba(15,23,42,.60);
  --text:#e6edf7;
  --muted:#9aa7bd;
  --line: rgba(30,42,68,1);

  /* Accents */
  --accent:#3b82f6;
  --accent-hover:#2563eb;
  --good:#22c55e;
  --warn:#f59e0b;
  --danger:#ef4444;

  /* UI */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --shadow: 0 8px 24px rgba(0,0,0,.22);
  --shadow-sm: 0 4px 14px rgba(0,0,0,.16);
  --shadow-accent: 0 8px 20px rgba(59,130,246,.20);

  /* App chrome */
  --chrome-bg: rgba(8,13,25,.94);
  --chrome-border: rgba(30,48,80,.75);

  /* Footer height */
  --footer-height: 52px;

  /* Typography */
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'Fira Code', monospace;

  /* Transitions */
  --t: .15s ease;
}

html[data-theme="light"]{
  --bg:#f0f4fa;
  --surface:#ffffff;
  --surface-2:#f8fafd;
  --text:#0f172a;
  --muted:#64748b;
  --line: rgba(15,23,42,.10);
  --accent:#2563eb;
  --accent-hover:#1d4ed8;

  --shadow: 0 4px 20px rgba(15,23,42,.08);
  --shadow-sm: 0 2px 10px rgba(15,23,42,.06);
  --shadow-accent: 0 8px 20px rgba(37,99,235,.16);

  --chrome-bg: rgba(8,13,25,.96);
  --chrome-border: rgba(255,255,255,.07);
}

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

html { scroll-behavior: smooth; }

body{
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(59,130,246,.13), transparent 60%),
    linear-gradient(180deg, rgba(7,11,20,1) 0%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
}

html[data-theme="light"] body{
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(37,99,235,.07), transparent 60%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 16px;
}

/* -------------------------
   UTILITIES
------------------------- */
.section { margin-top: 16px; }
.section:first-child { margin-top: 0; }

.hr {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
  border: none;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* -------------------------
   AUTH PAGES
------------------------- */
.auth-page {
  min-height: calc(100vh - var(--footer-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  width: 100%;
  max-width: 720px;
  padding: 20px;
}

.auth-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-grid-3 {
  display: grid;
  grid-template-columns: 1fr 140px 1fr;
  gap: 12px;
}

.auth-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* -------------------------
   BUTTONS
------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  transition: border-color var(--t), background var(--t), transform .08s ease, box-shadow var(--t);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  border-color: rgba(59,130,246,.30);
  background: rgba(59,130,246,.06);
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(160deg, #3b82f6 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.btn.primary:hover {
  background: linear-gradient(160deg, #60a5fa 0%, #2563eb 100%);
  border-color: #2563eb;
  box-shadow: 0 10px 24px rgba(59,130,246,.30);
}

.btn.danger {
  background: rgba(239,68,68,.10);
  border-color: rgba(239,68,68,.20);
  color: #fca5a5;
}

.btn.danger:hover {
  background: rgba(239,68,68,.16);
  border-color: rgba(239,68,68,.32);
}

html[data-theme="light"] .btn.danger { color: #b91c1c; }

.btn.sm {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn.ghost:hover {
  background: rgba(148,163,184,.10);
  border-color: rgba(148,163,184,.16);
  color: var(--text);
}

/* -------------------------
   CARDS
------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  transition: border-color var(--t);
}

html[data-theme="light"] .card {
  background: #fff;
  border-color: rgba(15,23,42,.09);
}

/* -------------------------
   FORMS
------------------------- */
label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}

input::placeholder, textarea::placeholder { color: rgba(107,114,128,.70); }

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder { color: rgba(15,23,42,.38); }

input:focus, select:focus, textarea:focus {
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

/* -------------------------
   TABLES
------------------------- */
.table-wrap { overflow: auto; border-radius: var(--radius); }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  padding: 13px 12px;
  font-size: 13px;
  text-align: left;
  border-bottom: 1px solid rgba(15,23,42,.06);
}

html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-bottom: 1px solid rgba(34,48,74,.40);
}

th {
  background: rgba(15,23,42,.03);
  color: rgba(15,23,42,.60);
  font-size: 11px;
  letter-spacing: .06em;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover { color: var(--accent); }

html[data-theme="dark"] th {
  background: rgba(17,26,46,.80);
  color: rgba(148,163,184,.80);
  border-bottom: 1px solid rgba(34,48,74,.65);
}

/* Zebra striping */
tbody tr:nth-child(even) td {
  background: rgba(15,23,42,.015);
}
html[data-theme="dark"] tbody tr:nth-child(even) td {
  background: rgba(255,255,255,.018);
}

/* Row hover */
tbody tr {
  transition: background var(--t);
}
tbody tr:hover td {
  background: rgba(59,130,246,.05) !important;
}
html[data-theme="dark"] tbody tr:hover td {
  background: rgba(59,130,246,.07) !important;
}

/* Last row no border */
tbody tr:last-child td { border-bottom: none; }

table.compact th, table.compact td { padding: 10px 12px; }

/* -------------------------
   STATUS BADGES (replaces plain text)
------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  border: 1px solid transparent;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge.active {
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.22);
  color: #15803d;
}
.badge.active::before { background: #22c55e; }

html[data-theme="dark"] .badge.active {
  background: rgba(34,197,94,.14);
  border-color: rgba(34,197,94,.28);
  color: #86efac;
}
html[data-theme="dark"] .badge.active::before { background: #4ade80; }

.badge.off-market {
  background: rgba(148,163,184,.10);
  border-color: rgba(148,163,184,.20);
  color: #64748b;
}
.badge.off-market::before { background: #94a3b8; }

html[data-theme="dark"] .badge.off-market {
  background: rgba(148,163,184,.12);
  border-color: rgba(148,163,184,.22);
  color: #94a3b8;
}

.badge.pending {
  background: rgba(245,158,11,.12);
  border-color: rgba(245,158,11,.22);
  color: #b45309;
}
.badge.pending::before { background: #f59e0b; }

html[data-theme="dark"] .badge.pending {
  color: #fcd34d;
}

.badge.danger {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.22);
  color: #b91c1c;
}
.badge.danger::before { background: #ef4444; }

html[data-theme="dark"] .badge.danger {
  color: #fca5a5;
}

/* Market badges */
.badge.market-usa {
  background: rgba(59,130,246,.10);
  border-color: rgba(59,130,246,.20);
  color: #1d4ed8;
  font-size: 10px;
}
html[data-theme="dark"] .badge.market-usa {
  color: #93c5fd;
}

.badge.market-rio {
  background: rgba(245,158,11,.10);
  border-color: rgba(245,158,11,.20);
  color: #92400e;
  font-size: 10px;
}
html[data-theme="dark"] .badge.market-rio {
  color: #fcd34d;
}

/* -------------------------
   PILLS (legacy compat)
------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid var(--line);
  background: rgba(148,163,184,.10);
  color: rgba(15,23,42,.65);
}

html[data-theme="dark"] .pill {
  background: rgba(96,165,250,.08);
  border-color: rgba(96,165,250,.20);
  color: #bfdbfe;
}

.pill.good  { background: rgba(34,197,94,.12);  border-color: rgba(34,197,94,.22);  color: #15803d; }
.pill.warn  { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.22); color: #b45309; }
.pill.danger{ background: rgba(239,68,68,.12);  border-color: rgba(239,68,68,.22);  color: #b91c1c; }

html[data-theme="dark"] .pill.good   { color: #86efac; }
html[data-theme="dark"] .pill.warn   { color: #fcd34d; }
html[data-theme="dark"] .pill.danger { color: #fca5a5; }

/* -------------------------
   PAGE HEADER
------------------------- */
.page-header.centered {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.page-title-wrap {
  text-align: center;
  max-width: 680px;
}

.page-title {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.page-subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.page-header-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 8px;
}

@media (max-width: 900px){
  .page-header.centered { flex-direction: column; gap: 12px; }
  .page-header-actions { position: static; transform: none; }
}

/* -------------------------
   KPI GRID
------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

@media(max-width: 980px){ .kpi-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media(max-width: 520px){ .kpi-grid{ grid-template-columns: 1fr; } }

.kpi-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.kpi-value {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
}

.kpi-hint { font-size: 12px; color: var(--muted); }

.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.14);
  color: var(--accent);
  flex: 0 0 auto;
  font-size: 20px;
}

/* -------------------------
   FILTERS PANEL
------------------------- */
.filters-panel {
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.filters-title {
  font-weight: 900;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filters-grid .muted.small,
.filters-head .muted.small,
.filters-head a.muted { color: rgba(15,23,42,.65); }

html[data-theme="dark"] .filters-grid .muted.small,
html[data-theme="dark"] .filters-head .muted.small,
html[data-theme="dark"] .filters-head a.muted { color: rgba(226,232,240,.55); }

.filters-head a {
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
}
.filters-head a:hover { color: var(--accent-hover); }

.filters-grid {
  display: grid;
  grid-template-columns: 1.2fr 200px 200px 200px 100px 100px;
  gap: 10px;
  align-items: end;
}

.filters-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

.filters-grid > .btn,
.filters-grid > button,
.filters-grid > input[type="submit"] { height: 38px; }

@media (max-width: 1100px){
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .filters-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* -------------------------
   SEARCH BAR (standalone)
------------------------- */
.search-bar {
  position: relative;
  flex: 1;
}

.search-bar input {
  padding-left: 36px;
}

.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
  opacity: .5;
}

/* -------------------------
   DASHBOARD GRID
------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

@media(max-width: 980px){ .dashboard-grid{ grid-template-columns: 1fr; } }

/* Tasks */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
}

.task-item {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 12px;
  background: var(--surface);
  transition: border-color var(--t), box-shadow var(--t);
}

.task-item:hover {
  border-color: rgba(59,130,246,.25);
  box-shadow: var(--shadow-sm);
}

.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-time { font-weight: 900; }
.task-title { font-weight: 800; }

.task-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

/* -------------------------
   APP SHELL
------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 68px 1fr;
  min-height: 100vh;
}

.app-shell.no-sidebar { grid-template-columns: 1fr; }

@media (max-width: 900px){
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { display: none; }
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--chrome-border);
  background: var(--chrome-bg);
  backdrop-filter: blur(12px);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 60;
}

.side-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 6px rgba(34,197,94,.5);
  flex: 0 0 auto;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-link {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  color: rgba(226,232,240,.60);
  text-decoration: none;
  transition: background var(--t), border-color var(--t), color var(--t);
  position: relative;
}

.side-link:hover {
  background: rgba(148,163,184,.10);
  border-color: rgba(148,163,184,.16);
  color: rgba(226,232,240,.92);
  text-decoration: none;
}

.side-link.active {
  background: rgba(59,130,246,.18);
  border-color: rgba(59,130,246,.32);
  color: #e0eaff;
}

.side-ico { font-size: 17px; line-height: 1; }

.side-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  text-decoration: none;
  transition: box-shadow var(--t);
}

.side-avatar:hover {
  box-shadow: 0 0 0 2px rgba(59,130,246,.50);
}

.side-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(59,130,246,.30);
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* -------------------------
   TOPBAR
------------------------- */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-border);
  backdrop-filter: blur(12px);
}

.top-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.brand { display: flex; align-items: baseline; gap: 8px; margin-right: 8px; }

.brand-link {
  color: rgba(226,232,240,.95);
  text-decoration: none;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -.01em;
}
.brand-link:hover { text-decoration: none; opacity: .85; }

.top-link {
  color: rgba(226,232,240,.65);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: color var(--t), background var(--t), border-color var(--t);
}

.top-link:hover {
  color: rgba(226,232,240,.92);
  background: rgba(148,163,184,.10);
  text-decoration: none;
}

.top-link.active {
  color: #e0eaff;
  background: rgba(59,130,246,.18);
  border-color: rgba(59,130,246,.30);
}

.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-form { margin: 0; display: inline; }

/* Topbar button overrides */
.app-topbar .btn {
  background: rgba(148,163,184,.08);
  border-color: rgba(148,163,184,.16);
  color: rgba(226,232,240,.88);
  box-shadow: none;
  font-size: 12px;
  padding: 7px 14px;
}
.app-topbar .btn:hover {
  background: rgba(148,163,184,.14);
  border-color: rgba(148,163,184,.24);
}
.app-topbar .btn.primary {
  background: rgba(59,130,246,.88);
  border-color: rgba(59,130,246,.95);
  color: #fff;
}
.app-topbar .btn.danger {
  background: rgba(239,68,68,.14);
  border-color: rgba(239,68,68,.24);
  color: #fca5a5;
}

/* -------------------------
   PAGE CONTENT
------------------------- */
.app-content {
  flex: 1;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px calc(var(--footer-height) + 20px);
}

.app-content > :first-child { margin-top: 0 !important; }

/* -------------------------
   FOOTER
------------------------- */
.app-footer {
  position: sticky;
  bottom: 0;
  z-index: 40;
  width: 100%;
  background: var(--chrome-bg);
  border-top: 1px solid var(--chrome-border);
  backdrop-filter: blur(12px);
}

.app-footer-inner {
  height: var(--footer-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.footer-brand  { font-weight: 900; font-size: 13px; color: rgba(226,232,240,.90); }
.footer-sep    { color: rgba(226,232,240,.35); }
.footer-sub    { color: rgba(226,232,240,.65); font-weight: 700; font-size: 13px; }
.footer-right  { color: rgba(226,232,240,.55); font-size: 11px; font-weight: 600; white-space: nowrap; }

/* -------------------------
   LIGHT MODE POLISH
------------------------- */
html[data-theme="light"] table {
  background: #fff;
  border-color: rgba(15,23,42,.09);
}
html[data-theme="light"] th {
  background: rgba(15,23,42,.025);
  color: rgba(15,23,42,.55);
  border-bottom: 1px solid rgba(15,23,42,.07);
}
html[data-theme="light"] td {
  border-bottom: 1px solid rgba(15,23,42,.05);
}
html[data-theme="light"] .btn {
  background: #f1f5f9;
  border-color: rgba(15,23,42,.11);
  color: #0f172a;
}
html[data-theme="light"] .btn:hover {
  background: #e2e8f0;
  border-color: rgba(15,23,42,.16);
}
html[data-theme="light"] .btn.primary {
  background: linear-gradient(160deg, #3b82f6 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  color: #fff;
  box-shadow: var(--shadow-accent);
}

/* -------------------------
   MOBILE
------------------------- */
@media (max-width: 768px){
  .app-sidebar { display: none; }
  .app-shell   { grid-template-columns: 1fr !important; }

  .app-content {
    padding: 12px 12px calc(var(--footer-height) + 12px);
  }

  .app-topbar {
    height: auto;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
  }

  .top-left, .top-right { width: 100%; }
  .top-left  { justify-content: space-between; }
  .top-right { flex-wrap: wrap; justify-content: flex-start; }
  .top-right .btn { flex: 1 1 auto; }

  .filters-grid { grid-template-columns: 1fr; }
  .filters-actions { grid-column: auto; justify-content: stretch; }
  .filters-actions .btn,
  .filters-grid > .btn,
  .filters-grid > button,
  .filters-grid > input[type="submit"] { width: 100%; }

  .form-grid-2 { grid-template-columns: 1fr; }

  .btn, .btn.sm { min-height: 44px; }

  :root { --footer-height: 72px; }
  .app-footer-inner {
    height: var(--footer-height);
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 10px 14px;
    gap: 2px;
  }
  .footer-right { white-space: normal; }

  .auth-grid-2, .auth-grid-3 { grid-template-columns: 1fr; }
  .page-title { font-size: 24px; }
}

@media (max-width: 480px){
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* -------------------------
   DISMISSIBLE MESSAGES
------------------------- */
.messages-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(34,197,94,.35);
  background: rgba(34,197,94,.10);
  font-size: 13px;
  font-weight: 600;
  animation: msgFadeIn .2s ease;
}

.msg-error {
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.10);
  color: #fca5a5;
}

.msg-warning {
  border-color: rgba(245,158,11,.35);
  background: rgba(245,158,11,.10);
  color: #fcd34d;
}

.msg-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: opacity .12s ease;
}

.msg-close:hover { opacity: 1; }

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}