/* ==========================================================================
   BUDGET LA CHABANNE (Mégane & Pierre) — Feuille de Style Responsive
   Identité visuelle harmonisée avec GestionLaChabanne : Vert Forêt, Sable, Or
   ========================================================================== */

:root {
  --color-forest-dark: #162a22;
  --color-forest: #1f3a2e;
  --color-forest-light: #2d5242;
  --color-sage: #7a9181;
  --color-sand-light: #faf8f5;
  --color-sand: #f2ece1;
  --color-sand-dark: #e2d8c7;
  --color-gold: #b89158;
  --color-gold-hover: #9e7840;
  --color-gold-soft: rgba(184, 145, 88, 0.14);
  --color-leather: #6e472b;
  --color-text: #2b2b28;
  --color-text-muted: #5c5a54;
  --color-white: #ffffff;

  --status-ok-bg: #e7f4ec;
  --status-ok-text: #1b6535;
  --status-ok-border: #b6dfc5;

  --status-warn-bg: #fef4e2;
  --status-warn-text: #9a5b08;
  --status-warn-border: #f5d496;

  --status-late-bg: #fdeaea;
  --status-late-text: #a92323;
  --status-late-border: #f3b7b7;

  --status-neutral-bg: #f0eee9;
  --status-neutral-text: #5c5a54;
  --status-neutral-border: #dcd6c8;

  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 8px rgba(22, 42, 34, 0.05);
  --shadow-md: 0 8px 24px rgba(22, 42, 34, 0.08);
  --shadow-lg: 0 18px 42px rgba(22, 42, 34, 0.16);
  --transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);

  --sidebar-width: 268px;
  --topbar-height: 68px;
  --mobile-nav-height: 66px;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-sand-light);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.text-pos { color: var(--status-ok-text); }
.text-neg { color: var(--status-late-text); }
.text-warn { color: var(--status-warn-text); }
.text-muted { color: var(--color-text-muted); }

/* ================= AUTHENTIFICATION SSO GOOGLE ================= */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: radial-gradient(circle at 20% 20%, var(--color-forest-light) 0%, var(--color-forest-dark) 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.auth-overlay.hidden { display: none; }

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--color-sand-light);
  border: 1px solid rgba(184, 145, 88, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-card-header {
  background: var(--color-forest-dark);
  color: var(--color-white);
  padding: 1.75rem 1.5rem 1.4rem;
  text-align: center;
  border-bottom: 3px solid var(--color-gold);
}

.auth-logo {
  height: 58px;
  width: auto;
  margin-bottom: 0.6rem;
}

.auth-eyebrow {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-gold);
  font-weight: 600;
}

.auth-card-header h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  margin-top: 0.2rem;
  line-height: 1.15;
}

.auth-subtitle {
  font-size: 0.9rem;
  color: rgba(250, 248, 245, 0.8);
  margin-top: 0.15rem;
}

.auth-card-body {
  padding: 1.5rem;
}

.auth-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 1.25rem;
}

