/* SAF-T CEO – style aligned with Invoice Management */
:root {
  --bg: #f1f3f5;
  --surface: #ffffff;
  --text: #1a1d29;
  --text-muted: #5c5f6b;
  --primary: #212545;
  --primary-hover: #181c36;
  --primary-light: #eff6ff;
  --theme-button-bg: #212545;
  --theme-button-hover: #181c36;
  --theme-header-bg: #1e293b;
  --theme-menu-bg: #1e293b;
  --theme-table-header-bg: #bababa;
  --theme-indicators-card-bg: #d1d6e6;
  --border: #e2e6f0;
  --error: #dc2626;
  --success: #16a34a;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 2px 6px rgba(0,0,0,.08);
  --sidebar-bg: #1e293b;
  --sidebar-text: #e2e8f0;
  --sidebar-text-muted: #94a3b8;
  --sidebar-width: 180px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

h1, h2, h3 {
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--text);
}

h1 { font-size: 18px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }

p { margin: 0 0 8px; }

/* ========== Layout ========== */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  flex-shrink: 0;
  background: var(--theme-header-bg);
  color: #e2e8f0;
  padding: 4px 14px;
  font-size: 12px;
  position: relative;
  z-index: 60;
  line-height: 1.2;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  min-height: 0;
}

.app-header-left {
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.2;
}

.app-header-brand {
  color: #fff !important;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex: 0 0 auto;
}

.app-header-logo {
  height: 26px;
  width: auto;
  max-height: 26px;
  object-fit: contain;
  object-position: center;
  border-radius: 2px;
  display: block;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}

.app-header-menu-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: #e2e8f0;
  width: 32px;
  height: 28px;
  padding: 0;
  margin: 0;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}
.app-header-menu-toggle:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.5);
  color: #fff;
  filter: none;
}

.app-header-tenant {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.2;
}
.app-header-tenant strong {
  color: #e2e8f0;
  font-weight: 600;
}
.app-header-tenant-meta {
  color: #94a3b8;
  font-weight: 400;
}

.login-brand-logo {
  width: 148px;
  height: 48px;
  object-fit: contain;
  object-position: center;
  display: block;
  background: transparent;
  border-radius: 0;
  margin: 0;
  padding: 0;
}

.login-hero-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 8px;
}

.login-hero-title .login-brand-logo {
  flex-shrink: 0;
}

.login-hero-tagline {
  margin: 0 !important;
  max-width: 560px;
  color: #334155;
  font-size: 15px;
  line-height: 1.35;
}

.login-footer-logo {
  width: 168px;
  height: 84px;
  object-fit: contain;
  display: block;
  border-radius: 0;
  margin: 0 auto 10px;
}

.footer-col-logo {
  display: block;
  width: auto;
  max-width: 140px;
  height: 40px;
  object-fit: contain;
  margin: 8px 0 0;
}

.app-header-left strong { color: #e2e8f0; }

/* legacy chip kept for other pages if still referenced */
.tenant-chip {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  min-width: 0;
  line-height: 1.2;
}

.tenant-chip strong {
  color: #e2e8f0;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tenant-chip span {
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.2;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1.2;
}

.user-name, .app-header-user {
  color: #e2e8f0;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.lang-form {
  margin: 0;
  display: inline-flex;
  align-items: center;
}
.lang-form select,
.app-header-lang-select {
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.2;
  height: 28px;
  background: #334155;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 4px;
  color: #f1f5f9;
  cursor: pointer;
  width: auto;
  min-width: 0;
  margin: 0;
  appearance: auto;
  box-sizing: border-box;
}

.lang-form select:hover,
.app-header-lang-select:hover {
  background: #475569;
}
.lang-form select:focus,
.app-header-lang-select:focus {
  outline: none;
  border-color: rgba(255,255,255,.5);
}

.logout-form {
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.logout-form button,
.app-header-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: #e2e8f0;
  padding: 4px 10px;
  height: 28px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}

.logout-form button:hover,
.app-header-logout:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.5);
  color: #fff;
  filter: none;
  text-decoration: none;
}

.app-layout-body {
  display: flex;
  flex: 1;
  min-width: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
/* Same pattern as InvoiceManagement: hide sidebar without stacking it under content */
.app-layout.sidebar-hidden .sidebar {
  display: none;
}
.app-layout.sidebar-hidden .main-content {
  width: 100%;
}
/* backwards-compatible alias */
body.sidebar-collapsed .sidebar {
  display: none;
}
body.sidebar-collapsed .main-content {
  width: 100%;
}

.app-layout > .main-footer {
  margin-top: auto;
  flex-shrink: 0;
  border-radius: 0;
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--theme-menu-bg, var(--sidebar-bg));
  color: var(--sidebar-text);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-brand strong {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand span {
  font-size: 10px;
  color: var(--sidebar-text-muted);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 11px;
  transition: background .15s, color .15s;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(255,255,255,.14);
  color: #fff;
}

.sidebar-nav-group {
  margin-top: 2px;
}

.sidebar-nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
}

.sidebar-nav-group-toggle:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-nav-group.open > .sidebar-nav-group-toggle {
  color: #fff;
}

.sidebar-nav-chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.75;
  transition: transform .15s ease;
}

.sidebar-nav-group.open .sidebar-nav-chevron {
  transform: rotate(180deg);
}

.sidebar-nav-sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 4px 8px;
  margin: 0 0 4px;
  border-left: 1px solid rgba(255,255,255,.12);
  margin-left: 8px;
}

.sidebar-nav-sub[hidden] {
  display: none !important;
}

.sidebar-nav-sub a {
  font-weight: 500;
  color: #fff;
}

.sidebar-nav-sub a:hover,
.sidebar-nav-sub a.active {
  color: #fff;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 12px 16px 16px;
  background: var(--bg);
}

.page-content { min-width: 0; }

.page-header {
  margin-bottom: 12px;
}

.page-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 11px;
}

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

.top p { color: var(--text-muted); margin: 0; }

