:root {
  --bg: #0a0e17;
  --surface: #121a2a;
  --surface2: #1a2740;
  --border: #2a3d5c;
  --text: #eef2f8;
  --muted: #8b9cb3;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --mak-gold: #c9a227;
  --mak-gold-light: #e8c547;
  --mak-gold-dim: rgba(201, 162, 39, 0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --sidebar-w: 272px;
  --font: 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

.cfma-titlebar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 26px;
  padding: 0.25rem 0.7rem;
  border-bottom: 1px solid #8b8f9a;
  background: linear-gradient(#f3f3f3, #d8d8d8);
  color: #151923;
  font-size: 0.78rem;
}

.cfma-menubar {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 30px;
  border-bottom: 1px solid #7c8290;
  background: #ece9d8;
  color: #111827;
  flex-shrink: 0;
  overflow: visible;
  z-index: 45;
}

.cfma-menu {
  position: relative;
}

.cfma-menu > button {
  height: 100%;
  padding: 0.32rem 0.58rem;
  border: 0;
  border-right: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 0;
  background: transparent;
  color: #111827;
  font-size: 0.82rem;
  cursor: pointer;
}

.cfma-menu:hover > button,
.cfma-menu > button:focus {
  background: #2563eb;
  color: white;
}

.cfma-dropdown {
  position: absolute;
  left: 0;
  top: 100%;
  display: none;
  min-width: 260px;
  padding: 0.35rem 0;
  border: 1px solid #7f7f7f;
  background: #efecc8;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.22);
  z-index: 80;
}

.cfma-menu:hover .cfma-dropdown,
.cfma-menu:focus-within .cfma-dropdown {
  display: block;
}

.cfma-dropdown button {
  display: block;
  width: 100%;
  padding: 0.43rem 0.8rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #111827;
  text-align: left;
  font-size: 0.82rem;
  cursor: pointer;
}

.cfma-dropdown button:hover,
.cfma-dropdown button:focus {
  background: #2563eb;
  color: white;
}

.cfma-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  border-bottom: 3px solid #101f78;
  background: linear-gradient(#d7d7d7, #bfc3c9);
  flex-shrink: 0;
}

.cfma-toolbar button {
  min-width: 34px;
  height: 32px;
  padding: 0 0.45rem;
  border: 1px solid #777;
  border-radius: 4px;
  background: linear-gradient(#ffffff, #d1d5db);
  color: #0f172a;
  font-weight: 700;
  font-size: 0.78rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  cursor: pointer;
}

.cfma-toolbar button:hover {
  border-color: #1d4ed8;
  background: #dbeafe;
}

/* —— Sidebar —— */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0f1624 0%, var(--surface) 100%);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--mak-gold), var(--mak-gold-light));
  color: #0a0e17;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  margin-bottom: 0.45rem;
}

.logo h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1.3;
}

.logo span { font-size: 0.72rem; color: var(--muted); display: block; margin-top: 0.2rem; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 0.5rem;
}

.nav-main {
  padding: 0.5rem 0 0.25rem;
}

.nav-modules {
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  padding-top: 0.25rem;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  border-left: 3px solid transparent;
}

.nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav a.active {
  color: var(--text);
  background: var(--mak-gold-dim);
  border-left-color: var(--mak-gold);
}

.nav-group-title {
  padding: 0.85rem 1.25rem 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--mak-gold);
  opacity: 0.9;
}

.cfma-shortcuts-title {
  padding: 0.7rem 0.9rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--mak-gold);
  text-transform: uppercase;
}

.cfma-shortcuts {
  display: grid;
  gap: 0.1rem;
  padding: 0.15rem 0.65rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.cfma-shortcuts button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #9db7ff;
  text-align: left;
  text-decoration: underline;
  font-size: 0.82rem;
  padding: 0.24rem 0.15rem;
  cursor: pointer;
}

.cfma-shortcuts button:hover {
  color: white;
  background: rgba(255,255,255,0.06);
}

.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--muted);
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/* —— Main —— */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  background: var(--bg);
}