.google-btn-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.auth-divider {
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin: 1rem 0 0.85rem;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 24%;
  height: 1px;
  background: var(--color-sand-dark);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.btn-google-official {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.72rem 1rem;
  background: var(--color-white);
  border: 1px solid var(--color-sand-dark);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-google-official:hover {
  background: var(--color-sand);
  border-color: var(--color-gold);
}

.auth-security-badge {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--color-sand);
  border-left: 3px solid var(--color-forest);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.auth-security-badge.auth-warning {
  border-left-color: #d93838;
  background: #fdeaea;
  color: #991b1b;
  width: 100%;
}

/* ================= APP SHELL ================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-forest-dark);
  color: var(--color-sand-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 300;
  border-right: 1px solid rgba(184, 145, 88, 0.22);
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  height: 38px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-brand-title {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-white);
}

.sidebar-brand-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--color-gold);
  letter-spacing: 0.04em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 0.75rem;
}

.nav-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(250, 248, 245, 0.45);
  padding: 0.85rem 0.75rem 0.35rem;
  font-weight: 700;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.68rem 0.8rem;
  margin-bottom: 0.2rem;
  border: none;
  background: transparent;
  color: rgba(250, 248, 245, 0.82);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-white);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--color-forest-light), rgba(184, 145, 88, 0.24));
  color: var(--color-white);
  font-weight: 600;
  border-left: 3px solid var(--color-gold);
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.nav-icon {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
}

.nav-badge {
  background: #d93838;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
}

.nav-badge-gold {
  background: var(--color-gold);
  color: var(--color-forest-dark);
}

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-gold);
  color: var(--color-forest-dark);
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--color-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.7rem;
  color: rgba(250, 248, 245, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon-ghost {
  background: transparent;
  border: none;
  color: rgba(250, 248, 245, 0.75);
  cursor: pointer;
  font-size: 1.05rem;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-xs);
}
.btn-icon-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* ================= MAIN & TOPBAR ================= */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--topbar-height);
  background: rgba(250, 248, 245, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-sand-dark);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.mobile-menu-btn {
  display: none;
  background: var(--color-white);
  border: 1px solid var(--color-sand-dark);
  border-radius: var(--radius-xs);
  width: 38px;
  height: 38px;
  font-size: 1.2rem;
  cursor: pointer;
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--color-forest-dark);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.sync-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--color-sand-dark);
  background: var(--color-white);
}

.sync-badge.sync-online {
  background: var(--status-ok-bg);
  color: var(--status-ok-text);
  border-color: var(--status-ok-border);
}

.app-content {
  padding: 1.4rem 1.5rem 2.5rem;
  max-width: 1460px;
  width: 100%;
  margin: 0 auto;
}

/* ================= BUTTONS & FORMS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.58rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-sm {
  padding: 0.42rem 0.78rem;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 0.26rem 0.55rem;
  font-size: 0.74rem;
  border-radius: var(--radius-xs);
}

.btn-primary {
  background: var(--color-forest);
  color: var(--color-white);
}
.btn-primary:hover {
  background: var(--color-forest-light);
}

.btn-gold {
  background: var(--color-gold);
  color: var(--color-forest-dark);
}
.btn-gold:hover {
  background: var(--color-gold-hover);
  color: var(--color-white);
}

.btn-secondary {
  background: var(--color-white);
  border-color: var(--color-sand-dark);
  color: var(--color-text);
}
.btn-secondary:hover {
  background: var(--color-sand);
}

.btn-danger {
  background: var(--status-late-bg);
  border-color: var(--status-late-border);
  color: var(--status-late-text);
}
.btn-danger:hover {
  background: #f9d2d2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-forest-dark);
}

.form-control {
  width: 100%;
  padding: 0.56rem 0.75rem;
  border: 1px solid var(--color-sand-dark);
  border-radius: var(--radius-xs);
  background: var(--color-white);
  font-size: 0.9rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px var(--color-gold-soft);
}

.form-hint {
  font-size: 0.74rem;
  color: var(--color-text-muted);
}

/* ================= CARDS & KPI GRID ================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}

.kpi-card {
  background: var(--color-white);
  border: 1px solid var(--color-sand-dark);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.kpi-card.accent-forest {
  background: linear-gradient(135deg, var(--color-forest-dark), var(--color-forest));
  color: var(--color-white);
  border-color: var(--color-forest-dark);
}
.kpi-card.accent-forest .kpi-label,
.kpi-card.accent-forest .kpi-sub {
  color: rgba(250, 248, 245, 0.78);
}

.kpi-card.accent-warn {
  background: var(--status-warn-bg);
  border-color: var(--status-warn-border);
}

.kpi-card.accent-danger {
  background: var(--status-late-bg);
  border-color: var(--status-late-border);
}

.kpi-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.card {
  background: var(--color-white);
  border: 1px solid var(--color-sand-dark);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--color-sand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-forest-dark);
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.card-body {
  padding: 1.1rem 1.2rem;
}

/* ================= ALERTS & TRANSFER SUGGESTIONS ================= */
.alerts-panel {
  border-left: 4px solid var(--status-warn-text);
  background: linear-gradient(180deg, #fffdf8 0%, #ffffff 100%);
  margin-bottom: 0.9rem;
}

.alerts-panel.critical {
  border-left-color: var(--status-late-text);
}

.alerts-compact-bar {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.68rem 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.alerts-compact-bar:hover {
  background: rgba(254, 244, 226, 0.55);
}

.alerts-panel.critical .alerts-compact-bar:hover {
  background: rgba(253, 234, 234, 0.55);
}

.alerts-compact-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-size: 0.86rem;
}

.alerts-compact-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-forest);
  flex-shrink: 0;
}

