/* ============================================================
   FinanzHub — Modal (editorial)
   ============================================================ */

.fh-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8,8,10,.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: grid; place-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.fh-modal-overlay.open { opacity: 1; pointer-events: auto; }
.fh-modal {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  width: min(540px, 100%);
  max-height: 88vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  transform: translateY(10px) scale(.98);
  transition: transform .25s cubic-bezier(.2,.7,.3,1);
  box-shadow: 0 24px 80px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.05);
}
.fh-modal-overlay.open .fh-modal { transform: none; }

.fh-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
.fh-modal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  text-transform: uppercase;
  letter-spacing: -.005em;
  line-height: 1.05;
  text-wrap: balance;
}
.fh-modal-subtitle {
  font-family: var(--font-italic);
  font-style: normal;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  margin-top: 6px;
  text-wrap: pretty;
  max-width: 56ch;
}
.fh-modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 22px; line-height: 1;
  color: var(--ink-mute);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.fh-modal-close:hover { background: rgba(255,255,255,.06); color: var(--ink); }

.fh-modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
}

.fh-modal-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(0,0,0,.18);
  gap: 10px;
}
.fh-modal-foot-right { display: flex; gap: 8px; }

/* CSV-Import-Preview-Tabelle */
.csv-preview-wrap { font-size: 13px; }
.csv-empty {
  text-align: center;
  color: var(--ink-mute);
  padding: 24px 8px;
}
.csv-preview {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}
.csv-preview th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.csv-preview td {
  padding: 8px 8px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--ink);
  vertical-align: top;
}
.csv-preview tr:last-child td { border-bottom: 0; }
.csv-preview td:first-child {
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  white-space: nowrap;
}
.csv-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.csv-num.pos { color: #34d399; }
.csv-num.neg { color: #f87171; }
.csv-cat {
  color: var(--ink-mute);
  font-size: 12px;
}
.csv-more {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-mute);
  text-align: center;
}
.csv-errors {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.csv-errors summary {
  cursor: pointer;
  font-size: 12px;
  color: #f87171;
  font-weight: 600;
}
.csv-errors ul {
  margin: 8px 0 0 18px;
  padding: 0;
  font-size: 12px;
  color: var(--ink-mute);
}
.csv-errors li { margin: 2px 0; }

/* CSV — KI-Status Banner */
.csv-cat-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  margin-bottom: 14px;
  line-height: 1.4;
}
.csv-cat-status.is-ai {
  background: rgba(232,105,10,0.10);
  border: 1px solid rgba(232,105,10,0.30);
  color: var(--ink);
}
.csv-cat-status.is-fallback {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--ink-mute);
}
.csv-cat-status-ico { font-size: 14px; flex-shrink: 0; }

/* CSV — Preview Scroll Container */
.csv-preview-scroll {
  max-height: 56vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.csv-preview-scroll .csv-preview { margin-top: 0; }
.csv-preview-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--panel, #1a1a1f);
  z-index: 2;
}

/* CSV — Zellen */
.csv-cell-date {
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  white-space: nowrap;
  font-size: 12px;
}
.csv-cell-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
}
.csv-cell-amt.pos { color: #34d399; }
.csv-cell-amt.neg { color: #f87171; }
.csv-cell-desc {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
.csv-cell-cat { width: 180px; }

/* CSV — Custom Category Picker */
.csv-cat-picker {
  position: relative;
  width: 100%;
}
.csv-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.csv-cat-btn:hover {
  border-color: rgba(232,105,10,0.4);
  background: rgba(232,105,10,0.05);
}
.csv-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.csv-cat-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.csv-cat-name.csv-cat-empty,
.csv-cat-empty {
  color: var(--ink-mute);
  font-style: normal;
}
.csv-cat-chev {
  opacity: 0.5;
  flex-shrink: 0;
}
.csv-cat-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  max-height: 280px;
  overflow-y: auto;
  background: #18181d;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  padding: 4px;
  z-index: 100;
}
.csv-cat-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  border-radius: 5px;
  text-align: left;
}
.csv-cat-opt:hover {
  background: rgba(232,105,10,0.10);
}
.csv-edit-hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--ink-mute);
  text-align: center;
  font-style: normal;
}

/* CSV — Loading Overlay (während KI-Call) */
.csv-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: csvLoadFadeIn .2s ease-out;
}
@keyframes csvLoadFadeIn { from { opacity: 0; } to { opacity: 1; } }
.csv-loading-box {
  background: #18181d;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 40px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.csv-loading-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(232,105,10,0.18);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: csvSpin .8s linear infinite;
}
@keyframes csvSpin { to { transform: rotate(360deg); } }
.csv-loading-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.csv-loading-sub {
  font-size: 12px;
  color: var(--ink-mute);
}

