/* ============================================================
   smart_accounting.css — Smart Accounting Page
   ============================================================ */

.sa-outer {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ---- Header ---- */

.sa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}

.sa-titel {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.sa-untertitel {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Ampel ---- */

.sa-ampel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid;
}

.sa-ampel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sa-ampel-gruen   { background: #ecfdf5; color: #166534; border-color: #86efac; }
.sa-ampel-gruen   .sa-ampel-dot { background: #16a34a; box-shadow: 0 0 6px rgba(22, 163, 74, .5); }
.sa-ampel-gelb    { background: #fefce8; color: #854d0e; border-color: #fde047; }
.sa-ampel-gelb    .sa-ampel-dot { background: #eab308; box-shadow: 0 0 6px rgba(234, 179, 8, .5); }
.sa-ampel-rot     { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.sa-ampel-rot     .sa-ampel-dot { background: #dc2626; box-shadow: 0 0 6px rgba(220, 38, 38, .5); animation: sa-pulse 1.5s ease-in-out infinite; }
.sa-ampel-neutral { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.sa-ampel-neutral .sa-ampel-dot { background: #94a3b8; }

@keyframes sa-pulse { 50% { opacity: .55; } }

/* ---- KPI-Karten ---- */

.sa-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

@media (max-width: 1100px) { .sa-kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .sa-kpi-row { grid-template-columns: 1fr; } }

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

.sa-kpi-erloese { border-left: 3px solid #16a34a; }
.sa-kpi-kosten  { border-left: 3px solid #dc2626; }
.sa-kpi-db.sa-pos { border-left: 3px solid #2563eb; }
.sa-kpi-db.sa-neg { border-left: 3px solid #ea580c; }

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

.sa-kpi-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-family: var(--font-display);
}

.sa-kpi-erloese .sa-kpi-val { color: #166534; }
.sa-kpi-kosten  .sa-kpi-val { color: #991b1b; }
.sa-kpi-db.sa-pos .sa-kpi-val { color: #1e40af; }
.sa-kpi-db.sa-neg .sa-kpi-val { color: #c2410c; }

.sa-kpi-sub {
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ---- Überfällig-Banner ---- */

.sa-mahn-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  border: 1px solid;
}

.sa-mahn-banner > div:not(.sa-mahn-info):not(.sa-mahn-icon) { flex: 1; }
.sa-mahn-info { flex: 1; }

.sa-mahn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.sa-mahn-banner strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-display);
  margin-bottom: 2px;
}

.sa-mahn-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.sa-mahn-warn {
  background: linear-gradient(135deg, #fef2f2, #fff7ed);
  border-color: #fecaca;
}
.sa-mahn-warn strong       { color: #991b1b; }
.sa-mahn-warn .sa-mahn-icon { background: #dc2626; color: #fff; box-shadow: 0 0 0 4px rgba(220, 38, 38, .15); animation: sa-pulse 1.5s infinite; }

.sa-mahn-ok {
  background: #ecfdf5;
  border-color: #86efac;
}
.sa-mahn-ok strong          { color: #166534; }
.sa-mahn-ok .sa-mahn-icon   { background: #16a34a; color: #fff; }
.sa-mahn-ok .sa-mahn-sub    { color: #166534; opacity: .8; }

.sa-mahn-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
  white-space: nowrap;
}

.sa-mahn-btn:hover {
  box-shadow: 0 4px 12px rgba(220, 38, 38, .4);
  transform: translateY(-1px);
}

/* ---- Grid für Charts + Karten ---- */

.sa-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

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

.sa-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

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

.sa-card-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.sa-legende {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.sa-legende span { display: inline-flex; align-items: center; gap: 5px; }

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

.sa-leg-erloese { background: #16a34a; }
.sa-leg-kosten  { background: #dc2626; }

/* ---- Chart ---- */

.sa-chart-card {
  display: flex;
  flex-direction: column;
}

.sa-chart {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  height: 220px;
  padding: 10px 0;
  align-items: end;
}

.sa-chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  cursor: default;
}

.sa-chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 100%;
  width: 100%;
}

.sa-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-height: 1px;
  transition: opacity .15s, transform .15s;
}

.sa-bar:hover {
  opacity: .85;
  transform: scaleY(1.02);
  transform-origin: bottom;
}

.sa-bar-erloese { background: linear-gradient(to top, #15803d, #22c55e); }
.sa-bar-kosten  { background: linear-gradient(to top, #b91c1c, #ef4444); }

.sa-chart-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  white-space: nowrap;
}

/* ---- Liquiditäts-Vorschau ---- */

.sa-flow {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sa-flow-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text);
}

.sa-flow-row strong { font-family: var(--font-display); font-weight: 700; }

.sa-flow-saldo {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
}

.sa-pos { color: #16a34a; }
.sa-neg { color: #dc2626; }

.sa-card-foot {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Listen (Mahn / Skonto) ---- */

.sa-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sa-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12.5px;
}

.sa-list-row strong { font-weight: 700; }

.sa-list-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.sa-empty {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- Leerstand ---- */

.sa-leer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
}

.sa-leer h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.sa-leer p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
}

/* ==========================================================
   ENTERPRISE / KI-VOLLAUTOMATIK
   ========================================================== */

.sa-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sa-ki-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #fcd34d 0%, #f59e0b 60%, #d97706 100%);
  color: #422006;
  box-shadow: 0 0 0 2px rgba(252, 211, 77, .2), 0 1px 4px rgba(217, 119, 6, .35);
  vertical-align: middle;
}

.sa-ki-pill-inline {
  margin-left: 6px;
}

.sa-ki-pulse {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  margin-right: 6px;
  vertical-align: middle;
  animation: sa-ki-pulse 1.6s ease-in-out infinite;
}

@keyframes sa-ki-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .55); transform: scale(1); }
  50%      { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);   transform: scale(1.15); }
}

.sa-btn-ocr {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid #f59e0b;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #78350f;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.sa-btn-ocr:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, .35);
}

/* Predictive Cashflow Card */
.sa-predictive-card {
  background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%);
  border: 1px solid rgba(245, 158, 11, .35);
  border-radius: var(--radius, 10px);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, .08), 0 6px 20px rgba(15, 23, 42, .04);
}

.sa-predictive-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 14px 0 18px;
}

.sa-pred-kpi {
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(245, 158, 11, .15);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sa-pred-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.sa-pred-kpi strong {
  font-size: 20px;
  font-weight: 700;
}

.sa-pred-kpi-sub {
  font-size: 11px;
  color: #6b7280;
}

.sa-predictive-canvas-wrap {
  position: relative;
  width: 100%;
  height: 220px;
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, .06);
}
.sa-predictive-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.sa-leg-pred-in    { background: rgba(37, 99, 235, .35); border: 1px solid rgba(37, 99, 235, .8); }
.sa-leg-pred-out   { background: rgba(220, 38, 38, .9); }
.sa-leg-pred-saldo { background: repeating-linear-gradient(90deg, #0f172a 0 5px, transparent 5px 9px); }

/* OCR Modal */
.sa-ocr-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  animation: sa-ocr-fade .2s ease-out;
}
@keyframes sa-ocr-fade { from { opacity: 0; } to { opacity: 1; } }

.sa-ocr-modal {
  background: #ffffff;
  border-radius: 12px;
  width: min(720px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  border: 1px solid rgba(245, 158, 11, .35);
}

.sa-ocr-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 22px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-bottom: 1px solid rgba(245, 158, 11, .25);
}
.sa-ocr-header h3 { margin: 0 0 4px; font-size: 16px; color: #78350f; }
.sa-ocr-sub { margin: 0; font-size: 12px; color: #92400e; }

.sa-ocr-close {
  background: none; border: none; cursor: pointer;
  font-size: 26px; line-height: 1; color: #78350f;
  padding: 0 4px;
}

.sa-ocr-body { padding: 18px 22px; }

.sa-ocr-upload-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.sa-ocr-file-label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.sa-ocr-file-label:hover { background: #e5e7eb; }
.sa-ocr-file-name { font-size: 12px; color: #6b7280; }

.sa-ocr-textarea {
  width: 100%;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, 'SF Mono', monospace;
  font-size: 12px;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  resize: vertical;
  min-height: 180px;
  background: #f9fafb;
}
.sa-ocr-textarea:focus { outline: none; border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); }

.sa-ocr-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 14px;
}

.sa-ocr-result {
  margin-top: 14px;
  padding: 14px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.sa-ocr-conf {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 12px;
}
.sa-ocr-conf-ok  { background: #dcfce7; color: #14532d; }
.sa-ocr-conf-mid { background: #fef3c7; color: #78350f; }
.sa-ocr-conf-low { background: #fee2e2; color: #7f1d1d; }
.sa-ocr-conf-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}

.sa-ocr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.sa-ocr-edit {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 11px;
  color: #4b5563;
  font-weight: 600;
}
.sa-ocr-edit input {
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #111827;
}
.sa-ocr-edit input:focus { outline: none; border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); }

.sa-ocr-field {
  font-size: 12px; padding: 6px 0; color: #4b5563;
}
.sa-ocr-field-empty em { color: #9ca3af; }

.sa-ocr-warn {
  margin: 10px 0 0;
  padding: 8px 12px;
  background: #fee2e2;
  color: #7f1d1d;
  border-radius: 6px;
  font-size: 12px;
}

.sa-btn-secondary, .sa-btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.sa-btn-secondary { background: #f3f4f6; color: #374151; border-color: #d1d5db; }
.sa-btn-secondary:hover { background: #e5e7eb; }
.sa-btn-primary { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.sa-btn-primary:hover { background: linear-gradient(135deg, #d97706, #b45309); }