.alerts-collapsible-body {
  padding: 0 1.05rem 1rem;
  border-top: 1px solid var(--color-sand);
}

.snapshot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.snapshot-table th {
  text-align: left;
  padding: 0.5rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-sand-dark);
}

.snapshot-table td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid var(--color-sand);
  vertical-align: middle;
}

.anchor-dot {
  display: inline-block;
  font-size: 0.68rem;
  margin-left: 3px;
  color: var(--color-gold);
}

.alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.alert-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--status-warn-border);
  background: var(--status-warn-bg);
}

.alert-row.critical {
  border-color: var(--status-late-border);
  background: var(--status-late-bg);
}

.alert-info {
  flex: 1;
  min-width: 240px;
}

.alert-headline {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.alert-detail {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.suggestion-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-white);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.72rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-forest-dark);
  cursor: pointer;
  transition: var(--transition);
}

.suggestion-pill:hover {
  background: var(--color-forest);
  color: var(--color-white);
  border-color: var(--color-forest);
}

/* ================= CHARTS ================= */
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--color-sand-dark);
  background: var(--color-sand-light);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.chip-toggle.active {
  background: var(--color-forest);
  color: var(--color-white);
  border-color: var(--color-forest);
}

.chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
  position: relative;
}

.chart-svg {
  width: 100%;
  min-width: 560px;
  height: auto;
  display: block;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--color-forest-dark);
  color: var(--color-white);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  box-shadow: var(--shadow-md);
  z-index: 50;
  min-width: 170px;
  border: 1px solid var(--color-gold);
  display: none;
}

.two-col-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
}

/* ================= ANNUAL MATRIX TABLE ================= */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.matrix-table th,
.matrix-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--color-sand);
  text-align: right;
  white-space: nowrap;
}

.matrix-table th {
  background: var(--color-forest-dark);
  color: var(--color-white);
  font-weight: 600;
  font-size: 0.76rem;
  position: sticky;
  top: 0;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 165px;
}

.matrix-table th:first-child {
  z-index: 4;
}

.matrix-table td:first-child {
  background: var(--color-white);
  font-weight: 600;
  border-right: 1px solid var(--color-sand-dark);
}

.matrix-row-summary td {
  background: var(--color-sand-light);
  font-weight: 700;
}
.matrix-row-summary td:first-child {
  background: var(--color-sand);
}

.matrix-row-total td {
  background: #edf3ef;
  font-weight: 700;
  border-top: 2px solid var(--color-forest);
  border-bottom: 2px solid var(--color-forest);
}
.matrix-row-total td:first-child {
  background: #e1ece5;
}

.matrix-cell-clickable {
  cursor: pointer;
  transition: background 0.15s ease;
}

.matrix-cell-clickable:hover {
  background: var(--color-gold-soft) !important;
}

.cell-savings {
  background: var(--status-warn-bg) !important;
  color: var(--status-warn-text);
  font-weight: 700;
}

.cell-deficit {
  background: var(--status-late-bg) !important;
  color: var(--status-late-text);
  font-weight: 700;
}

.cell-mini-tag {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  opacity: 0.9;
}

