/* =========================================================
   Integrare Cont MAIB — Prototip
   Paletă: instanță de referință dataviz (categorial/divergent/status)
   ========================================================= */

:root {
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  --series-in:      #2a78d6; /* încasări — blue */
  --series-out:     #e34948; /* plăți — red */

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);

    --series-in:      #3987e5;
    --series-out:     #e66767;

    --status-good:     #0ca30c;
    --status-warning:  #fab219;
    --status-serious:  #ec835a;
    --status-critical: #d03b3b;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
}

.mono { font-variant-numeric: tabular-nums; font-family: "SF Mono", Consolas, monospace; }

/* ---------- Banner ---------- */
.demo-banner {
  background: color-mix(in srgb, var(--status-warning) 18%, var(--surface-1));
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 20px;
  text-align: center;
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--series-in);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.brand-sub { font-size: 12.5px; color: var(--text-secondary); }

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-warning { background: var(--status-warning); }
.dot-good { background: var(--status-good); }
.dot-critical { background: var(--status-critical); }

/* ---------- Main layout ---------- */
.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

h2 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}

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

/* ---------- Account summary cards ---------- */
.account-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-balance { background: color-mix(in srgb, var(--series-in) 8%, var(--surface-1)); }

.card-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.card-value--small { font-size: 15px; font-weight: 500; }

.card-sub { font-size: 12.5px; color: var(--text-secondary); }

/* ---------- Chart ---------- */
.legend {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-item { display: flex; align-items: center; gap: 6px; }

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.swatch-in { background: var(--series-in); }
.swatch-out { background: var(--series-out); }

.chart-wrap {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 20px 12px;
}

.chart {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: 220px;
  gap: 4px;
}

.chart-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 90px;
  height: 100%;
}

.chart-half {
  display: flex;
  height: 50%;
  gap: 3px;
  justify-content: center;
}

.chart-half--top { align-items: flex-end; }
.chart-half--bottom { align-items: flex-start; }

.bar {
  width: 14px;
  min-height: 2px;
  cursor: pointer;
  transition: opacity 0.12s ease;
}

.bar:hover, .bar:focus-visible { opacity: 0.8; outline: none; }

.bar-in {
  background: var(--series-in);
  border-radius: 4px 4px 0 0;
}

.bar-out {
  background: var(--series-out);
  border-radius: 0 0 4px 4px;
}

.chart-baseline {
  height: 1px;
  background: var(--baseline);
  margin: 0;
}

.chart-month-label {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.tooltip {
  position: fixed;
  background: var(--text-primary);
  color: var(--page-plane);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: 50;
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-group {
  display: flex;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.chip {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}

.chip:hover { background: var(--gridline); }

.chip.is-active {
  background: var(--series-in);
  color: #fff;
}

.search-input {
  flex: 1;
  min-width: 200px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
}

.search-input:focus { outline: 2px solid var(--series-in); outline-offset: 1px; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 720px;
}

.tx-table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gridline);
  position: sticky;
  top: 0;
  background: var(--surface-1);
  white-space: nowrap;
  vertical-align: middle;
}

.tx-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gridline);
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}

.tx-table td.wrap { white-space: normal; max-width: 340px; line-height: 1.4; }

.tx-table tbody tr:last-child td { border-bottom: none; }
.tx-table tbody tr:hover { background: color-mix(in srgb, var(--series-in) 5%, transparent); }

.num { text-align: right; font-variant-numeric: tabular-nums; }

.amount-in { color: var(--status-good); font-weight: 600; }
.amount-out { color: var(--text-primary); font-weight: 600; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.status-badge .dot { width: 6px; height: 6px; }
.status-completed { color: var(--text-secondary); }
.status-pending { color: var(--text-primary); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  margin: 0;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid var(--border);
}

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

.btn-secondary:hover { background: var(--gridline); }

.btn-text {
  background: transparent;
  border: none;
  color: var(--series-in);
  padding: 4px 0;
}

/* ---------- Integration note ---------- */
.integration-note {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.integration-note h2 { margin-bottom: 10px; }

.integration-note ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .account-summary { grid-template-columns: repeat(2, 1fr); }
  .app-header { padding: 14px 16px; }
  .chart-group { max-width: 44px; }
}
