:root {
  --surface: #eef2f1;
  --panel: #ffffff;
  --ink: #15231f;
  --muted: #5a6b65;
  --line: #cfd8d4;
  --accent: #0f6b5c;
  --accent-ink: #073f37;
  --accent-soft: #d8ebe6;
  --text: 0.875rem;
  --text-sm: 0.78rem;
  --space: 0.55rem;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Georgia, serif;
  font-size: var(--text);
  line-height: 1.35;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 107, 92, 0.1), transparent 42%),
    linear-gradient(180deg, #f4f7f6 0%, #e8efec 100%);
  min-height: 100vh;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell {
  display: flex;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 100vh;
}
.sidebar {
  width: 248px;
  flex: 0 0 248px;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  position: sticky;
  top: 0;
  max-height: 100vh;
  padding: 0.85rem 0.65rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.sidebar .nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.sidebar-logout-wrap {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.sidebar-logout-name {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.4rem;
  padding: 0 0.15rem;
  word-break: break-word;
}
.sidebar-logout {
  display: flex;
  width: 100%;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}
.sidebar-logout:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
  text-decoration: none;
}
.brand-kicker { font-size: 0.65rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.brand { font-size: 1.25rem; margin: 0.1rem 0; line-height: 1.2; }
.brand-logo {
  display: block;
  margin: 0 0 0.55rem;
  text-decoration: none;
}
.brand-logo img {
  display: block;
  width: 100%;
  max-width: 220px;
  height: auto;
}
.login-logo {
  display: block;
  width: min(20rem, 100%);
  margin: 0 auto 0.65rem;
}
.login-logo img { display: block; width: 100%; height: auto; }
.brand-sub { color: var(--muted); font-size: 0.75rem; margin-bottom: 0.75rem; }
.nav a {
  display: block; padding: 0.35rem 0.55rem; border-radius: 5px; color: var(--ink);
  margin-bottom: 0.12rem; text-decoration: none; font-size: 0.84rem;
}
.nav a:hover, .nav a.active { background: var(--accent-soft); }
/* Contul meu / Configurare — ogni voce col suo rettangolo */
.nav a.nav-boxed {
  margin-bottom: 0.28rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.85);
  font-weight: 700;
  color: var(--accent-ink);
}
.nav a.nav-boxed:hover,
.nav a.nav-boxed.active {
  background: var(--accent-soft);
  border-color: rgba(15, 107, 92, 0.35);
}
/* RuteLog = altra app (blu, voce singola → contenuto a destra) */
.nav a.nav-routelog {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.65rem;
  margin-bottom: 0.35rem;
  padding: 0.45rem 0.55rem;
  background: #004a8d;
  color: #fff !important;
  font-weight: 650;
  border: 1px solid #003666;
  letter-spacing: 0.02em;
}
.nav a.nav-routelog img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.nav a.nav-routelog:hover,
.nav a.nav-routelog.active {
  background: #0a6cbd;
  color: #fff !important;
  border-color: #004a8d;
}
.nav-group {
  margin: 0.55rem 0 0.15rem;
  padding: 0.35rem 0 0.15rem;
  border-top: 1px solid var(--line);
}
.nav-group:first-of-type { margin-top: 0.45rem; }
.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.35rem;
  margin: 0;
  padding: 0.28rem 0.55rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.nav-group-toggle:hover { background: var(--accent-soft); color: var(--accent-ink); }
.nav-group-chevron {
  flex: 0 0 auto;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  opacity: 0.75;
}
.nav-group.is-open .nav-group-toggle { color: var(--accent-ink); }
.nav-group.is-open .nav-group-chevron { transform: rotate(45deg); }
.nav-group-items {
  display: none;
  padding-top: 0.1rem;
}
.nav-group.is-open .nav-group-items { display: block; }
.nav-group-items a {
  padding-left: 0.7rem;
  font-size: 0.82rem;
}
.nav-sublabel {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 0.45rem 0.7rem 0.15rem;
  opacity: 0.9;
}
.nav-sublabel:first-child { padding-top: 0.15rem; }
.nav-flat {
  margin-top: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}
.nav-flat a {
  display: block;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
}
.nav-flat a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.nav-flat a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.file-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.file-pick-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.file-pick-btn { cursor: pointer; margin: 0; }
.file-pick-name { font-size: 0.85rem; color: var(--muted); }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem; border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.85);
}
.topbar h1 { margin: 0; font-size: 1.15rem; flex: 1 1 auto; min-width: 8rem; line-height: 1.2; }
.topbar .actions { flex: 1 1 auto; justify-content: flex-end; }
.content { padding: 0.75rem 1rem 1.25rem; width: 100%; max-width: 1680px; }
.toolbar-panel { margin-bottom: 0.65rem; }
.toolbar-row { margin-bottom: 0.5rem; }
.filters-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: flex-end;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}
.filter-field { margin-bottom: 0; min-width: 9rem; flex: 1 1 9rem; }
.filter-actions { display: flex; gap: 0.4rem; align-items: center; padding-bottom: 0.1rem; }
.table-wrap { padding: 0; overflow: auto; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.8rem;
  box-shadow: 0 1px 0 rgba(28,42,36,0.04);
}
.grid { display: grid; gap: var(--space); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: auto;
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .nav { overflow: visible; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
.kpi { display: block; transition: border-color .15s; padding: 0.65rem 0.75rem; }
.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi .label { font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-size: 1.35rem; margin-top: 0.2rem; line-height: 1.15; }
.kpi .hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

.dash-period {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.55rem 0.85rem;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.75rem;
}
.dash-period .field { min-width: 9rem; }
.dash-period-label { margin-left: auto; font-size: 0.8rem; align-self: center; }
.dash-kpi-row { margin-bottom: 0.25rem; }
.dash-widget-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
}
.dash-mini-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.dash-mini-row:last-child { border-bottom: 0; }
.row-overdue td { background: rgba(159, 18, 57, 0.04); }

.primite-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.efact-sections { margin-bottom: 0.65rem; }
.efact-sections .primite-tab {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.5rem 0.95rem;
}
.primite-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  text-decoration: none;
}
.primite-tab span {
  min-width: 1.1rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.72rem;
  text-align: center;
}
.primite-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.primite-tab.is-active span {
  background: rgba(255,255,255,0.22);
  color: #fff;
}
.primite-e {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  vertical-align: middle;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
}
.nowrap { white-space: nowrap; }
.rap-hub {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.65rem;
}
.rap-hub-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
}
.rap-hub-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.rap-hub-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rap-hub-links a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.2rem 0;
}
.rap-hub-links a:hover { color: var(--accent); }
.center { text-align: center; }
.user-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.35rem;
}
.user-perms label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.perm-ok { color: #15803d; font-weight: 700; }
.perm-no { color: var(--muted); }
.user-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.15rem;
  flex-wrap: wrap;
  align-items: center;
}
.conta-banner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border-color: transparent;
}
.conta-card h3 { font-size: 0.95rem; }
.conta-actions { display: flex; flex-direction: column; gap: 0.55rem; }
.conta-action {
  display: block;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
}
.conta-action strong { display: block; margin-bottom: 0.15rem; }
.conta-action:hover { border-color: var(--accent); }
.conta-action.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  background: #f7f7f7;
}
.conta-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.conta-doc-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.conta-doc-list li:last-child { border-bottom: 0; }
@media (max-width: 720px) {
  .table .nowrap { white-space: normal; }
}
.field { display: flex; flex-direction: column; gap: 0.15rem; font-size: var(--text); margin-bottom: 0.35rem; }
.field span { color: var(--muted); font-size: var(--text-sm); line-height: 1.2; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 5px; padding: 0.32rem 0.5rem; font: inherit;
  font-size: 0.875rem; background: #fff; min-height: 2rem;
}
.field textarea { min-height: 3.2rem; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.pw-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.pw-wrap input {
  width: 100%;
  padding-right: 2.3rem;
}
.pw-toggle {
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  line-height: 0;
  border-radius: 4px;
}
.pw-toggle:hover, .pw-toggle.is-on { color: var(--accent-ink); background: var(--accent-soft); }
.client-pick { display: flex; gap: 0.4rem; align-items: stretch; }
.client-pick select { flex: 1; min-width: 0; }
.client-pick .btn-plus {
  flex: 0 0 2.1rem;
  padding: 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
}
.quick-client {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  margin-top: 0.45rem;
  background: var(--surface);
}
.quick-client[hidden] { display: none; }
h2 { font-size: 1.1rem; margin: 0.35rem 0; line-height: 1.25; }
h3 { font-size: 0.95rem; margin: 0.45rem 0 0.2rem; line-height: 1.25; }
.muted { color: var(--muted); font-size: var(--text-sm); line-height: 1.3; }
.panel > .muted:first-child { margin: 0 0 0.45rem; }
.bank-accounts { display: flex; flex-direction: column; gap: 0.5rem; }
.bank-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.bank-row .field { margin-bottom: 0; }
.bank-remove {
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.35rem 0.55rem;
  color: var(--muted);
  min-width: 2.2rem;
}
.bank-remove:hover { color: #a33; }
@media (max-width: 700px) {
  .bank-row { grid-template-columns: 1fr; }
  .bank-remove { justify-self: end; }
}
.settings-shell { display: flex; flex-direction: column; gap: 0.5rem; }
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(28,42,36,0.04);
}
.settings-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 7px;
  cursor: pointer;
}
.settings-tab:hover { background: var(--accent-soft); color: var(--ink); }
.settings-tab.is-active {
  background: var(--accent);
  color: #fff;
}
/* Nu folosi display:none pe tab-uri inactive: pe unele browsere/PWA
   câmpurile din panouri ascunse nu se trimit la Salvează. Folosim [hidden]. */