/* Buttons */
.fh-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 10px 18px;
  border-radius: 999px;
  transition: all .18s;
  cursor: pointer;
}
.fh-btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.fh-btn-primary:hover {
  background: var(--accent-2);
  box-shadow: 0 12px 26px -8px rgba(255,255,255,.4);
}
.fh-btn-ghost {
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.fh-btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }
.fh-btn-danger {
  border: 1px solid rgba(210,132,132,.4);
  color: var(--neg);
}
.fh-btn-danger:hover { background: rgba(210,132,132,.1); }

/* Form fields */
.fh-field { margin-bottom: 14px; }
.fh-field:last-child { margin-bottom: 0; }
.fh-field label {
  display: block;
  font-size: 10.5px; letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.fh-field-inp { position: relative; }
.fh-field-inp input,
.fh-field-inp select,
.fh-field-inp textarea {
  width: 100%;
  background: rgba(0,0,0,.32);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 14px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.fh-field-inp.has-unit input { padding-right: 48px; }
.fh-field-inp .fh-unit {
  position: absolute;
  right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 12px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  pointer-events: none;
}
.fh-field-inp input:focus,
.fh-field-inp select:focus,
.fh-field-inp textarea:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,.06);
  box-shadow: 0 0 0 3px rgba(255,255,255,.10);
}
.fh-field-inp select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c9a96a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.fh-field.has-error .fh-field-inp input,
.fh-field.has-error .fh-field-inp select,
.fh-field.has-error .fh-field-inp textarea {
  border-color: #e24b4a;
  background: rgba(226, 75, 74, .06);
}
.fh-field.has-error .fh-field-inp input:focus,
.fh-field.has-error .fh-field-inp select:focus,
.fh-field.has-error .fh-field-inp textarea:focus {
  box-shadow: 0 0 0 3px rgba(226, 75, 74, .14);
}
.fh-field-error {
  margin-top: 6px;
  font-size: 12px;
  color: #e24b4a;
  letter-spacing: 0;
  text-transform: none;
}
input[type="number"] { -moz-appearance: textfield; }

/* Custom Select (Editorial) — ersetzt natives <select> wegen unstylebarer OS-Dropdown-Optik */
.fh-cselect {
  position: relative;
}
.fh-cselect-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(0,0,0,.32);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 14px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.fh-cselect-btn:hover,
.fh-cselect-btn:focus-visible,
.fh-cselect.is-open .fh-cselect-btn {
  border-color: var(--accent);
  background: rgba(255,255,255,.06);
  box-shadow: 0 0 0 3px rgba(255,255,255,.10);
}
.fh-cselect-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fh-cselect-chev {
  width: 14px; height: 14px;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform .2s ease;
}
.fh-cselect.is-open .fh-cselect-chev { transform: rotate(180deg); }

.fh-cselect-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: rgba(13,14,18,.98);
  border: 1px solid var(--line-hi);
  border-radius: 6px;
  box-shadow: 0 18px 40px -16px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06);
  z-index: 1100;
  max-height: 260px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.fh-cselect.is-open .fh-cselect-list {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.fh-cselect-opt {
  padding: 10px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
  transition: background .12s, color .12s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.fh-cselect-opt:hover {
  background: rgba(255,255,255,.10);
  color: var(--ink);
}
.fh-cselect-opt.is-selected {
  color: var(--accent);
  background: rgba(255,255,255,.06);
}
.fh-cselect-opt.is-selected::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.fh-cselect-opt:not(.is-selected)::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}

/* Radio group */
.fh-radio-group { display: flex; flex-wrap: wrap; gap: 6px; }
.fh-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
  font-size: 12px;
  color: var(--ink-soft);
}
.fh-radio input { display: none; }
.fh-radio:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* Edit pencil & delete buttons (used inline) */
.fh-icon-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-mute);
  transition: background .15s, color .15s;
}
.fh-icon-btn:hover { background: rgba(255,255,255,.06); color: var(--accent); }
.fh-icon-btn.danger:hover { background: rgba(210,132,132,.10); color: var(--neg); }
.fh-icon-btn svg { width: 14px; height: 14px; }

/* Inline-add row */
.fh-add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px dashed var(--line);
  font-family: var(--font-italic);
  font-style: normal;
  color: var(--ink-mute);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.fh-add-row:hover { color: var(--accent); background: rgba(255,255,255,.04); }
.fh-add-row::before { content: "+ "; }
