/* KARBON-BOX — Banque standalone */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: Inter, system-ui, sans-serif; background: #f3f4f6; color: #111827; min-height: 100vh; }

.kb-header {
  background: linear-gradient(135deg, #0e7490, #06b6d4);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky; top: 0; z-index: 10;
}
.kb-header-inner {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px; max-width: 1600px; margin: 0 auto;
}
.kb-header h1 {
  display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700;
}
.kb-header h1 small { font-size: 11px; font-weight: 400; opacity: 0.7; margin-left: 4px; }
.kb-tabs { display: flex; gap: 4px; flex: 1; }
.kb-tab {
  padding: 7px 14px; border: none; background: rgba(255,255,255,0.1); color: white;
  font-size: 13px; font-weight: 500; border-radius: 6px; cursor: pointer; transition: all .15s;
}
.kb-tab:hover { background: rgba(255,255,255,0.2); }
.kb-tab.active { background: white; color: #0e7490; font-weight: 600; }
.kb-user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.kb-user a { color: white; opacity: 0.85; }
.kb-user a:hover { opacity: 1; }

#kb-main {
  max-width: 1600px; margin: 16px auto; padding: 0 16px 40px;
}

.kb-loading { text-align: center; padding: 60px 20px; color: #6b7280; font-size: 14px; }

/* === Vue mensuelle === */
.kb-mv-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; background: white; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 12px; flex-wrap: wrap;
}
.kb-mv-year { display: flex; align-items: center; gap: 6px; }
.kb-mv-year button {
  padding: 5px 11px; border: 1px solid #d1d5db; background: white; border-radius: 6px;
  cursor: pointer; font-size: 14px; font-weight: 600;
}
.kb-mv-year button:hover { background: #f3f4f6; }
.kb-mv-year .y-label { min-width: 60px; text-align: center; font-size: 16px; font-weight: 700; }

.kb-mv-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.kb-mv-count {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: white; border: 2px solid transparent;
  transition: transform .15s, border-color .15s;
}
.kb-mv-count.green  { background: #16a34a; }
.kb-mv-count.orange { background: #f59e0b; }
.kb-mv-count.blue   { background: #3b82f6; }
.kb-mv-count.red    { background: #dc2626; }
.kb-mv-count:hover { transform: scale(1.05); }
.kb-mv-count.active { border-color: #1e293b; box-shadow: 0 0 0 2px white inset; }

.kb-mv-relances {
  padding: 6px 14px; background: #7c3aed; color: white; border: none; border-radius: 6px;
  cursor: pointer; font-size: 12px; font-weight: 600; margin-left: 8px;
}
.kb-mv-relances:hover { background: #6d28d9; }

.kb-mv-table-wrap {
  background: white; border-radius: 10px; overflow: auto; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  max-height: calc(100vh - 200px);
}
.kb-mv-table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px;
}
.kb-mv-table thead th {
  position: sticky; top: 0; background: #f9fafb; z-index: 2;
  padding: 9px 6px; text-align: center; font-weight: 600; color: #6b7280;
  border-bottom: 2px solid #e5e7eb; min-width: 50px;
}
.kb-mv-table thead th:first-child {
  text-align: left; padding: 9px 12px; min-width: 280px;
  position: sticky; left: 0; z-index: 3; background: #f9fafb;
}
.kb-mv-table tbody tr:nth-child(even) { background: #fafafa; }
.kb-mv-table td {
  padding: 6px 6px; border-bottom: 1px solid #f3f4f6; vertical-align: middle;
}
.kb-mv-table td:first-child {
  position: sticky; left: 0; background: white; z-index: 1;
  padding: 6px 12px;
}
.kb-mv-table tbody tr:nth-child(even) td:first-child { background: #fafafa; }
.kb-mv-table .row-label { font-weight: 600; color: #111; line-height: 1.2; }
.kb-mv-table .row-meta { font-size: 10px; color: #6b7280; font-family: ui-monospace, monospace; }

.kb-mv-cell {
  padding: 0; border-left: 1px solid #f3f4f6; height: 32px; min-width: 50px;
  text-align: center; cursor: context-menu;
}
.kb-mv-cell.s-green  { background: #16a34a; color: white; font-weight: 600; font-size: 10px; }
.kb-mv-cell.s-orange { background: #f59e0b; color: white; font-weight: 600; font-size: 10px; }
.kb-mv-cell.s-blue   { background: #3b82f6; color: white; font-weight: 600; font-size: 10px; }
.kb-mv-cell.s-red    { background: #dc2626; color: white; font-weight: 600; font-size: 10px; }
.kb-mv-cell sup { font-size: 9px; opacity: 0.85; }

/* === Menu contextuel === */
.kb-cell-menu {
  position: fixed; background: white; border: 1px solid #d1d5db; border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2); z-index: 9999;
  padding: 4px 0; min-width: 240px; font-size: 13px;
}
.kb-cell-menu .header {
  padding: 8px 12px; font-size: 11px; color: #6b7280; border-bottom: 1px solid #f3f4f6;
}
.kb-cell-menu .header strong { color: #111; }
.kb-cell-menu button {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border: none; background: transparent; cursor: pointer; font-size: 13px;
}
.kb-cell-menu button:hover { background: #f3f4f6; }
.kb-cell-menu .swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  margin-right: 8px; vertical-align: middle;
}
.kb-cell-menu .reset { font-size: 12px; color: #6b7280; border-top: 1px solid #f3f4f6; }
.kb-cell-menu .hist { border-top: 1px solid #f3f4f6; padding: 6px 12px; font-size: 11px; color: #6b7280; max-height: 130px; overflow-y: auto; }
.kb-cell-menu .hist-row { margin-top: 3px; }

/* === Onglets OFX / Historique === */
.kb-ofx-list, .kb-log-list {
  background: white; border-radius: 10px; padding: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.kb-ofx-list table, .kb-log-list table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.kb-ofx-list th, .kb-log-list th {
  text-align: left; padding: 8px; background: #f9fafb; border-bottom: 2px solid #e5e7eb;
  font-weight: 600; color: #374151;
}
.kb-ofx-list td, .kb-log-list td {
  padding: 6px 8px; border-bottom: 1px solid #f3f4f6;
}
.kb-toolbar-search {
  display: flex; gap: 8px; align-items: center; margin-bottom: 12px;
}
.kb-toolbar-search input, .kb-toolbar-search select {
  padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 12px;
}
.kb-badge {
  display: inline-block; padding: 1px 6px; border-radius: 10px; font-size: 10px;
  font-weight: 600; vertical-align: middle;
}
.kb-badge-green  { background: #d1fae5; color: #065f46; }
.kb-badge-orange { background: #fef3c7; color: #92400e; }
.kb-badge-blue   { background: #dbeafe; color: #1e40af; }
.kb-badge-red    { background: #fee2e2; color: #991b1b; }
.kb-badge-gray   { background: #f3f4f6; color: #4b5563; }

/* === Toast === */
#kb-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
}
.kb-toast {
  background: #1e293b; color: white; padding: 10px 16px; border-radius: 8px;
  margin-top: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  font-size: 13px; max-width: 380px; animation: kb-toast-in .25s ease;
}
.kb-toast.ok { background: #059669; }
.kb-toast.err { background: #dc2626; }
@keyframes kb-toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