.settings-card[hidden] { display: none !important; }
.settings-card.is-active { display: block; }
.settings-card.panel { padding: 0.75rem 0.9rem; }
.settings-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.settings-card-head h2 { margin: 0; font-size: 1.05rem; }
.settings-card-head .muted {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  line-height: 1.3;
}
.settings-card .grid { gap: 0.45rem 0.75rem; }
.settings-card .field {
  margin-bottom: 0.2rem;
  gap: 0.15rem;
  font-size: 0.86rem;
}
.settings-card .field > span { font-size: 0.78rem; line-height: 1.2; }
.settings-card .field input,
.settings-card .field select,
.settings-card .field textarea {
  padding: 0.35rem 0.5rem;
  font-size: 0.88rem;
  border-radius: 5px;
}
.settings-card .notice {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  line-height: 1.25;
}
.settings-card .muted { font-size: 0.8rem; line-height: 1.3; }
.settings-card h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.95rem;
}
.settings-card .bank-accounts { gap: 0.35rem; }
.settings-card .bank-row {
  gap: 0.45rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
}
.settings-card .bank-remove {
  font-size: 1.15rem;
  padding: 0.2rem 0.4rem;
  min-width: 1.8rem;
}
.settings-card .btn { padding: 0.35rem 0.7rem; font-size: 0.88rem; }
.settings-card .row-cui { gap: 0.4rem; }
.settings-card .mt { margin-top: 0.65rem; }
.settings-card .tpl-grid { gap: 0.5rem; margin-top: 0.35rem; }
.settings-card .tpl-card { padding: 0.55rem; }
.settings-card .tpl-card .tpl-swatch { height: 1.4rem; margin-bottom: 0.35rem; }
.settings-card .logo-preview { max-height: 42px; max-width: 120px; }
.settings-card .invoice-live-preview { margin-top: 0.65rem; }
.settings-card #anaf-msg:empty { display: none; margin: 0; }
@media (max-width: 700px) {
  .settings-card-head { flex-direction: column; align-items: stretch; }
}
.row-cui { display: flex; gap: 0.5rem; }
.row-cui input { flex: 1; }
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px; padding: 0.32rem 0.65rem; font: inherit; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; font-size: 0.84rem; line-height: 1.2;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: var(--accent-soft); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--muted); border: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.email-send-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.table th, .table td { padding: 0.32rem 0.45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.74rem; }
.badge {
  display: inline-flex; border-radius: 5px; padding: 0.08rem 0.32rem; font-size: 0.68rem;
  font-weight: 600; border: 1px solid;
}
.badge-draft { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge-issued { background: #f0f9ff; color: #075985; border-color: #bae6fd; }
.badge-paid { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-cancelled { background: #fff1f2; color: #9f1239; border-color: #fecdd3; }
.row-highlight td { background: #ecfdf5; }
.badge-invoice { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--line); }
.badge-proforma { background: #f5f3ff; color: #5b21b6; border-color: #ddd6fe; }
.badge-credit_note { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.badge-self_invoice { background: #ecfeff; color: #155e75; border-color: #a5f3fc; }
.badge-delivery_note { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.flash { padding: 0.45rem 0.7rem; border-radius: 8px; margin-bottom: 0.65rem; font-size: 0.84rem; }
.flash-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-err { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }
.flash-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 0.65rem; }
.notice { font-size: 0.78rem; color: var(--muted); margin: 0.25rem 0 0; line-height: 1.3; }
.cat-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.cat-chip {
  display: inline-block;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  line-height: 1.2;
}
.cat-chip:hover { background: var(--accent-soft); text-decoration: none; }
.cat-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.stock-cat-title {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-ink);
}
.row-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.row-inline-form input[type="text"],
.row-inline-form input:not([type]) {
  min-width: 10rem;
  flex: 1;
}
.info-tip-btn {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: 700 0.75rem/1 Georgia, serif;
  cursor: pointer;
  padding: 0;
}
.info-tip-btn[aria-expanded="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.info-tip-panel {
  margin-top: 0.65rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf9;
  font-size: 0.88rem;
  color: var(--ink);
}
.info-tip-panel ul {
  margin: 0.35rem 0 0.75rem 1.1rem;
  padding: 0;
}
.info-tip-panel li { margin: 0.2rem 0; }
.info-tip-panel code {
  font-size: 0.82rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}
.receipt-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid #86efac;
  border-radius: 10px;
  background: #ecfdf5;
  color: #065f46;
  font-size: 0.92rem;
}
.receipt-preview-label {
  margin: 1.5rem 0 0.65rem;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.receipt-sheet {
  border: 2px dashed var(--accent);
  background: #f7fbf9;
  scroll-margin-top: 1rem;
}
.receipt-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.35rem;
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .receipt-sheet {
    break-before: page;
    page-break-before: always;
    box-shadow: none;
    border-radius: 0;
    border-style: solid;
  }
  .nir-sheet {
    box-shadow: none;
    border: none;
  }
}

/* NIR 14-3-1A */
.nir-sheet .nir-head {
  display: flex;
  justify-content: space-between;
  gap: 0.85rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.5rem;
}
.nir-sheet .nir-title {
  margin: 0.1rem 0 0.2rem;
  font-size: 1rem;
  line-height: 1.25;
}
.nir-sheet .nir-meta { text-align: right; font-size: 0.84rem; }
.nir-sheet .nir-info {
  display: grid;
  gap: 0.2rem;
  font-size: 0.84rem;
}
.nir-sheet .nir-label {
  display: inline-block;
  min-width: 7.5rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 600;
}
.nir-sheet .nir-diff {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  background: #fffdf7;
}
.nir-sheet .nir-diff h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}
.nir-sheet .nir-signs {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 0.85rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}
.nir-sheet .nir-sign-row {
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  margin-top: 0.4rem;
  align-items: flex-end;
}
.nir-sheet .nir-sign-line {
  border-bottom: 1px solid #111;
  min-width: 7rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  padding-bottom: 0.1rem;
}
.nir-sheet .nir-table th,
.nir-sheet .nir-table td {
  padding: 0.25rem 0.35rem;
  font-size: 0.8rem;
}
.nir-pdf-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
  padding: 0.55rem 0.65rem;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.nir-pdf-extract {
  font-size: 0.78rem;
  color: var(--muted);
}
.nir-pdf-extract pre {
  margin: 0.4rem 0 0;
  max-height: 12rem;
  overflow: auto;
  padding: 0.45rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: pre-wrap;
  font-size: 0.75rem;
}
.nir-form .section-title {
  margin: 0.55rem 0 0.25rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.15rem;
}
.section-title {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.2rem;
}
.code-lookup { position: relative; }
.code-suggest {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% - 0.1rem);
  max-height: 14rem;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15, 40, 35, 0.12);
}
.code-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.4rem 0.55rem;
  font-size: 0.84rem;
  cursor: pointer;
  color: var(--ink);
  line-height: 1.3;
}
.code-suggest-item:hover,
.code-suggest-item:focus {
  background: var(--accent-soft);
  outline: 0;
}
.code-suggest-item .risk {
  color: #a15c00;
  font-style: normal;
  font-size: 0.72rem;
  margin-left: 0.25rem;
}
.code-suggest-empty {
  padding: 0.45rem 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.pill {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
  font-weight: 600;
}
.pill-warn {
  background: #fff3d6;
  color: #8a5a00;
  border: 1px solid #f0d49a;
}
.scan-field { margin: 0.5rem 0 0.75rem; }
.barcode-scan-input {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.02em;
  border: 1px dashed var(--accent) !important;
  background: #f4fbf8 !important;
}
.barcode-scan-input.is-scanning { opacity: 0.7; }
.barcode-scan-input.is-miss {
  border-color: #9f1239 !important;
  background: #fff1f2 !important;
}
tr.scan-hit {
  outline: 2px solid var(--accent);
  background: var(--accent-soft);
}
.nir-form .nir-lines { width: 100%; }
.nir-form .nir-lines th,
.nir-form .nir-lines td { padding: 0.2rem 0.28rem; vertical-align: middle; }
.nir-form .nir-lines input,
.nir-form .nir-lines select {
  width: 100%;
  min-width: 0;
  padding: 0.22rem 0.3rem;
  font-size: 0.8rem;
}
.nir-form .nir-lines .prod { min-width: 7.5rem; max-width: 11rem; }
.nir-form .nir-lines .desc { min-width: 14rem; }
.nir-form .nir-lines .unit { max-width: 3.2rem; }
.nir-form .nir-lines .qty-inv,
.nir-form .nir-lines .qty-rec,
.nir-form .nir-lines .qty-rej,
.nir-form .nir-lines .markup,
.nir-form .nir-lines .vat { max-width: 4.4rem; }
.nir-form .nir-lines .price,
.nir-form .nir-lines .sale { max-width: 5.4rem; }
@media (max-width: 800px) {
  .nir-sheet .nir-head,
  .nir-sheet .nir-signs { grid-template-columns: 1fr; display: grid; }
  .nir-sheet .nir-meta { text-align: left; }
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 22rem;
}
.row-cui {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.row-cui input { flex: 1; }

.cookie-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  background: #15231f;
  color: #f4f7f6;
  padding: 0.85rem 1rem;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
}
.cookie-bar-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  font-size: 0.88rem;
}
.cookie-bar p { margin: 0; max-width: 44rem; }
.cookie-bar a { color: #9ee0d4; }
.cookie-bar-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.cookie-bar .btn { text-decoration: none; }

.help-bot {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
}
.nav-dot {
  display: inline-block;
  min-width: 1.05rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #c2410c;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
  margin-left: 0.2rem;
  vertical-align: middle;
  text-align: center;
}
.nav-dot[hidden] { display: none !important; }
.table tr.is-unread td { font-weight: 650; background: var(--accent-soft); }
.help-bot-fab {
  position: relative;
  display: inline-block;
}
.help-bot-toggle {
  width: 2.6rem;
  height: 2.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: 700 1.15rem/1 "Segoe UI", sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(15, 107, 92, 0.28);
}
.help-bot-badge {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  z-index: 2;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font: 700 0.72rem/1.25rem "Segoe UI", sans-serif;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 0 2px #fff;
}
.help-bot-badge[hidden] { display: none !important; }
.help-bot-panel {
  position: absolute;
  right: 0;
  bottom: 3.2rem;
  width: min(22rem, calc(100vw - 2rem));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(21, 35, 31, 0.16);
  overflow: hidden;
}
.help-bot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.7rem;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}
.help-bot-close {
  border: 0;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
}
.help-bot-log {
  max-height: 16rem;
  overflow: auto;
  padding: 0.6rem;
}
.help-bot-msg {
  margin: 0 0 0.45rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  font-size: 0.82rem;
  white-space: pre-wrap;
}
.help-bot-msg-bot, .help-bot-msg-staff { background: #f3f6f5; }
.help-bot-msg-user { background: var(--accent-soft); margin-left: 1.5rem; }
.help-bot-msg-staff { border-left: 3px solid var(--accent); }
.help-bot-human {
  padding: 0 0.6rem 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.help-bot-form {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem 0.6rem 0.25rem;
  border-top: 1px solid var(--line);
}
.help-bot-human-link {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0 0.7rem 0.5rem;
  cursor: pointer;
  text-align: left;
}
.help-bot-human-link:hover,
.help-bot-human-link.is-hot { color: var(--accent); }
.help-bot-input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.45rem;
}

/* Document header — layout compact */
.doc-header {
  display: grid;
  gap: 0.55rem;
}
.doc-header .field { margin: 0; }
.doc-header-row {
  display: grid;
  gap: 0.5rem;
  align-items: end;
}
.doc-header-client {
  grid-template-columns: minmax(0, 1fr) minmax(8rem, 12rem);
}
.doc-inline-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
}
.doc-header .field-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.doc-header .field-inline > span {
  flex: 0 0 auto;
  min-width: auto;
}
.doc-header .field-inline > select,
.doc-header .field-inline > input,
.doc-header .field-inline > .row-cui {
  flex: 0 1 auto;
  min-width: 0;
}
.doc-field-status select { width: 7.5rem; }
.doc-field-proforma { flex: 1 1 14rem; min-width: 12rem; max-width: 26rem; }
.doc-field-proforma select { width: 100%; min-width: 12rem; }
.doc-field-pay select { width: 9.5rem; }
.doc-field-currency select { width: 5.5rem; }
.doc-header-dates input[type="date"] { width: 10.5rem; }
.doc-fx-controls { min-width: 8.5rem; }
.doc-fx-controls input { width: 4.5rem; }
.doc-fx-hint,
.doc-cash-hint,
.doc-proforma-hint {
  margin: 0;
  font-size: 0.78rem;
}
.doc-series-badge {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  width: fit-content;
  max-width: 100%;
  padding: 0.45rem 0.85rem;
  border: 1px solid #9ec9bc;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.9rem;
}
.doc-series-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}
.doc-series-value { font-size: 1.05rem; }
.doc-series-sep { opacity: 0.55; }
@media (max-width: 560px) {
  .doc-header-client { grid-template-columns: 1fr; }
  .doc-header .field-inline {
    flex-direction: column;
    align-items: stretch;
    white-space: normal;
    width: 100%;
  }
  .doc-field-status select,
  .doc-field-pay select,
  .doc-field-currency select,
  .doc-header-dates input[type="date"],
  .doc-field-proforma select { width: 100%; }
}

