:root {
  --bg: #12141a;
  --surface: #191c24;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8a90a3;
  --accent: #e3a857;
  --accent-ink: #211603;
  --success: #5fb88b;
  --danger: #da6f63;
  --info: #6ea8d8;
  --font-display: 'Segoe UI Semibold', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'JetBrains Mono', 'Cascadia Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
}

.app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 210px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-mark {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--accent);
  border: 1px solid var(--accent);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: .04em; }

.nav-item {
  all: unset;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--accent); font-weight: 600; }
.nav-spacer { flex: 1; }

/* Content */
.content { flex: 1; overflow-y: auto; padding: 28px 36px; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.view-head h1 { font-family: var(--font-display); font-size: 21px; margin: 0; letter-spacing: -.01em; }
.head-actions { display: flex; gap: 8px; }

.btn {
  all: unset;
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn-accent { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-color: var(--accent); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-small { padding: 4px 10px; font-size: 12px; }

/* Ledger table */
.ledger-table { width: 100%; border-collapse: collapse; }
.ledger-table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  font-weight: 600;
}
.ledger-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.ledger-table tbody tr:hover { background: var(--surface); }
.ledger-table .num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ledger-table th.num, .ledger-table td.num { text-align: right; }

.ledger-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  margin-top: 4px;
  font-family: var(--font-display);
}
.ledger-total-bar span:last-child { font-size: 20px; color: var(--accent); }

/* Stamp-style status badge */
.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1.5px dashed currentColor;
  border-radius: 3px;
  transform: rotate(-2deg);
}
.stamp-draft { color: var(--muted); }
.stamp-sent { color: var(--info); }
.stamp-accepted, .stamp-paid { color: var(--success); }
.stamp-rejected, .stamp-overdue { color: var(--danger); }
.stamp-invoiced, .stamp-unpaid { color: var(--accent); }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 13.5px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.notes-field { margin-top: 16px; }

.item-add-row { display: flex; gap: 10px; margin: 12px 0 20px; }
.item-add-row select { flex: 1; }

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-row { display: flex; align-items: center; gap: 10px; }
.key-field { display: flex; gap: 8px; }
.key-field input { flex: 1; }
.hint { color: var(--muted); font-size: 12px; }
.hint.ok { color: var(--success); }
.hint.err { color: var(--danger); }

/* Template gallery (Beállítások > Árajánlat kinézete) */
.template-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 6px;
}
.template-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.template-card.selected { border-color: var(--accent); }
.template-card h3 {
  margin: 0;
  font-size: 13.5px;
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  gap: 8px;
}
.template-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.template-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  flex: 1;
}
.template-actions { display: flex; gap: 8px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 9, 12, .6);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 420px;
  max-width: 90vw;
}
.modal.modal-lg { width: 880px; max-width: 94vw; }
.modal h2 { margin: 0 0 16px; font-family: var(--font-display); font-size: 16px; }
.modal .form-grid { grid-template-columns: 1fr; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#template-preview-frame {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.icon-btn { all: unset; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.icon-btn:hover { color: var(--danger); }

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

/* Search boxes in list headers */
.search-box {
  min-width: 220px;
}

/* Dashboard */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 16px 18px;
}
.stat-card .stat-label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 22px; }
.stat-card.warn { border-left-color: var(--danger); }
.stat-card.warn .stat-value { color: var(--danger); }

.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}
.dash-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}
.dash-panel h3 { margin: 0 0 14px; font-family: var(--font-display); font-size: 14px; }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 160px;
}
.bar-chart .bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
}
.bar-chart .bar {
  width: 100%;
  max-width: 40px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.bar-chart .bar-label { font-size: 10.5px; color: var(--muted); }
.bar-chart .bar-value { font-size: 10.5px; color: var(--text); font-family: var(--font-mono); }

.top-customer-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.top-customer-row:last-child { border-bottom: none; }

/* Recurring */
.toggle-switch { all: unset; cursor: pointer; font-size: 18px; }

/* --- Webes többfelhasználós verzió kiegészítései --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
  padding: 10px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
#topbar-company { font-weight: 600; margin-right: auto; color: var(--text); }
.row-actions { display: flex; gap: 8px; }

.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--danger);
  color: #fff;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
}
.impersonation-banner .btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
.impersonation-banner .btn:hover { border-color: #fff; }