.list-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.list-actions form {
  margin: 0;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--theme-table-header-bg, #9ca3af);
  border-bottom: 1px solid var(--theme-table-header-bg, #9ca3af);
  margin: 12px 0;
}

.main-content .card > .list-actions + .section-divider {
  display: none;
}

/* ========== Cards / grid / KPIs ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0;
}

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

.health-grid {
  grid-template-columns: 220px 1fr;
  margin-bottom: 12px;
}

.health-score {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  margin: 8px 0;
}

.health-ok { color: var(--success); }
.health-warn { color: #d97706; }
.health-bad { color: var(--error); }

.period-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-filter label {
  margin: 0;
  white-space: nowrap;
}

.kpis .card {
  background: var(--theme-indicators-card-bg, var(--surface));
}

.kpi-card small { display: block; }

.kpis .card span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.kpis .card strong {
  display: block;
  font-size: 18px;
  margin: 6px 0;
  color: var(--text);
}

.kpis .card small {
  color: var(--text-muted);
  font-size: 11px;
}

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

/* ========== Forms ========== */
label {
  display: block;
  margin: 0 0 2px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
}

input, textarea, select {
  width: 100%;
  margin-top: 0;
  padding: 4px 6px;
  border: 1px solid #000;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  box-sizing: border-box;
}

.card input,
.card textarea,
.card select {
  border: 1px solid #000;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #000;
  box-shadow: 0 0 0 1px #000;
}

.form-row {
  margin-bottom: 8px;
}

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

.formula-input {
  width: 100%;
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.formula-fn-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
}

.formula-fn-btn {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid #000;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
}

.formula-fn-btn:hover {
  background: #e2e8f0;
}

.saft-indicators-panel {
  margin-top: 16px;
}

.saft-indicators-panel h3 {
  margin: 0 0 4px;
}

.formula-preview {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.compare-indicator-name {
  cursor: help;
}
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .form-grid-2,
  .form-grid-3 { grid-template-columns: 1fr; }
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.checkbox-row input { width: auto; margin: 0; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}

.form-max,
.tenant-form { max-width: 640px; }

.btn-primary {
  background: var(--theme-button-bg, var(--primary));
  color: #fff;
}

.btn-primary:hover {
  background: var(--theme-button-hover, var(--primary-hover));
}

.period-select-wrap {
  position: relative;
  display: inline-block;
}

.period-range-tooltip {
  display: none;
  position: absolute;
  z-index: 20;
  left: 0;
  bottom: calc(100% + 6px);
  max-width: 280px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text, #1a1d26);
  background: #fff;
  border: 1px solid var(--border, #e2e6f0);
  border-radius: var(--radius-sm, 6px);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  white-space: nowrap;
  pointer-events: none;
}

.period-select-wrap:hover .period-range-tooltip:not(:empty),
.period-select-wrap:focus-within .period-range-tooltip:not(:empty) {
  display: block;
}

.hint {
  color: var(--text-muted);
  font-size: 11px;
  margin: 4px 0 10px;
  font-weight: 500;
}

/* ========== Buttons ========== */
button,
.btn,
.btn-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  background: var(--theme-button-bg, var(--primary));
  color: #fff;
  text-decoration: none;
  box-shadow: none;
}

button:hover,
.btn:hover,
.btn-export:hover {
  background: var(--theme-button-hover, var(--primary-hover));
  filter: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--text-muted);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  box-shadow: none;
  padding: 4px 10px;
}

.btn-danger:hover { background: #b91c1c; }

.btn-link,
.link-btn {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  font-size: 11px;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 2px 4px;
}

.btn-link:hover,
.link-btn:hover {
  text-decoration: underline;
  background: transparent;
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.row-actions form { margin: 0; }

/* ========== Messages ========== */
.flash,
.msg-error,
.msg-success {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  margin: 0 0 8px;
  border: 1px solid transparent;
}

.flash.ok,
.msg-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: var(--success);
}

.flash.err,
.msg-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--error);
}

/* ========== Tables ========== */
.table-wrap {
  overflow: auto;
  max-height: 70vh;
  border-radius: var(--radius-sm);
  border: 1px solid #000;
  background: var(--surface);
  padding: 0;
}

/* Nu combina card+table-wrap pe același element: filtrele nu trebuie în zona cu scroll */
.card.table-wrap {
  overflow: visible;
  max-height: none;
}

.table-wrap table {
  border-collapse: separate;
  border-spacing: 0;
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--theme-table-header-bg, #9ca3af);
  background-clip: padding-box;
  box-shadow: inset 0 -1px 0 #d1d5db;
}

.table-wrap .actions {
  white-space: nowrap;
}

.btn.btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}

.table-wrap .actions form {
  display: inline;
  margin: 0;
}

.table-wrap .actions .btn-danger {
  min-height: 24px;
  padding: 2px 6px;
  font-size: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th, td {
  padding: 4px 8px;
  text-align: left;
  border: 1px solid #d1d5db;
}

th {
  font-weight: 600;
  color: #111827;
  background: var(--theme-table-header-bg, #9ca3af);
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:hover td { background: #f8fafc; }

td.num, th.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-feature-settings: "tnum" 1;
}

.trend-col {
  text-align: center;
  width: 64px;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.trend-up {
  color: #15803d;
  background: #dcfce7;
}

.trend-down {
  color: #b91c1c;
  background: #fee2e2;
}

.trend-flat {
  color: #64748b;
  background: #e2e8f0;
}

.compare-indicators-table tbody tr:hover {
  background: #f8fafc;
}

tfoot td {
  font-weight: 700;
  background: #e5e7eb;
  border-top: 2px solid #111827;
}

.table-wrap tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: #e5e7eb;
}

.status-pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
}

.status-off {
  background: #f1f5f9;
  color: #64748b;
}

/* ========== Tabs (Invoice Management style) ========== */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 5px solid #374151;
  flex-wrap: wrap;
}

.tabs .tab,
.tabs .tab-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 3px solid transparent;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.tabs .tab:hover,
.tabs .tab-btn:hover {
  color: var(--text);
  background: #f8fafc;
  border-color: #9ca3af;
}

.tabs .tab.active,
.tabs .tab-btn.active {
  color: var(--primary);
  background: var(--surface);
  border: 3px solid #374151;
  border-bottom-color: var(--surface);
  margin-bottom: -5px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.export-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.table-export-host {
  position: relative;
}

.table-export-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
}

.table-export-toolbar .btn-export {
  min-height: 24px;
  padding: 2px 8px;
  font-size: 10px;
}

.filter-toggle-btn {
  height: 22px;
  width: 22px;
  min-height: 22px;
  min-width: 22px;
  padding: 0;
}

.saft-filter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

/* Ascuns din start (fără FOUC) — JS doar comută data-open */
.saft-filter-layout:not([data-open="1"]) .saft-filter-panel {
  display: none !important;
}

.saft-filter-layout[data-open="1"] {
  grid-template-columns: 280px minmax(0, 1fr);
}

.saft-filter-layout[data-open="1"] .saft-table-wrap {
  border-color: #dc2626;
}

.saft-filter-panel {
  order: 1;
  padding: 10px;
  position: sticky;
  top: 12px;
  border: 1px solid #000;
  background: #d1d5db;
}

.saft-filter-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.saft-filter-panel .form-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.saft-filter-panel label {
  margin: 0;
  font-size: 12px;
}

.saft-filter-panel .filter-field {
  width: 100%;
  box-sizing: border-box;
}

.filter-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

.filter-actions .btn {
  flex: 1;
  text-align: center;
}

.filter-count {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
}

.saft-table-wrap {
  order: 2;
  border: 1px solid #000;
  padding: 6px;
}

@media (max-width: 900px) {
  .saft-filter-layout[data-open="1"] {
    grid-template-columns: 1fr !important;
  }
  .saft-filter-panel { position: static; }
}

.saft-data-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.saft-data-header-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.period-filter {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 0 0 12px;
  margin: 0 0 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #000;
  border-radius: 0;
  overflow: visible;
}

.period-filter label { margin: 0; min-width: 0; }
.period-filter select { width: auto; min-width: 90px; }

.period-filter + .grid,
.period-filter + .kpis,
.period-filter + .card,
.period-filter + .table-wrap {
  margin-top: 0;
}

.import-filters-row {
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
  overflow: visible;
}

.import-filters-row .form-row {
  margin: 0;
  min-width: 0;
  flex: 0 1 auto;
}

.import-filters-row .form-row label {
  display: block;
  margin-bottom: 4px;
  min-width: 0;
  font-size: 12px;
}

.import-filters-row .form-row select,
.import-filters-row .form-row input {
  width: auto;
  min-width: 88px;
  max-width: 220px;
}

.import-filters-row .form-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  white-space: nowrap;
  margin: 0;
  padding: 0 0 2px;
}