.header {
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.header-titles { min-width: 0; }

.header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status-dot.ok { background: var(--success); box-shadow: 0 0 6px rgba(34, 197, 94, 0.5); }
.status-dot.err { background: var(--danger); }
.status-dot.warn { background: var(--mak-gold); }

.header-banner {
  display: none;
  padding: 0.55rem 1.5rem;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  background: var(--mak-gold-dim);
  color: var(--text);
}

.header-banner.visible { display: block; }
.header-banner.warn { background: rgba(245, 158, 11, 0.12); }
.header-banner.error { background: rgba(239, 68, 68, 0.12); }

.content {
  padding: 1.25rem 1.5rem 2rem;
  flex: 1;
  overflow: auto;
}

/* —— Dashboard —— */
.product-hero {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.product-hero h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.product-hero .version {
  color: var(--mak-gold);
  font-size: 0.88rem;
}

.page-intro {
  font-size: 0.88rem;
  margin-bottom: 1rem;
  line-height: 1.55;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  border-top: 3px solid var(--mak-gold);
}

.stat .label { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 1.45rem; font-weight: 700; color: var(--text); }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.quick-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  color: inherit;
  font: inherit;
}

.quick-card:hover {
  border-color: var(--mak-gold);
  background: var(--surface2);
  transform: translateY(-1px);
}

.quick-card .icon { font-size: 1.5rem; margin-bottom: 0.35rem; display: block; }
.quick-card .label { font-size: 0.82rem; color: var(--muted); }

.roadmap {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.roadmap h3 {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  color: var(--mak-gold);
}

.roadmap-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.roadmap-steps li {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border-left: 3px solid transparent;
}

.roadmap-steps li.active {
  color: var(--text);
  background: var(--mak-gold-dim);
  border-left-color: var(--mak-gold);
}

.roadmap-steps li.done {
  color: var(--success);
  border-left-color: var(--success);
}

.catalog-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.catalog-summary span {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.catalog-summary strong { color: var(--text); }

.cfg-checklist { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.75rem 0; }
.cfg-step { font-size: 0.88rem; padding: 0.35rem 0.5rem; border-radius: 4px; background: var(--surface2, #1a1d24); }
.cfg-step.ok { border-left: 3px solid var(--ok, #2ecc71); }
.cfg-steps span.ok { color: var(--ok, #2ecc71); }
.cfg-steps span.miss { color: var(--muted, #888); }

.alert-box {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

.alert-box.info { background: var(--mak-gold-dim); border-color: rgba(201, 162, 39, 0.35); }
.alert-box.warn { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.35); }
.alert-box code { font-size: 0.8rem; background: rgba(0,0,0,0.25); padding: 0.1rem 0.35rem; border-radius: 4px; }

.vnes-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.vnes-tab {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
}

.vnes-tab.active {
  background: var(--mak-gold-dim);
  color: var(--text);
  border-color: var(--mak-gold);
}

.vnes-pane { display: none; }
.vnes-pane.active { display: block; }

.vnes-form { padding: 1.15rem 1.25rem; }
.vnes-form h3 { margin: 0; font-size: 1rem; }

.vnes-form-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.vnes-form-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.vnes-flow-chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.vnes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.vnes-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.vnes-grid input,
.vnes-grid select { min-width: 0; width: 100%; }

.vnes-grid input.is-invalid,
.vnes-grid select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.vnes-field-hint {
  margin: -0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.vnes-field-hint.ok { color: var(--success); }
.vnes-field-hint.warn { color: var(--warning); }
.vnes-field-hint.err { color: var(--danger); }

.vnes-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.vnes-message {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  border: 1px solid var(--border);
  background: var(--surface2);
}

.vnes-message:empty { display: none; }

.vnes-message.ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.vnes-message.err {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
}

#vnes-status:empty { display: none; }

.ai-dropzone {
  border: 2px dashed rgba(201, 162, 39, 0.45);
  border-radius: 10px;
  padding: 1.5rem;
  text-align: center;
  background: var(--surface2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.ai-dropzone.dragover { border-color: var(--mak-gold); background: var(--mak-gold-dim); }
.ai-inv-hint { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.75rem; }
.ai-inv-types { font-size: 0.75rem; color: var(--muted); margin-top: 0.5rem; }
.ai-inv-preview { margin: 1rem 0; max-height: 220px; overflow: auto; }
.ai-inv-preview img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.ai-inv-check { display: flex; align-items: center; gap: 0.5rem; margin: 1rem 0; font-size: 0.9rem; }
.ai-inv-checks { display: grid; gap: 0.45rem; margin: 0.85rem 0; }
.ai-check-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, auto) 1fr;
  align-items: start;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  font-size: 0.86rem;
}
.ai-check-row strong { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0; }
.ai-check-row.ok { border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.ai-check-row.ok strong { color: #16a34a; }
.ai-check-row.warn { border-color: rgba(245, 158, 11, 0.42); background: rgba(245, 158, 11, 0.1); }
.ai-check-row.warn strong { color: #b45309; }
.ai-check-row.err { border-color: rgba(239, 68, 68, 0.38); background: rgba(239, 68, 68, 0.09); }
.ai-check-row.err strong { color: var(--danger); }
.ai-stavki-table { width: 100%; font-size: 0.85rem; margin: 0.75rem 0; border-collapse: collapse; }
.ai-stavki-table th, .ai-stavki-table td { border: 1px solid var(--border); padding: 0.35rem 0.5rem; text-align: left; }
.smetk-auto-actions { flex-wrap: wrap; }
.sm-auto-result { margin-top: 1rem; padding: 0.75rem; background: var(--surface2); border-radius: 8px; font-size: 0.8rem; overflow: auto; max-height: 240px; white-space: pre-wrap; }
button.linkish { background: none; border: none; color: var(--mak-gold); cursor: pointer; text-decoration: underline; padding: 0; font: inherit; }

.mak-client-select {
  max-width: 200px;
  font-size: 0.78rem;
  padding: 0.35rem 0.5rem;
  margin-right: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
.klijenti-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.klijent-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; background: var(--surface2); border-radius: 8px; border: 1px solid var(--border);
}
.klijent-card strong { flex: 1 1 180px; }
.klijent-card span { font-size: 0.85rem; color: var(--muted); flex: 1 1 200px; }

.izv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.izv-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 5.5rem;
  transition: border-color 0.15s, background 0.15s;
}

.izv-card:hover {
  border-color: var(--mak-gold);
  background: rgba(201, 162, 39, 0.06);
}

.izv-card strong { font-size: 0.92rem; line-height: 1.3; }

.izv-cat {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mak-gold);
  font-weight: 700;
}

.izv-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

#izvestai-result { margin-top: 0.5rem; }

.vnes-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.25rem; }
.vnes-tab { flex-shrink: 0; white-space: nowrap; }

/* —— Modules / catalog —— */
.module-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  transition: border-color 0.15s;
}

.module-card:hover { border-color: var(--mak-gold); }

.module-card h3 { font-size: 1rem; margin-bottom: 0.35rem; }
.module-card p { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.75rem; line-height: 1.4; }
.module-card ul { list-style: none; max-height: 200px; overflow-y: auto; }
.module-card li { margin-bottom: 0.25rem; }
.module-card a, .catalog-link { color: var(--accent); text-decoration: none; font-size: 0.85rem; cursor: pointer; }
.module-card a:hover, .catalog-link:hover { text-decoration: underline; color: var(--mak-gold-light); }

.sp-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.sp-row code { flex: 1; font-family: Consolas, monospace; color: var(--text); font-size: 0.82rem; }

.badge-write {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.table-link { cursor: pointer; color: var(--accent); }
.table-link:hover { text-decoration: underline; }

/* —— Toolbar & forms —— */
.toolbar {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  align-items: center;
}

input[type="search"],
input[type="text"],
input[type="number"],
input[type="date"],
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  min-width: 160px;
}

input[type="search"] { min-width: 220px; }

select { cursor: pointer; min-width: 140px; }

input:focus, select:focus {
  outline: 2px solid var(--mak-gold);
  outline-offset: 0;
  border-color: var(--mak-gold);
}

label.inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

button, .btn {
  background: linear-gradient(180deg, var(--mak-gold-light), var(--mak-gold));
  color: #0a0e17;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s, transform 0.1s;
}

button:hover { filter: brightness(1.08); }
button:active { transform: scale(0.98); }

button.secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

button.secondary:hover { filter: none; background: var(--border); }

/* —— Tables —— */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 480px;
}

th, td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(201, 162, 39, 0.06); }
tr.clickable { cursor: pointer; }

.badge {
  display: inline-block;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-v { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-i { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

.empty, .loading, .error-msg {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.error-msg { color: var(--danger); }

.panel { display: none; }
.panel.active { display: block; }

/* —— Modal —— */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal h3 { margin-bottom: 1rem; padding-right: 2rem; }
.modal dl { display: grid; grid-template-columns: 130px 1fr; gap: 0.45rem 1rem; font-size: 0.85rem; }
.modal dt { color: var(--muted); }
.modal .close {
  float: right;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  padding: 0;
  line-height: 1;
  border: none;
  font-weight: 400;
}

.hidden { display: none !important; }

/* —— AI chat —— */
.ai-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  max-height: 620px;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.ai-msg {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
}

.ai-msg.user { background: var(--surface2); margin-left: 2rem; }
.ai-msg.bot { background: var(--mak-gold-dim); border: 1px solid rgba(201, 162, 39, 0.25); margin-right: 2rem; }
.ai-msg .actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ai-msg .actions button { font-size: 0.8rem; padding: 0.35rem 0.75rem; }
.ai-table { font-size: 0.8rem; margin-top: 0.5rem; }

.bn-match-table { margin-top: 0.75rem; }
.bn-match-table table { width: 100%; font-size: 0.82rem; }
.bn-match-table .ok { color: var(--mak-gold); }
.bn-match-table .miss { color: var(--muted); }
.dashboard-hint {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: rgba(201, 162, 39, 0.12);
  border: 1px solid rgba(201, 162, 39, 0.35);
  font-size: 0.88rem;
}

.home-modules {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 1.25rem 0;
}

.home-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem 1.1rem;
  border-left: 4px solid var(--mak-gold);
}

.home-section-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.home-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--mak-gold), var(--mak-gold-light));
  color: #0a0e17;
  font-size: 1rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.dashboard-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.dashboard-welcome {
  font-size: 1.65rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.dashboard-date {
  font-size: 0.88rem;
  color: var(--muted);
  text-transform: capitalize;
}

.dashboard-meta {
  text-align: right;
  flex-shrink: 0;
}

.dashboard-brand {
  display: block;
  font-size: 0.82rem;
  color: var(--mak-gold);
  font-weight: 600;
}

.dashboard-ver {
  font-size: 0.75rem;
  color: var(--muted);
}

.system-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.85rem 0 1rem;
}

.system-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.85rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
}

.system-chip.ok {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.09);
  color: var(--success);
}

.system-chip.warn {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.system-chip.muted {
  color: var(--muted);
}

.erp-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.erp-workbench-main,
.erp-workbench-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
}

.erp-workbench-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.erp-workbench-head span {
  font-weight: 700;
  color: var(--text);
}

.erp-workbench-head small {
  color: var(--muted);
  font-size: 0.76rem;
}

.erp-command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.55rem;
}

.erp-command {
  min-height: 4.4rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.25rem;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  text-align: left;
}

.erp-command.primary {
  background: rgba(214, 167, 44, 0.14);
  border-color: rgba(214, 167, 44, 0.32);
}

.erp-command:hover {
  filter: none;
  transform: none;
  border-color: var(--accent);
  box-shadow: none;
}

.erp-command strong {
  font-size: 0.94rem;
}

.erp-command span {
  color: var(--muted);
  font-size: 0.78rem;
}

.erp-workbench-side {
  display: flex;
  flex-direction: column;
}

.erp-side-link {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  box-shadow: none;
  text-align: left;
  padding: 0.52rem 0.6rem;
}

.erp-side-link:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--border);
  transform: none;
  box-shadow: none;
  filter: none;
}

.stats-compact {
  margin-bottom: 1.25rem;
}

.stats-compact .stat {
  border-top-width: 2px;
  padding: 0.75rem 0.9rem;
}

.stats-compact .stat .value {
  font-size: 1.2rem;
}

.home-item-admin {
  display: flex !important;
}

.hidden { display: none !important; }

.module-hint,
.dev-only,
.tech-only,
.nav-modules,
#sp-prefix,
.sp-row code,
.badge-write,
#header-banner {
  display: none !important;
}

.panel-admin-only .sp-row code {
  display: inline !important;
}

.sp-row .sp-label {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text);
}

.status-dot-only .status-label {
  display: none;
}

@media (min-width: 901px) {
  .status-label-short {
    max-width: 6rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.home-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.home-section-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.home-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}

.home-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

.home-item:hover {
  border-color: var(--mak-gold);
  background: rgba(201, 162, 39, 0.08);
  transform: translateY(-1px);
}

.home-item-label {
  line-height: 1.3;
}

@media (max-width: 900px) {
  .home-items { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .home-items { grid-template-columns: 1fr; }
}

/* —— Responsive —— */
@media (max-width: 900px) {
  .menu-toggle { display: block; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 40;
  }

  .content { padding: 1rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .pos-layout { grid-template-columns: 1fr; }
}

.section-title {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
}

tr.selected td {
  background: rgba(59, 130, 246, 0.15);
}

.pos-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}

.pos-workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.pos-workspace-head h3,
.pos-cart-head h3 {
  margin: 0;
  font-size: 1rem;
}

.pos-workspace-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.pos-head-actions,
.pos-paybar,
.pos-searchbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pos-head-actions { justify-content: flex-end; }

.pos-searchbar {
  align-items: center;
  margin-bottom: 0.75rem;
}

.pos-searchbar input {
  flex: 1 1 18rem;
  min-width: 0;
}

.pos-status-strip {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.pos-status-strip span,
.pos-cart-head span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.75rem;
}

.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.pos-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid var(--border, #334155);
  border-radius: 8px;
  background: var(--card-bg, #1e293b);
  cursor: pointer;
  text-align: left;
}

.pos-item:hover {
  border-color: var(--accent, #3b82f6);
}

.pos-item-code { font-size: 0.75rem; opacity: 0.8; }
.pos-item-name { font-size: 0.85rem; line-height: 1.2; }
.pos-item-price { font-weight: 700; color: var(--accent, #60a5fa); }

.pos-total {
  margin: 0.75rem 0;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border, #334155);
  font-size: 1.1rem;
}

.pos-cart-stats {
  color: var(--muted);
  font-size: 0.78rem;
  margin: -0.25rem 0 0.55rem;
}

.pos-paybar input[type="number"] {
  width: 7.5rem;
  min-width: 0;
}

.pos-change {
  min-height: 1.4rem;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.pos-change.ok { color: var(--success); }
.pos-change.err { color: var(--danger); }

.pos-auto-alert {
  display: grid;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.pos-auto-alert.ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.pos-auto-alert.warn {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.pos-auto-alert.danger {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.pos-auto-alert strong { color: var(--text); }

.pos-cart-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.pos-right h4 {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
}

.kasa-action-card {
  padding: 0.85rem;
  margin: 0.5rem 0;
}

.kasa-action-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.65rem;
}

.kasa-action-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.kasa-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.kasa-mini-grid span {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  padding: 0.55rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.kasa-mini-grid strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--text);
  font-size: 0.9rem;
}

/* —— PANTHEON navigation —— */
.nav a.nav-top {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.nav-ico {
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.9;
  font-size: 1rem;
}

.pantheon-dash-wrap {
  margin: 1.25rem 0;
}

.pantheon-dash-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mak-gold);
  margin-bottom: 0.75rem;
}

.pantheon-dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.pantheon-dash-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--mak-gold);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.pantheon-dash-tile:hover {
  background: var(--surface2);
  border-color: rgba(201, 162, 39, 0.45);
}

.pantheon-dash-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.pantheon-dash-label {
  font-size: 1rem;
  font-weight: 700;
}

.pantheon-dash-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.pantheon-module {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.pantheon-module-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.pantheon-module-icon {
  font-size: 2rem;
  line-height: 1;
}

.pantheon-module-head h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.pantheon-module-head p {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
}

.pantheon-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

.pantheon-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--mak-gold);
  margin-bottom: 0.75rem;
}

.pantheon-fn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.pantheon-fn-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pantheon-fn-btn:hover {
  background: var(--mak-gold-dim);
  border-color: rgba(201, 162, 39, 0.4);
}

/* —— Мрежен пристап (dashboard) —— */
.network-access {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}

.network-access-title {
  font-size: 0.88rem;
  display: block;
  margin-bottom: 0.25rem;
}

.network-access-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.network-url-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.network-url {
  color: var(--accent);
  font-size: 0.85rem;
  word-break: break-all;
  padding: 0.35rem 0;
}

.erp-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.9rem;
}

.erp-module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.erp-module-open {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1rem;
  background: transparent;
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  text-align: left;
}

.erp-module-open:hover {
  background: var(--surface2);
  box-shadow: none;
  transform: none;
}

.erp-module-open-mark,
.erp-module-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 6px;
  background: var(--mak-gold-dim);
  border: 1px solid rgba(214, 167, 44, 0.28);
  color: var(--mak-gold-light);
  font-weight: 800;
  flex: 0 0 auto;
}

.erp-module-open strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.22rem;
}

.erp-module-open small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.erp-card-actions {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem;
}

.erp-card-actions button,
.erp-link {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  box-shadow: none;
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-weight: 500;
}

.erp-card-actions button:hover,
.erp-link:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}

.erp-module {
  display: grid;
  gap: 1rem;
}

.erp-module-head {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.erp-module-head h2 {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.erp-module-head p {
  color: var(--muted);
  font-size: 0.9rem;
}

.erp-primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.erp-primary-btn {
  border-radius: 6px;
  min-height: 2.35rem;
}

.erp-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.85rem;
}

.erp-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.erp-section h3 {
  font-size: 0.88rem;
  margin-bottom: 0.55rem;
  color: var(--mak-gold-light);
}

.erp-link-list {
  display: grid;
  gap: 0.25rem;
}

.cfma-workspace,
.cfma-window-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.cfma-window-card {
  border: 6px solid #2434ad;
  background: #f5f0b7;
  color: #172033;
  min-height: 250px;
  padding: 0.8rem 1rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
}

.cfma-window-card h3 {
  margin: 0 0 0.55rem;
  color: #25308c;
  font-size: 1.05rem;
  text-align: center;
  font-weight: 800;
}

.cfma-command-list {
  display: grid;
  gap: 0.05rem;
}

.cfma-command {
  display: grid;
  grid-template-columns: 4.2rem 1fr;
  gap: 0.35rem;
  align-items: center;
  width: 100%;
  min-height: 27px;
  padding: 0.2rem 0.35rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #1e2a54;
  text-align: left;
  font-size: 0.92rem;
  line-height: 1.2;
  cursor: pointer;
}

.cfma-command span {
  color: #1c245f;
  text-align: right;
  font-weight: 600;
}

.cfma-command:hover,
.cfma-command:focus {
  background: #283bb5;
  color: white;
  outline: none;
}

.cfma-command:hover span,
.cfma-command:focus span {
  color: white;
}

.cfma-form-window {
  max-width: 980px;
  margin: 0 auto;
  border: 2px solid #2c5aa0;
  border-radius: 0;
  background: #dce7f4;
  color: #182235;
  box-shadow: 9px 9px 0 rgba(28, 46, 92, 0.28);
  padding: 0;
}

.cfma-form-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 30px;
  padding: 0.35rem 0.6rem;
  background: linear-gradient(#2f84c5, #1d5c9c);
  color: white;
  font-size: 0.82rem;
  font-weight: 700;
}

.cfma-form-title strong {
  font-size: 0.78rem;
  color: #eef6ff;
}

.cfma-form-window .vnes-form-head {
  display: none;
}

.cfma-inner-tabs {
  display: flex;
  gap: 0.15rem;
  padding: 0.45rem 0.55rem 0;
  border-bottom: 1px solid #9aaabe;
  background: #dce7f4;
  overflow-x: auto;
}

.cfma-inner-tabs button {
  border: 1px solid #9aaabe;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
  background: #edf2f7;
  color: #1f2937;
  padding: 0.35rem 0.6rem;
  font-size: 0.76rem;
  min-height: 28px;
}

.cfma-inner-tabs button.active {
  background: #ffffff;
  font-weight: 700;
}

.cfma-form-window .vnes-grid {
  grid-template-columns: 130px minmax(190px, 1fr) 120px minmax(150px, 0.8fr);
  gap: 0.45rem 0.75rem;
  padding: 0.85rem 1rem 0.45rem;
}

.cfma-form-window .vnes-grid label {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem;
  color: #263348;
  font-size: 0.76rem;
}

.cfma-form-window .vnes-grid input,
.cfma-form-window .vnes-grid select {
  height: 24px;
  border: 1px solid #93a4bb;
  border-radius: 0;
  background: #f8fbff;
  color: #111827;
  padding: 0.15rem 0.28rem;
  font-size: 0.78rem;
}

.cfma-form-window .vnes-field-hint {
  margin: 0.35rem 1rem 0.65rem;
  color: #42526b;
  font-size: 0.76rem;
}

.cfma-form-window .vnes-actions {
  margin-top: 0;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid #9aaabe;
  background: #cbd9ea;
}

.cfma-form-window .vnes-actions button {
  border-radius: 2px;
  min-height: 30px;
  padding: 0.32rem 0.7rem;
}

.cfma-form-window .vnes-actions #btn-vn-save-art::after,
.cfma-form-window .vnes-actions #btn-vn-save-kup::after {
  content: " (F8)";
}

.cfma-form-window .vnes-actions #btn-vn-next-art::after,
.cfma-form-window .vnes-actions #btn-vn-next-kup::after {
  content: " / Ctrl+N";
}

.cfma-barcode-box {
  margin: 0.2rem 1rem 0.45rem;
  max-width: 360px;
  border: 1px solid #9aaabe;
  background: #eef4fb;
  color: #263348;
  padding: 0.45rem 0.7rem;
  font-size: 0.76rem;
}

.cfma-barcode-box span {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 700;
}

.cfma-barcode-box ol {
  margin-left: 1.2rem;
  min-height: 4.5rem;
}

.work-list {
  display: grid;
  gap: 0.75rem;
}

.work-list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.work-list-head h3 {
  font-size: 1.12rem;
  margin-bottom: 0.22rem;
}

.work-list-head p {
  color: var(--muted);
  font-size: 0.84rem;
}

.work-list-count {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.24rem 0.62rem;
  font-size: 0.76rem;
  font-weight: 600;
}

.work-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.work-list-actions button {
  min-height: 2.25rem;
  border-radius: 6px;
}

.automation-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  padding: 0.55rem;
}

.automation-strip span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  margin-right: 0.25rem;
}

.automation-strip button {
  min-height: 2rem;
  padding: 0.35rem 0.6rem;
}

.automation-cockpit {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin: 0.9rem 0;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.automation-cockpit h3 {
  margin: 0;
  font-size: 1rem;
}

.automation-cockpit p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.automation-cockpit-actions,
.ai-quick-commands {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ai-quick-commands {
  margin-top: 0.65rem;
}

.ai-suggest-box {
  margin-top: 0.85rem;
}

.ai-suggest-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.ai-suggest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
}

.ai-suggest-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-height: 4.4rem;
  border-radius: 8px;
  text-align: left;
}

.ai-suggest-item span {
  color: var(--muted);
  font-size: 0.72rem;
}

.ai-suggest-item strong {
  color: var(--text);
  font-size: 0.86rem;
}

.ai-suggest-item small {
  color: var(--muted);
  font-size: 0.72rem;
}

.article-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.article-summary span {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
  padding: 0.28rem 0.62rem;
  font-size: 0.78rem;
}

.article-summary strong { color: var(--text); }

.partner-filter {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.65rem;
}

.partner-filter input[type="search"] {
  flex: 1 1 260px;
}

.order-filter input[type="search"] {
  flex-basis: 300px;
}

.document-filter input[type="search"] {
  flex-basis: 320px;
}

.stock-filter input[type="search"] {
  flex-basis: 280px;
}

.stock-summary span:last-child {
  background: rgba(34, 197, 94, 0.08);
}

.stock-alert {
  display: grid;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.stock-alert.ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.stock-alert.warn {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.stock-alert.danger {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.stock-alert strong { color: var(--text); }

.stock-alert-actions,
.stock-alert-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.stock-alert-item {
  max-width: 100%;
  text-align: left;
}

.finance-filter input[type="search"] {
  flex-basis: 340px;
}

.finance-summary span:nth-child(4) {
  background: rgba(59, 130, 246, 0.08);
}

.finance-alert {
  display: grid;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.finance-alert.ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.finance-alert.warn {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.finance-alert.danger {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.finance-alert strong { color: var(--text); }

.finance-alert-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.finance-alert-item {
  max-width: 100%;
  text-align: left;
}

.match-suggest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.5rem;
}

.match-suggest-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  border-radius: 8px;
  text-align: left;
  min-height: 4.6rem;
}

.match-suggest-card span,
.match-suggest-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.match-suggest-card strong {
  color: var(--text);
  font-size: 0.86rem;
}

.article-detail {
  display: grid;
  gap: 1rem;
}

.article-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.article-detail-head h3 {
  margin: 0.2rem 0 0;
  font-size: 1.25rem;
}

.article-code {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
}

.article-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem;
}

.article-detail-grid div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  padding: 0.7rem;
}

.article-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}

.article-detail-grid strong {
  color: var(--text);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.partner-next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.order-detail + h4 {
  color: var(--text);
  font-size: 0.95rem;
}

/* —— Tablet & mobile (touch) —— */
@media (max-width: 900px) {
  .header {
    padding: 0.65rem 1rem;
    flex-wrap: wrap;
  }

  .header h2 { font-size: 1rem; max-width: 55vw; }

  .status {
    font-size: 0.72rem;
    gap: 0.35rem;
  }

  .mak-client-select {
    max-width: 7rem;
    font-size: 0.72rem;
  }

  .toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .cfma-titlebar,
  .cfma-menubar,
  .cfma-toolbar {
    overflow-x: auto;
  }

  .cfma-menubar {
    min-height: 38px;
  }

  .cfma-menu > button {
    white-space: nowrap;
    min-height: 38px;
  }

  .cfma-dropdown {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    top: 96px;
    min-width: 0;
  }

  .toolbar input[type="search"],
  .toolbar input[type="text"],
  .toolbar input[type="number"],
  .toolbar select {
    min-width: 0;
    flex: 1 1 100%;
    font-size: 16px;
  }

  .toolbar button,
  button.primary,
  button.secondary,
  .home-item,
  .pantheon-fn-btn,
  .pantheon-dash-tile,
  .pos-item {
    min-height: 44px;
    touch-action: manipulation;
  }

  .pantheon-dash-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .erp-workbench {
    grid-template-columns: 1fr;
  }

  .cfma-workspace,
  .cfma-window-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .cfma-window-card {
    min-height: auto;
    border-width: 4px;
    padding: 0.65rem;
  }

  .cfma-form-window .vnes-grid {
    grid-template-columns: 1fr;
  }

  .cfma-form-window .vnes-grid label {
    grid-template-columns: 1fr;
  }

  .pantheon-fn-grid {
    grid-template-columns: 1fr;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .vnes-grid {
    grid-template-columns: 1fr;
  }

  .pos-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  table {
    font-size: 0.78rem;
  }

  table th, table td {
    padding: 0.45rem 0.4rem;
  }

  .modal {
    width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 2rem);
    margin: 1rem;
  }
}

@media (max-width: 520px) {
  .header-left { gap: 0.5rem; }

  .status #status-label { display: none; }

  .stats { grid-template-columns: 1fr 1fr; }

  .pantheon-dash-grid { grid-template-columns: 1fr; }

  .pos-grid { grid-template-columns: 1fr; }

  .quick-grid { grid-template-columns: 1fr; }

  .cfma-command {
    grid-template-columns: 3.5rem 1fr;
    font-size: 0.84rem;
  }

  .logo h1 { font-size: 0.92rem; }

  .nav a {
    padding: 0.75rem 1.25rem;
    min-height: 44px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .nav a:active,
  .home-item:active,
  .pantheon-fn-btn:active,
  .pos-item:active {
    background: var(--mak-gold-dim);
  }
}

@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .content {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}

/* —— Admin panel —— */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.mak-user-badge {
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--mak-gold);
  white-space: nowrap;
}

.badge-admin { color: #f0c040; }
.badge-operater { color: #7ec8ff; }
.badge-smetkovoditel { color: #8fd89a; }
.badge-readonly { color: var(--muted); }