/* Document lines — composer SmartBill-style */
.doc-lines-panel .doc-lines-title {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}
.doc-line-composer {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2, var(--surface));
  margin-bottom: 1.1rem;
}
.doc-composer-metrics {
  display: grid;
  grid-template-columns: minmax(4.5rem, 0.7fr) minmax(5rem, 1fr) minmax(6.5rem, 1.2fr) minmax(5.5rem, 1fr);
  gap: 0.55rem;
  margin-top: 0.65rem;
  align-items: end;
}
.doc-composer-metrics.has-vat {
  grid-template-columns: minmax(4rem, 0.65fr) minmax(4.5rem, 0.9fr) minmax(6rem, 1.1fr) minmax(5rem, 0.9fr) minmax(5.5rem, 1fr);
}
.doc-composer-metrics .num-comma,
input.num-comma {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  .doc-composer-metrics,
  .doc-composer-metrics.has-vat { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .doc-composer-metrics,
  .doc-composer-metrics.has-vat { grid-template-columns: 1fr; }
}
.doc-composer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.75rem;
}
.doc-composer-actions #composer-msg {
  margin-right: auto;
}
.doc-composer-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}
.doc-invoice-lines {
  margin-top: 0.35rem;
}
.doc-lines-table-wrap {
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
}
.doc-lines-table { margin: 0; }
.doc-lines-empty { margin: 0.35rem 0 0; }
.doc-lines-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.95rem;
}
.doc-lines-total-main { font-size: 1.05rem; }
.doc-line-actions { white-space: nowrap; }
.doc-line-desc { white-space: pre-wrap; max-width: 22rem; }
.btn-sm {
  padding: 0.22rem 0.5rem;
  font-size: 0.78rem;
  min-height: 0;
}
.field-disabled {
  opacity: 0.65;
}
.field-disabled select:disabled,
.field-disabled input:disabled {
  cursor: not-allowed;
  background: var(--surface-2, #f3f4f6);
}

/* Nomenclator produs — riga compactă categorie / UM / preț / TVA */
.prod-form-main {
  display: grid;
  gap: 0.55rem;
}
.prod-form-metrics {
  display: grid;
  grid-template-columns: minmax(8rem, 1.6fr) minmax(4.5rem, 0.7fr) minmax(6rem, 1fr) minmax(6.5rem, 1.1fr);
  gap: 0.5rem;
  align-items: end;
}
.prod-form-extra {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(6rem, 0.8fr);
  gap: 0.5rem;
  align-items: end;
}
.prod-cat-link {
  font-weight: 500;
  font-size: 0.78rem;
  margin-left: 0.25rem;
}
.prod-vat-hint,
.prod-scan-hint {
  margin: 0;
  font-size: 0.78rem;
}
.prod-field-um select,
.prod-field-weight input {
  max-width: 100%;
}
@media (max-width: 720px) {
  .prod-form-metrics { grid-template-columns: 1fr 1fr; }
  .prod-form-extra { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .prod-form-metrics { grid-template-columns: 1fr; }
}