@media (max-width: 900px) {
  .import-filters-row {
    flex-wrap: wrap;
  }
}

/* ========== Login ========== */
.login {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: #0b1220;
  color: #e8eef7;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  min-height: 100vh;
}

.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: clamp(28px, 6vw, 64px);
  background:
    radial-gradient(1200px 600px at 10% 0%, rgba(37, 99, 235, 0.35), transparent 55%),
    radial-gradient(900px 500px at 90% 80%, rgba(15, 118, 110, 0.28), transparent 50%),
    linear-gradient(160deg, #0b1220 0%, #132038 45%, #0f172a 100%);
}

.login-brand-glow {
  position: absolute;
  inset: auto -10% -20% 20%;
  height: 55%;
  background: radial-gradient(circle at center, rgba(56, 189, 248, 0.18), transparent 65%);
  pointer-events: none;
  animation: loginGlow 8s ease-in-out infinite alternate;
}

.login-brand-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.55), transparent 85%);
  pointer-events: none;
}

.login-brand-content {
  position: relative;
  z-index: 1;
  max-width: 520px;
}

.login-kicker {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #93c5fd;
}

.login-brand-name {
  margin: 0 0 14px;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: #f8fafc;
  animation: loginRise 0.7s ease-out both;
}

.login-brand-tagline {
  margin: 0;
  max-width: 36ch;
  font-size: 15px;
  line-height: 1.55;
  color: #cbd5e1;
  animation: loginRise 0.7s ease-out 0.12s both;
}

.login-main {
  display: grid;
  place-items: center;
  padding: clamp(24px, 4vw, 48px);
  background:
    linear-gradient(180deg, #f4f7fb 0%, #e8eef5 100%);
}

.login-panel {
  width: min(400px, 100%);
  padding: 28px 28px 24px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(8px);
  animation: loginRise 0.65s ease-out 0.08s both;
}

.login-panel-header h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  color: #0f172a;
}

.login-panel-header p {
  margin: 0 0 18px;
  color: #64748b;
  font-size: 13px;
}

.login-alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.login-alert-error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.login-alert-ok {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
}

.login-field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}

.login-field input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.login-field input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-field input[aria-invalid="true"] {
  border-color: #f87171;
  background: #fffbfb;
}

.login-submit {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  background: #1d4ed8;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .15s;
}

.login-submit:hover:not(:disabled) {
  background: #1e40af;
}

.login-submit:active:not(:disabled) {
  transform: translateY(1px);
}

.login-submit:disabled {
  opacity: 0.75;
  cursor: wait;
}

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

@keyframes loginGlow {
  from { opacity: 0.7; transform: translateY(0); }
  to { opacity: 1; transform: translateY(-12px); }
}

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

  .login-brand {
    min-height: 34vh;
    align-items: center;
    padding: 32px 24px;
  }

  .login-brand-name {
    font-size: clamp(2.2rem, 10vw, 3rem);
  }

  .login-main {
    align-items: start;
    padding: 20px 16px 40px;
  }
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  background: var(--primary);
  color: #fff;
}

@media (max-width: 1100px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis-6 { grid-template-columns: 1fr 1fr; }
  .health-grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
}