/* ================= STANDARD DATA TABLES & LISTS ================= */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th {
  text-align: left;
  padding: 0.65rem 0.8rem;
  background: var(--color-sand);
  color: var(--color-forest-dark);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-sand-dark);
}

.data-table td {
  padding: 0.72rem 0.8rem;
  border-bottom: 1px solid var(--color-sand);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(242, 236, 225, 0.35);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-account {
  background: var(--color-sand);
  color: var(--color-forest-dark);
  border-color: var(--color-sand-dark);
}

.badge-ok {
  background: var(--status-ok-bg);
  color: var(--status-ok-text);
  border-color: var(--status-ok-border);
}

.badge-warn {
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
  border-color: var(--status-warn-border);
}

.badge-danger {
  background: var(--status-late-bg);
  color: var(--status-late-text);
  border-color: var(--status-late-border);
}

.badge-neutral {
  background: var(--status-neutral-bg);
  color: var(--status-neutral-text);
  border-color: var(--status-neutral-border);
}

/* ================= ACCOUNTS GRID ================= */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.account-card {
  background: var(--color-white);
  border: 1px solid var(--color-sand-dark);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  border-top: 4px solid var(--color-forest);
}

.account-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.account-name {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-forest-dark);
  line-height: 1.15;
}

.account-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  background: var(--color-sand-light);
  padding: 0.7rem;
  border-radius: var(--radius-sm);
}

.metric-box-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
}

.metric-box-val {
  font-size: 1rem;
  font-weight: 700;
}

/* ================= CATEGORY BARS ================= */
.cat-bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.cat-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.cat-bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
}

.cat-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--color-sand);
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--color-forest);
}

/* ================= FILTER BAR & TABS ================= */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tab-pills {
  display: inline-flex;
  background: var(--color-sand);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  gap: 0.25rem;
}

.tab-pill {
  border: none;
  background: transparent;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.tab-pill.active {
  background: var(--color-white);
  color: var(--color-forest-dark);
  box-shadow: var(--shadow-sm);
}

/* ================= MODALS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(22, 42, 34, 0.56);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.hidden { display: none; }

.modal-box {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.25rem;
  background: var(--color-forest-dark);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--color-gold);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--color-white);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-xs);
}
.modal-close:hover { background: rgba(255, 255, 255, 0.14); }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--color-sand);
  background: var(--color-sand-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.schedule-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.exception-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-sand-dark);
  border-radius: var(--radius-xs);
  background: var(--color-sand-light);
  margin-bottom: 0.45rem;
  font-size: 0.84rem;
}

/* ================= TOAST ================= */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
}

.toast {
  background: var(--color-forest-dark);
  color: var(--color-white);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--color-gold);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  animation: fadeSlideUp 0.22s ease;
}

.toast.toast-error {
  background: #8c1d1d;
  border-left-color: #ffb3b3;
}

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

/* ================= MOBILE NAVIGATION & RESPONSIVE ================= */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 250;
}

.sidebar-backdrop.open { display: block; }

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-height);
  background: var(--color-forest-dark);
  border-top: 2px solid var(--color-gold);
  z-index: 240;
  grid-template-columns: repeat(5, 1fr);
}

.mobile-nav-btn {
  border: none;
  background: transparent;
  color: rgba(250, 248, 245, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

.mobile-nav-btn .mnav-icon { font-size: 1.15rem; }
.mobile-nav-btn.active {
  color: var(--color-gold);
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-muted);
}

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

@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
    padding-bottom: calc(var(--mobile-nav-height) + 0.5rem);
  }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-bottom-nav {
    display: grid;
  }
  .topbar {
    padding: 0 0.9rem;
  }
  .topbar-title {
    font-size: 1.25rem;
  }
  .topbar-subtitle {
    display: none;
  }
  .sync-badge {
    display: none;
  }
  .app-content {
    padding: 1rem 0.85rem 2rem;
  }
  .toast-container {
    bottom: calc(var(--mobile-nav-height) + 0.75rem);
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
  }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .accounts-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.35rem; }
}