/* Mobile: follow InvoiceManagement — keep row layout, toggle menu; do NOT stack sidebar on top */
@media (max-width: 900px) {
  .app-header {
    padding: 4px 10px;
  }
  .app-header-inner {
    gap: 8px;
  }
  .app-header-inner {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .app-header-left {
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .app-header-logo {
    height: 26px;
  }
  .app-header-user {
    display: none;
  }
  .app-header-tenant {
    max-width: 48vw;
  }
  .app-header-tenant-meta {
    display: none;
  }
  .lang-form select,
  .app-header-lang-select {
    min-width: 0;
    width: auto;
  }

  .app-layout-body {
    flex-direction: row; /* keep content usable; menu via toggle */
    min-width: 0;
  }
  .sidebar {
    position: fixed;
    z-index: 50;
    top: 48px; /* below sticky header so ☰ stays usable */
    left: 0;
    bottom: 0;
    width: min(260px, 86vw);
    padding-top: 8px;
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.28);
    overflow-y: auto;
  }
  .app-layout:not(.sidebar-hidden) .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(15, 23, 42, 0.4);
    border: 0;
    padding: 0;
    cursor: pointer;
  }
  .sidebar-backdrop {
    display: none;
  }
  .app-layout.sidebar-hidden .sidebar,
  body.sidebar-collapsed .sidebar {
    display: none;
  }
  .main-content {
    width: 100%;
    min-width: 0;
    padding: 10px 10px 20px;
    overflow-x: hidden;
  }
  .page-content {
    min-width: 0;
    max-width: 100%;
  }
  .page-title {
    font-size: 1rem;
  }

  .card {
    padding: 10px;
    min-width: 0;
    overflow-x: auto;
  }
  .form-max,
  .tenant-form {
    max-width: none;
  }
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .form-actions,
  .list-actions {
    gap: 8px;
  }
  .list-actions .btn,
  .form-actions .btn {
    flex: 1 1 auto;
  }

  .period-filter,
  .import-filters-row {
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
  }
  .import-filters-row .form-row {
    flex: 1 1 140px;
  }
  .import-filters-row .form-row select,
  .import-filters-row .form-row input {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .import-filters-row .form-actions {
    flex: 1 1 100%;
    white-space: normal;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    margin-bottom: 0;
  }
  .tabs .tab,
  .tabs .tab-btn {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  .table-wrap {
    max-height: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table {
    min-width: 520px;
  }
  .table-wrap .actions {
    white-space: normal;
  }
  .table-wrap .actions .link-btn,
  .table-wrap .actions .btn {
    display: inline-block;
    margin: 2px 0;
  }

  .kpis { grid-template-columns: 1fr; }
  .kpis-6 { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }

  .ceo-header,
  .ceo-header-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .ceo-header-aside {
    margin-left: 0;
    align-self: stretch;
  }
  .ceo-health {
    width: 100%;
  }
  .ceo-zones,
  .ceo-charts,
  .ceo-parties,
  .ceo-expenses-split,
  .ceo-aging-split,
  .ceo-rev-exp-kpis,
  .ceo-rev-exp-kpis.ceo-personnel-kpis {
    grid-template-columns: 1fr;
  }
  .budget-pct-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .scenarios-config-grid {
    grid-template-columns: 1fr;
  }

  .ceo-modal-panel,
  .ceo-drawer-panel {
    width: 100% !important;
    max-width: 100%;
    margin: 0;
    border-radius: 12px 12px 0 0;
  }
  .ceo-modal {
    align-items: flex-end;
  }
  .ceo-drawer-panel.ceo-expense-drawer-panel {
    width: 100%;
  }

  .users-admin .actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ========== Upload progress overlay ========== */
body.upload-busy {
  overflow: hidden;
}

.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.upload-overlay[hidden] {
  display: none !important;
}

.upload-overlay-card {
  width: min(480px, 100%);
  background: #fff;
  border: 1px solid #000;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px 18px 16px;
  text-align: center;
}

.upload-overlay-card h3 {
  margin: 10px 0 6px;
}

.upload-hourglass {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 3px solid #cbd5e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: upload-spin 0.9s linear infinite;
}

@keyframes upload-spin {
  to { transform: rotate(360deg); }
}

.upload-progress-bar {
  margin-top: 14px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-bar span {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--primary);
  border-radius: 999px;
  animation: upload-bar 1.4s ease-in-out infinite;
}

.upload-log {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 160px;
  overflow: auto;
  text-align: left;
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
  font-size: 0.85rem;
}

.upload-log li {
  padding: 3px 0;
  color: #374151;
  word-break: break-word;
}

.upload-log li.ok {
  color: #166534;
}

.upload-log li.err {
  color: #b91c1c;
}

@keyframes upload-bar {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

html.app-loading-active #appLoadingOverlay {
  display: flex !important;
}

.app-loading-progress {
  margin-top: 14px;
  text-align: left;
}

.app-loading-progress-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.app-loading-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.app-loading-progress-label {
  display: block;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* CEO Dashboard */
.ceo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ceo-header-main {
  flex: 1 1 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.ceo-header-main .page-title {
  margin: 0;
}

.ceo-header-main .period-filter {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.ceo-header-aside {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: flex-start;
}

.ceo-header > .period-filter {
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.ceo-header-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.ceo-header-actions .period-filter {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.budget-exec-filters label {
  min-width: auto;
}

.budget-exec-filters select {
  min-width: 180px;
}

.ceo-health {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  cursor: help;
}

.ceo-health.health-ok { border-color: #86efac; background: #f0fdf4; }
.ceo-health.health-warn { border-color: #fcd34d; background: #fffbeb; }
.ceo-health.health-bad { border-color: #fca5a5; background: #fef2f2; }

.ceo-health-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.ceo-health-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.ceo-health-tooltip {
  display: none;
  position: absolute;
  z-index: 30;
  right: 0;
  top: calc(100% + 8px);
  width: min(340px, 70vw);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text, #1a1d26);
  background: #fff;
  border: 1px solid var(--border, #e2e6f0);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  white-space: pre-line;
  pointer-events: none;
}

.ceo-health:hover .ceo-health-tooltip,
.ceo-health:focus-within .ceo-health-tooltip {
  display: block;
}

.ceo-zones {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.ceo-zone-title {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ceo-rev-exp {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.ceo-rev-exp h3 {
  margin: 0 0 2px;
  font-size: 0.95rem;
}

.ceo-rev-exp-hint {
  margin: 0 0 10px;
  font-size: 0.8rem;
}

.ceo-rev-exp-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ceo-rev-exp-kpis.ceo-personnel-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
}

.ceo-rev-kpi {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--theme-indicators-card-bg, #d1d6e6);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ceo-rev-kpi-result {
  background: color-mix(in srgb, var(--theme-indicators-card-bg, #d1d6e6) 88%, black);
  border-color: #cbd5e1;
}

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

.ceo-rev-kpi-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.2;
  word-break: break-word;
}

.ceo-rev-kpi-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.ceo-rev-kpi-mom {
  font-size: 0.82rem;
  font-weight: 600;
}

.ceo-mini-table {
  width: 100%;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .ceo-rev-exp-kpis,
  .ceo-rev-exp-kpis.ceo-personnel-kpis {
    grid-template-columns: 1fr;
  }
}

.ceo-kpi-table {
  width: 100%;
  font-size: 0.88rem;
}

.ceo-kpi-table th {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.ceo-kpi-name {
  font-weight: 500;
  max-width: 160px;
}

.ceo-kpi-name[title] {
  cursor: help;
  border-bottom: 1px dotted #94a3b8;
}

.ceo-kpi-table th[title] {
  cursor: help;
  border-bottom: 1px dotted #94a3b8;
}

.ceo-kpi-clickable {
  cursor: pointer;
}

.ceo-kpi-clickable:hover td {
  background: #eff6ff;
}

.ceo-indicators-table .ceo-indicator-cat-row td {
  background: #e8eef7;
  color: #1e293b;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  border-top: 1px solid #cbd5e1;
}

.ceo-trend-up { color: #15803d; }
.ceo-trend-down { color: #dc2626; }
.ceo-trend-flat { color: var(--muted); }

.ceo-alerts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ceo-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.ceo-alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.ceo-alert-critical .ceo-alert-dot { background: #dc2626; }
.ceo-alert-warn .ceo-alert-dot { background: #f59e0b; }
.ceo-alert-ok .ceo-alert-dot { background: #16a34a; }

.ceo-alert[title] {
  cursor: help;
}

.ceo-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ceo-expenses-card {
  grid-column: 1 / -1;
}

.ceo-expenses-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
}

.ceo-expenses-chart {
  min-width: 0;
}

.ceo-expenses-table {
  min-width: 0;
}

.ceo-expense-amount {
  cursor: pointer;
  color: var(--link, #2563eb);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ceo-expense-amount:hover {
  color: var(--link-hover, #1d4ed8);
  background: color-mix(in srgb, var(--accent, #2563eb) 8%, transparent);
}

.ceo-expense-component-row {
  cursor: pointer;
}

.ceo-expense-component-row:hover {
  background: color-mix(in srgb, var(--accent, #2563eb) 10%, transparent);
}

.ceo-drawer-panel.ceo-expense-drawer-panel {
  width: min(1280px, 98vw);
  max-width: 98vw;
}

#ceoExpenseJournalWrap {
  max-height: min(70vh, 640px);
  overflow: auto;
}

#ceoExpenseJournalTable {
  font-size: 12px;
}

#ceoExpenseJournalTable td,
#ceoExpenseJournalTable th {
  white-space: nowrap;
}

#ceoExpenseJournalTable td:nth-child(5),
#ceoExpenseJournalTable td:nth-child(7) {
  white-space: normal;
  min-width: 10rem;
  max-width: 22rem;
}

#ceoExpenseJournalTable th.ceo-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

#ceoExpenseJournalTable th.ceo-sortable::after {
  content: ' ↕';
  opacity: 0.35;
  font-size: 0.85em;
}

#ceoExpenseJournalTable th.ceo-sortable.sorted-asc::after {
  content: ' ↑';
  opacity: 0.9;
}

#ceoExpenseJournalTable th.ceo-sortable.sorted-desc::after {
  content: ' ↓';
  opacity: 0.9;
}

.ceo-parties {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.ceo-aging-card {
  margin-top: 14px;
}

.ceo-aging-split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.ceo-aging-chart {
  position: relative;
  height: 180px;
  min-width: 0;
}

.ceo-aging-table {
  min-width: 0;
}

.ceo-parties-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.ceo-chart-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.ceo-personnel-chart {
  position: relative;
  height: 220px;
}

.ceo-conc-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}

.ceo-conc-pill {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fafafa;
}

.ceo-conc-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ceo-conc-pct {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
}

.ceo-conc-amt {
  font-size: 0.8rem;
  color: #4b5563;
}

.ceo-chart-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 200px;
}

.ceo-aging-msg {
  margin: auto 0;
  text-align: center;
  max-width: 28ch;
  margin-left: auto;
  margin-right: auto;
}

.ceo-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  visibility: hidden;
}

.ceo-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.ceo-modal.open,
.ceo-modal:not([hidden]) {
  display: flex;
}

.ceo-modal[hidden] {
  display: none !important;
}

.ceo-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.ceo-modal-panel {
  position: relative;
  z-index: 1;
  width: min(860px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  animation: loginRise 0.25s ease-out;
}

.ceo-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #e5e7eb;
}

.ceo-modal-header h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.ceo-modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  padding: 0 4px;
}

.ceo-modal-body {
  padding: 14px 18px 18px;
  overflow: auto;
}

.ceo-modal-loading {
  text-align: center;
  padding: 28px 12px 18px;
}

.ceo-modal-loading p {
  margin: 12px 0 16px;
  color: #475569;
  font-weight: 600;
}

body.ceo-modal-open {
  overflow: hidden;
}

.ceo-fifo-total-mismatch {
  color: #b45309;
  font-weight: 700;
}

.ceo-drawer.open {
  pointer-events: auto;
  visibility: visible;
}

.ceo-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}

.ceo-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  background: #fff;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.ceo-drawer.open .ceo-drawer-panel {
  transform: translateX(0);
}

.ceo-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid #e2e8f0;
}

.ceo-drawer-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.ceo-drawer-close {
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.ceo-drawer-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.ceo-drawer-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0 0 16px;
}

.ceo-drawer-metrics div {
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 8px;
}

.ceo-drawer-metrics dt {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
}

.ceo-drawer-metrics dd {
  margin: 4px 0 0;
  font-weight: 600;
  font-size: 1rem;
}

@media (max-width: 1100px) {
  .ceo-zones,
  .ceo-charts,
  .ceo-parties,
  .ceo-expenses-split,
  .ceo-aging-split {
    grid-template-columns: 1fr;
  }
}

.section-title {
  margin: 16px 0 10px;
  font-size: 1rem;
  font-weight: 700;
}

.cell-edit-table {
  width: 100%;
}

.cell-edit-table th,
.cell-edit-table td {
  padding: 0;
  vertical-align: middle;
}

.cell-edit-table thead th.num,
.cell-edit-table tbody td {
  width: 19ch;
  max-width: 19ch;
  min-width: 19ch;
  box-sizing: border-box;
}

.cell-edit-table tbody th.num {
  width: auto;
  min-width: 5.5rem;
  max-width: none;
  white-space: nowrap;
  padding: 8px 6px;
}

.cell-edit-table th {
  padding: 8px 6px;
}

.cell-input {
  width: 100%;
  max-width: 19ch;
  min-width: 0;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
  text-align: right;
  padding: 8px 6px;
  font: inherit;
}

.cell-input:focus {
  background: #fffbe6;
  outline: 1px solid #000;
}

.budget-ceo-table .budget-chapter-row {
  cursor: pointer;
  font-weight: 600;
  background: #f3f4f6;
}

.budget-ceo-table .budget-chapter-row:hover {
  background: #e5e7eb;
}

.budget-ceo-table .budget-child-row td:nth-child(2) {
  padding-left: 28px;
}

.budget-chevron {
  display: inline-block;
  width: 1em;
  margin-right: 6px;
  font-size: 11px;
  transition: transform .15s ease;
}

.budget-chapter-row.open .budget-chevron {
  transform: rotate(90deg);
}

.budget-ceo-table code {
  font-size: 12px;
  font-weight: 500;
}

/* Coloane numerice buget — mască max 999 999 999 999.99 (19 caractere) */
.budget-ceo-table td.num,
.budget-ceo-table th.num {
  width: 19ch;
  max-width: 19ch;
  min-width: 19ch;
  padding-left: 4px;
  padding-right: 6px;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.budget-ceo-table td.num-pct,
.budget-ceo-table th.num-pct {
  width: 10ch;
  max-width: 10ch;
  min-width: 10ch;
}

.budget-exec-wrap {
  overflow: auto;
}

.budget-exec-table {
  font-size: 12px;
}

.budget-exec-table thead th {
  position: sticky;
  background: var(--theme-table-header-bg, #9ca3af);
  background-clip: padding-box;
  box-shadow: inset 0 -1px 0 #d1d5db;
}

.budget-exec-table thead tr:first-child th {
  top: 0;
  z-index: 5;
}

.budget-exec-table thead tr:first-child th[rowspan] {
  z-index: 6;
}

.budget-exec-table thead tr.budget-exec-subhead th {
  top: var(--budget-exec-head-h, 30px);
  z-index: 4;
}

.budget-exec-table thead tr:first-child th[colspan] {
  text-align: center;
  border-left: 1px solid #d1d5db;
}

.budget-exec-table th,
.budget-exec-table td {
  white-space: nowrap;
}

.budget-exec-table .budget-signal {
  text-align: center;
  width: 22px;
  padding-left: 4px;
  padding-right: 8px;
  border-left: none;
}

.semafor {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
}

.semafor-ok {
  background: #16a34a;
}

.semafor-bad {
  background: #dc2626;
}

.semafor-none {
  background: #d1d5db;
}

@media (max-width: 900px) {
  .budget-pct-grid {
    grid-template-columns: repeat(3, minmax(90px, 1fr));
  }
}

/* ===== FOOTER (marketing login page) ===== */

.main-footer {
  margin-top: 20px;
  background: var(--theme-header-bg, #1e293b);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 16px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
}

.footer-grid h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #e2e8f0;
}

.footer-grid ul {
  margin: 0;
  padding-left: 16px;
}

.footer-grid li {
  margin: 0 0 4px;
}

.footer-grid a {
  color: #cbd5e1;
  text-decoration: none;
}

.footer-grid a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.footer-grid p {
  margin: 0 0 6px;
  color: #cbd5e1;
  font-size: 13px;
}

.footer-bottom {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.15);
  color: #94a3b8;
  text-align: center;
}

.footer-bottom p {
  margin: 0 0 4px;
  font-size: 12px;
}

.footer-social-link {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.2);
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}

.footer-social-link:hover {
  color: #fff;
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.35);
}

.footer-social-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.footer-contact-social {
  margin-top: 8px;
}

.login-page-footer {
  grid-column: 1 / -1;
  margin-top: 0;
}

.login-footer-legal {
  text-align: center;
}

.main-footer--login {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: var(--shadow-md);
}

.login-page-footer.main-footer--login {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
  border-color: #1e40af;
}

.login-page-footer.main-footer--login .footer-grid h4 {
  color: #e0f2fe;
}

.login-page-footer.main-footer--login .footer-grid a {
  color: #bfdbfe;
}

.login-page-footer.main-footer--login .footer-grid a:hover {
  color: #ffffff;
}

.login-page-footer.main-footer--login .footer-grid p {
  color: #bfdbfe;
}

.login-page-footer.main-footer--login .footer-bottom {
  border-top-color: rgba(255,255,255,.2);
  color: #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.login-page-footer.main-footer--login .footer-social-link {
  color: #bfdbfe;
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.3);
}

.login-page-footer.main-footer--login .footer-social-link:hover {
  color: #ffffff;
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.5);
}

@media (max-width: 960px) {
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .login-page-footer.main-footer--login .footer-bottom {
    flex-direction: column;
    gap: 8px;
  }
}

/* ===== MARKETING LOGIN PAGE (MGSmart.ro) ===== */

.login-page-marketing {
  align-items: flex-start;
  justify-content: center;
  padding: 20px 24px 40px;
  --login-header-blue-dark: #3b82f6;
  --login-header-blue-dark-hover: #2563eb;
  background: #f8fafc;
  min-height: 100vh;
}

.login-page-marketing .btn-primary {
  background: var(--login-header-blue-dark);
  border: 1px solid var(--login-header-blue-dark);
  color: #ffffff;
}
.login-page-marketing .btn-primary:hover,
.login-page-marketing .btn-primary:focus {
  background: var(--login-header-blue-dark-hover);
  border-color: var(--login-header-blue-dark-hover);
}

.login-layout {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
  position: relative;
}

.login-page-header {
  grid-column: 1 / -1;
  padding: 24px 28px 20px;
  border-radius: 12px;
  display: block;
  position: relative;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
  border: 1px solid #1e40af;
  box-shadow: 0 4px 24px rgba(37,99,235,0.18);
}

.login-header-marketing h1 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.05;
  color: #ffffff;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.login-header-marketing p {
  margin: 0 0 12px;
  color: #bfdbfe;
  max-width: 760px;
  font-size: 15px;
  line-height: 1.5;
}

.marketing-cta-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  margin-bottom: 0;
}

.login-page-header .marketing-cta-row .btn-primary {
  background: #ffffff;
  border: 1px solid #ffffff;
  color: #1e3a8a;
  font-weight: 700;
}
.login-page-header .marketing-cta-row .btn-primary:hover,
.login-page-header .marketing-cta-row .btn-primary:focus {
  background: #eff6ff;
}

.btn-secondary-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.6);
  color: #fff;
}
.btn-secondary-ghost:hover {
  background: rgba(255,255,255,0.12);
}

.marketing-top-strip {
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(0,0,0,0.25);
  color: #e0f2fe;
  font-size: 12px;
  line-height: 1.4;
  display: block;
}
.marketing-top-strip strong {
  display: block;
  margin: 0 0 3px;
  color: #ffffff;
  font-size: 12px;
}
.marketing-top-strip span { display: block; }

.marketing-content {
  display: grid;
  gap: 12px;
}
.marketing-content .card {
  padding: 18px 20px;
  margin-bottom: 0;
}
.marketing-content .card > h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
}

.marketing-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.marketing-grid-3 article:not(.marketing-info-card),
.marketing-grid-3 blockquote {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.marketing-grid-3 article.marketing-info-card {
  margin: 0;
  border-radius: 8px;
}
.marketing-grid-3 h3 { margin: 0 0 6px; font-size: 14px; }
.marketing-grid-3 p { margin: 0; color: var(--muted); font-size: 13px; }
.marketing-grid-3 blockquote { font-size: 13px; font-style: italic; color: #374151; }
.marketing-grid-3 blockquote cite { display: block; margin-top: 8px; font-style: normal; font-weight: 600; color: #6b7280; font-size: 12px; }

.login-page-marketing .marketing-features .marketing-grid-3 > article.marketing-info-card {
  padding: 18px 16px !important;
  border: 1px solid #bfdbfe !important;
  border-radius: 8px !important;
  background: #dbeafe !important;
}
.login-page-marketing .marketing-steps .marketing-grid-3 > article.marketing-info-card {
  padding: 18px 16px !important;
  border: 1px solid #fde047 !important;
  border-radius: 8px !important;
  background: #fef9c3 !important;
}
.login-page-marketing .marketing-info-card h3,
.login-page-marketing .marketing-info-card p { color: #111 !important; }

/* Pricing cards — same layout language as InvoiceManagement */
.marketing-pricing .marketing-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.marketing-pricing .marketing-grid-3 article {
  display: flex;
  flex-direction: column;
  border: 1px solid #d0d0d0;
  border-radius: 0;
  padding: 20px;
  background: #fff;
}
.marketing-pricing .marketing-grid-3 article > h3,
.marketing-pricing .marketing-grid-3 article > .price,
.marketing-pricing .marketing-grid-3 article > p {
  display: block;
  width: 100%;
}
.marketing-pricing .marketing-grid-3 article > h3 {
  margin: 0 0 6px;
}
.marketing-pricing .marketing-grid-3 article:nth-child(1) {
  background: #f7f7f7;
}
.marketing-pricing .marketing-grid-3 article:nth-child(2) {
  background: #efefef;
}
.marketing-pricing .marketing-grid-3 article:nth-child(3) {
  background: #e5e5e5;
}
.marketing-pricing .price {
  font-size: 20px !important;
  font-weight: 700;
  color: var(--text) !important;
  margin-bottom: 8px !important;
}
.marketing-pricing .marketing-grid-3 article > p:last-of-type {
  flex: 1;
}
.pricing-choose-btn {
  margin-top: 16px;
  align-self: stretch;
  text-align: center;
}

.marketing-final-cta { text-align: center; }
.marketing-final-cta h2 { margin: 0 0 6px; }
.marketing-final-cta p { margin: 0 0 14px; color: var(--muted); }

.marketing-screenshot-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.marketing-screenshot-img {
  display: block;
  width: 100%;
  height: auto;
}

/* Mock screenshot widget */
.ms-screenshot-mock { background: #f8fafc; }
.ms-mock-bar {
  height: 32px;
  background: #e5e7eb;
  border-bottom: 1px solid #d1d5db;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 5px;
}
.ms-mock-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ms-mock-body { display: flex; min-height: 200px; }
.ms-mock-sidebar {
  width: 140px;
  flex-shrink: 0;
  background: #f3f4f6;
  border-right: 1px solid #e5e7eb;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ms-mock-nav-item {
  height: 28px;
  border-radius: 5px;
  background: #e5e7eb;
}
.ms-mock-main {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ms-mock-kpi-row { display: flex; gap: 10px; }
.ms-mock-kpi {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-mock-kpi-label { font-size: 11px; color: #6b7280; }
.ms-mock-kpi-val { font-size: 16px; font-weight: 700; color: #111827; }
.ms-mock-chart { flex: 1; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; padding: 12px; }
.ms-mock-bar-chart { display: flex; gap: 6px; align-items: flex-end; height: 80px; }
.ms-mock-bar-col { flex: 1; border-radius: 3px 3px 0 0; min-width: 0; }
.ms-mock-table-row { height: 10px; background: #e5e7eb; border-radius: 4px; width: 100%; }

/* Login panel (sticky right) — aligned with InvoiceManagement */
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface, #ffffff);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border, #e2e6f0);
  padding: 32px;
}

.login-title {
  margin: 0 0 24px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text, #1a1d29);
  text-align: center;
  letter-spacing: -0.02em;
}

.login-msg {
  margin-bottom: 16px;
  padding: 10px 12px;
  font-size: 12px;
  border-radius: 6px;
}
.login-msg-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.login-msg-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.login-form .form-row { margin-bottom: 16px; }
.login-form .form-row:last-of-type { margin-bottom: 20px; }
.login-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text, #1a1d29);
}
.login-form input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #000000;
  border-radius: 6px;
  box-sizing: border-box;
  background: #fff;
  color: var(--text, #1a1d29);
}
.login-form input:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 1px #000000;
}
.login-card .btn-block {
  margin-top: 0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
}

.login-create-tenant {
  margin: 20px 0 0;
  text-align: center;
  font-size: 13px;
}
.login-create-tenant a {
  color: var(--primary, #2563eb);
  text-decoration: none;
  font-weight: 600;
}
.login-create-tenant a:hover {
  text-decoration: underline;
}

.login-panel-top-right {
  position: sticky;
  top: 12px;
}
.login-panel-top-right .login-card {
  max-width: 380px;
  border: 1px solid #000000;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  border: 1px solid #e5e7eb;
  padding: 20px;
  min-width: 320px;
  max-width: 100%;
  max-height: min(92vh, 900px);
  overflow: auto;
}

.modal-box h3 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
}

.modal-box .form-row {
  margin-bottom: 12px;
}

.modal-box .form-row label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.modal-box .form-row input,
.modal-box .form-row textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #111827;
  border-radius: 6px;
  box-sizing: border-box;
  font: inherit;
}

.modal-box .form-row textarea {
  min-height: 220px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.btn-secondary {
  background: #f3f4f6;
  color: #111827;
  border: 1px solid #d1d5db;
}

.login-page-footer {
  grid-column: 1 / -1;
  margin-top: 8px;
}

/* Responsive marketing (InvoiceManagement breakpoints) */
@media (max-width: 960px) {
  .login-layout {
    grid-template-columns: 1fr;
  }
  .login-panel-top-right {
    position: static;
  }
  .login-panel-top-right .login-card {
    max-width: 100%;
    width: 100%;
  }
  .marketing-content,
  .marketing-content .card {
    min-width: 0;
    max-width: 100%;
  }
  .marketing-grid-3 {
    grid-template-columns: 1fr;
  }
  .marketing-pricing .marketing-grid-3 {
    grid-template-columns: 1fr;
  }
}
@media (min-width: 961px) and (max-width: 1100px) {
  .marketing-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .marketing-pricing .marketing-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ===== SCENARII BUGETARE ===== */
.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 8px;
}

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

.scenario-card {
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scenario-card-pesimist { border-color: #f87171; background: #fff5f5; }
.scenario-card-realist  { border-color: #60a5fa; background: #f0f7ff; }
.scenario-card-optimist { border-color: #34d399; background: #f0fdf8; }

.scenario-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scenario-label {
  font-weight: 700;
  font-size: 1rem;
}

.scenario-card-pesimist .scenario-label { color: #dc2626; }
.scenario-card-realist  .scenario-label { color: #2563eb; }
.scenario-card-optimist .scenario-label { color: #059669; }

.scenario-desc {
  font-size: 12px;
  color: #6b7280;
}

.scenario-kpis {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-kpi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,.04);
}

.scenario-kpi-profit {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.scenario-kpi-label {
  font-size: 12px;
  color: #6b7280;
}

.scenario-kpi-value {
  font-weight: 700;
  font-size: 0.95rem;
}

.scenario-kpi-diff {
  font-size: 11px;
  color: #6b7280;
}

.profit-pos { color: #059669; }
.profit-neg { color: #dc2626; }

.scenario-details summary {
  cursor: pointer;
  font-size: 12px;
  color: #2563eb;
  padding: 4px 0;
}

/* ===== ALERTE BUGETARE ===== */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.budget-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  border-left: 4px solid transparent;
  font-size: 13px;
}

.budget-alert-warning {
  background: #fffbeb;
  border-left-color: #f59e0b;
  color: #78350f;
}

.budget-alert-danger {
  background: #fff1f2;
  border-left-color: #ef4444;
  color: #7f1d1d;
}

.budget-alert-icon {
  font-size: 1rem;
  line-height: 1.4;
  flex-shrink: 0;
}

.budget-alert-msg {
  line-height: 1.5;
}

.alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  margin-left: 5px;
  vertical-align: middle;
}

.alert-empty {
  text-align: center;
  padding: 32px 16px;
  color: #059669;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ===== CONFIGURARE SCENARII (tenant-settings) ===== */
.scenarios-config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 10px;
}

@media (max-width: 900px) {
  .scenarios-config-grid { grid-template-columns: 1fr; }
}

.scenario-config-card {
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  padding: 14px;
}

.scenario-config-pesimist { border-color: #f87171; background: #fff5f5; }
.scenario-config-realist  { border-color: #60a5fa; background: #f0f7ff; }
.scenario-config-optimist { border-color: #34d399; background: #f0fdf8; }

.scenario-config-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.scenario-config-pesimist .scenario-config-title { color: #dc2626; }
.scenario-config-realist  .scenario-config-title { color: #2563eb; }
.scenario-config-optimist .scenario-config-title { color: #059669; }



/* ===== SCENARII - LISTA & CONSTRUCTOR ===== */
.scenarios-list { display: flex; flex-direction: column; gap: 12px; }

.scenario-list-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface);
}

.scenario-list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.scenario-list-name { font-size: 1rem; display: block; }
.scenario-list-budget { font-size: 12px; color: #6b7280; display: block; margin-top: 2px; }
.scenario-list-desc { margin: 6px 0 0; font-size: 13px; color: #6b7280; }
.scenario-list-meta { margin-top: 8px; font-size: 12px; color: #9ca3af; }

.scenario-list-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.btn-danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

/* Constructor reguli */
.rule-builder { display: flex; flex-direction: column; gap: 12px; }

.rule-builder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.rule-builder-row .form-row {
  flex: 1 1 150px;
  min-width: 130px;
  margin: 0;
}

.rule-preview-box {
  background: #f0f7ff;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #1e3a8a;
}

.quick-rules-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

/* Comparare scenariu */
.scenario-compare-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.scenario-compare-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scenario-compare-total {
  font-size: 1.3rem;
}

/* ===== SCENARIO COMPARE ===== */
.scenario-affected-row {
  background: #fffbeb;
}

.scenario-affected-row:hover {
  background: #fef3c7;
}

.scenario-cell-affected {
  background: #fef9c3;
  font-weight: 600;
}

.scenario-rules-cell {
  font-size: 11px;
  max-width: 220px;
}

.scenario-rule-tag {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 4px;
  padding: 1px 6px;
  margin: 1px 2px;
  font-size: 11px;
  white-space: nowrap;
}

.semafor-legend {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 3px;
  vertical-align: middle;
}

.semafor-legend-affected { background: #fef08a; border: 1px solid #ca8a04; }
.semafor-legend-chapter  { background: var(--surface); border: 1px solid var(--border); }

/* Paginare (jos, centru) */
.pagination-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 8px;
  width: 100%;
}

.pagination-info {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.pagination-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 6px;
  background: #fff;
  color: var(--text, #1e293b);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  line-height: 1;
}

a.pagination-btn:hover {
  border-color: var(--primary, #212545);
  color: var(--primary, #212545);
  background: #f8fafc;
}

.pagination-btn.is-current {
  background: var(--primary, #212545);
  border-color: var(--primary, #212545);
  color: #fff;
  font-weight: 600;
}

.pagination-btn.is-disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  color: var(--text-muted, #64748b);
  font-size: 13px;
  user-select: none;
}

/* Previzualizare indicatori pe categorii */
.indicator-preview-simple {
  max-width: 640px;
}

.indicator-preview-block {
  margin-bottom: 18px;
}

.indicator-preview-block:last-child {
  margin-bottom: 0;
}

.indicator-preview-cat {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

.indicator-preview-names {
  margin: 0;
  padding-left: 22px;
  list-style: disc;
}

.indicator-preview-names li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 2px 0;
  padding-right: 4px;
  line-height: 1.4;
}

.indicator-preview-amount {
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mail-body-preview {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  max-width: 720px;
  overflow-x: auto;
}
