/* Stilul Kassio, în culorile logo-ului House Decor.
   Culorile se schimbă doar aici, în variabilele de mai jos. */
:root {
  --slate: #3a4149;        /* gri-ardezie închis */
  --slate-dark: #2b3036;
  --accent: #f5a524;       /* galben-portocaliu (pensula) */
  --accent-dark: #d98a0b;
  --bg: #f4f5f6;
  --text: #22262b;
  --muted: #6b7280;
  --danger: #b42318;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Logo simplu: pătrat cu „pensulă” portocalie */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0 55%, var(--slate) 55%);
}

/* Ecranul de autentificare */
.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--slate);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: var(--radius);
  border-top: 6px solid var(--accent);
  padding: 32px 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.login-card h1 { margin: 0; font-size: 28px; color: var(--slate); }
.subtitle { color: var(--muted); margin: 6px 0 24px; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid #cfd4da;
  border-radius: 8px;
}
input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.btn-primary {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-dark);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-dark); }

.alert {
  background: #fdecea;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

/* Pagina de început */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--slate);
  color: #fff;
  border-bottom: 4px solid var(--accent);
}
.brand-name { font-weight: 700; font-size: 20px; }
.btn-link {
  background: none; border: 1px solid var(--accent); color: var(--accent);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.page { padding: 24px 16px; max-width: 960px; margin: 0 auto; }

/* Meniul de comutare între conturi */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.org-switch select {
  max-width: 180px;
  padding: 6px 10px;
  font-size: 15px;
  color: #fff;
  background: var(--slate-dark);
  border: 1px solid var(--accent);
  border-radius: 8px;
}
.org-info { font-size: 17px; }
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-dark);
  background: var(--accent);
  border-radius: 999px;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}
[hidden] { display: none !important; }

/* Meniul principal */
.mainnav {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid #e3e6ea;
  overflow-x: auto;
}
.mainnav a {
  padding: 12px 14px;
  color: var(--slate);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.mainnav a.active { border-bottom-color: var(--accent); }

/* Elemente comune */
a { color: var(--slate); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.link-muted { color: var(--muted); font-size: 15px; }
.btn-inline { width: auto; display: inline-block; margin-top: 0; padding: 10px 18px; text-decoration: none; }
.btn-secondary {
  padding: 9px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
  color: #fff; background: var(--slate); border: 0; border-radius: 8px;
}
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.flash { padding: 10px 14px; border-radius: 8px; background: #e7f6ec; color: #14532d; }
.flash-error { background: #fdecea; color: var(--danger); }
.empty { padding: 24px; text-align: center; background: #fff; border-radius: var(--radius); color: var(--muted); }

/* Filtre */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; }
.filters input[type="search"] { flex: 1 1 260px; }
.filters input, .filters select { padding: 9px 10px; font-size: 15px; border: 1px solid #cfd4da; border-radius: 8px; background: #fff; }

/* Tabel */
.table-wrap { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid #e3e6ea; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; padding: 10px 12px; background: #f0f2f4; color: var(--muted); font-size: 13px; font-weight: 600; }
.table td { padding: 10px 12px; border-top: 1px solid #eef0f2; vertical-align: top; }
.client-name { font-weight: 600; text-decoration: none; display: block; }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--pill); background: color-mix(in srgb, var(--pill) 14%, white);
}
.tag { display: inline-block; margin: 0 4px 4px 0; padding: 1px 8px; font-size: 12px; background: #eef0f2; border-radius: 6px; }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 16px 0 4px; }

/* Pe telefon tabelul devine o listă de carduri */
@media (max-width: 700px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 10px 12px; border-top: 1px solid #eef0f2; }
  .table td { border: 0; padding: 2px 0; }
  .table td:empty { display: none; }
  .table td:not(:first-child)::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
}

/* Formulare */
.card { background: #fff; border-radius: var(--radius); border: 1px solid #e3e6ea; padding: 16px; margin: 16px 0; }
.card h2 { margin: 0 0 12px; font-size: 18px; color: var(--slate); }
.card h3 { margin: 18px 0 8px; font-size: 16px; color: var(--slate); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.field { margin-bottom: 12px; }
.field label, .field .label { display: block; font-weight: 600; margin: 0 0 6px; font-size: 14px; }
.field.required > label::after { content: " *"; color: var(--danger); }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%; padding: 10px; font-size: 16px; font-family: inherit;
  border: 1px solid #cfd4da; border-radius: 8px; background: #fff;
}
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.help { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.error { display: block; color: var(--danger); font-size: 13px; margin-top: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.row-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px;
  padding: 10px 0; border-top: 1px dashed #e3e6ea; align-items: end;
}
.row-form .delete { margin-bottom: 14px; color: var(--danger); }
.form-actions { display: flex; gap: 16px; align-items: center; margin: 8px 0 32px; }
.btn-danger {
  padding: 9px 16px; font-size: 15px; cursor: pointer;
  color: var(--danger); background: #fff; border: 1px solid var(--danger); border-radius: 8px;
}
.head-actions { display: flex; gap: 8px; align-items: center; }
.btn-link-plain { text-decoration: none; display: inline-block; }
.num, .table th.num { text-align: right; white-space: nowrap; }

/* Arborele de categorii */
.tree { list-style: none; margin: 0; padding: 0; }
.tree li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  padding: 10px 12px 10px calc(12px + var(--level) * 22px);
  border-top: 1px solid #eef0f2;
}
.tree li:first-child { border-top: 0; }
.tree-name { font-weight: 600; }
.tree-branch { color: var(--muted); margin-right: 6px; }
.tree-actions { margin-left: auto; display: flex; gap: 12px; }

/* Produse */
.thumb-cell { width: 52px; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.thumb-empty { background: #eef0f2; }
tr.inactive td { opacity: 0.55; }
.price-grid { margin-bottom: 6px; }
.price-grid input { width: 110px; padding: 8px; font-size: 15px; text-align: right; border: 1px solid #cfd4da; border-radius: 8px; }
.price-grid input:disabled { background: #f4f5f6; color: var(--text); }
.input-error { border-color: var(--danger) !important; }
.images { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.image-item { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.image-item img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid #e3e6ea; }

/* Comenzi: căutarea produselor, pozițiile și totalurile */
.product-search { position: relative; margin-bottom: 12px; }
.product-search input { width: 100%; padding: 12px; font-size: 16px; border: 2px solid var(--accent); border-radius: 8px; }
.search-results {
  position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px 0;
  list-style: none; background: #fff; border: 1px solid #cfd4da; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); max-height: 320px; overflow-y: auto;
}
.search-results li { display: flex; gap: 8px; align-items: baseline; padding: 10px 12px; cursor: pointer; }
.search-results li:hover, .search-results li:focus { background: #fff6e6; outline: none; }
.result-price { margin-left: auto; font-weight: 600; white-space: nowrap; }
.search-results li.new-product { border-top: 1px solid #eef0f2; color: var(--accent-dark); font-weight: 600; }
.quick-product {
  margin: 0 0 16px; padding: 14px 16px; background: #fffaf0;
  border: 1px solid var(--accent); border-radius: var(--radius);
}
.quick-product h3 { margin-top: 0; }
/* Bara de comenzi a documentelor (rândul 1) și antetul (rândul 2), ca în MoySklad */
.doc-toolbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: center;
  margin: -4px 0 12px; padding-bottom: 10px; border-bottom: 1px solid #e3e6ea;
}
.tb-left { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tb-save { background: #6bbf2a; color: #fff; }
.tb-save:hover { background: #57a51f; }
.tb-nav { display: inline-flex; align-items: center; gap: 4px; margin: 0 4px; }
.tb-arrow {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 34px;
  border: 1px solid #cfd4da; border-radius: 6px; background: #fff; text-decoration: none; font-size: 18px; color: var(--slate);
}
.tb-arrow.disabled { opacity: 0.35; }
.tb-menus { display: inline-flex; flex-wrap: wrap; border: 1px solid #cfd4da; border-radius: 8px; background: #fff; }
.tb-menu { position: relative; }
.tb-menu + .tb-menu { border-left: 1px solid #cfd4da; }
.tb-menu summary { list-style: none; cursor: pointer; padding: 8px 12px; font-size: 15px; white-space: nowrap; }
.tb-menu summary::-webkit-details-marker { display: none; }
.tb-menu[open] summary { background: #f0f2f4; }
.tb-dropdown {
  position: absolute; z-index: 20; left: 0; top: 100%; min-width: 240px; margin-top: 2px; padding: 4px 0;
  background: #fff; border: 1px solid #cfd4da; border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.tb-dropdown form { margin: 0; }
.tb-dropdown hr { border: 0; border-top: 1px solid #eef0f2; margin: 4px 0; }
.tb-item {
  display: block; width: 100%; padding: 8px 14px; text-align: left; font-size: 15px; color: var(--text);
  background: none; border: 0; text-decoration: none; cursor: pointer; font-family: inherit;
}
.tb-item:hover { background: #fff6e6; }
.tb-item.disabled { color: #a3a9b1; cursor: default; }
.tb-right { text-align: right; }
.doc-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 8px; }
.doc-head h1 { margin: 0; }
.doc-head .field { margin: 0; }
.doc-head .field label { display: none; }
.doc-head .field input, .doc-head .field select { width: auto; min-width: 210px; font-size: 18px; }
.paid-button {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid #cfd4da;
  border-radius: 8px; background: #fff; text-decoration: none; color: var(--text); font-size: 15px;
}
.paid-button .check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #cfd4da; display: inline-block; }
.paid-button.is-paid .check { background: #16a34a; border-color: #16a34a; position: relative; }
.paid-button.is-paid .check::after { content: "✓"; color: #fff; font-size: 12px; position: absolute; left: 2px; top: -1px; }
.client-balance { font-size: 14px; margin: -4px 0 10px; }

/* Liste în stilul MoySklad: sub-meniu, bară de unelte, filtre, tabel compact */
.subnav {
  display: flex; flex-wrap: wrap; gap: 4px 20px; margin: -8px 0 12px; padding-bottom: 6px;
  border-bottom: 1px solid #e3e6ea; overflow-x: auto;
}
.subnav a, .subnav span { padding: 6px 0; font-size: 15px; white-space: nowrap; text-decoration: none; color: var(--slate); border-bottom: 3px solid transparent; }
.subnav a.active { font-weight: 700; border-bottom-color: var(--accent); }
.subnav .soon { color: #a3a9b1; cursor: help; }
.list-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 10px; }
.list-toolbar h1 { margin: 0 8px 0 0; font-size: 24px; }
.list-toolbar input[type="search"] { flex: 0 1 300px; padding: 9px 10px; font-size: 15px; border: 1px solid #cfd4da; border-radius: 8px; }
.filter-panel {
  flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: end;
  padding: 12px; background: #fff; border: 1px solid #e3e6ea; border-radius: var(--radius);
}
.filter-panel label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filter-panel select, .filter-panel input { padding: 8px; font-size: 15px; border: 1px solid #cfd4da; border-radius: 8px; background: #fff; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.bulk-bar select { padding: 6px 8px; border: 1px solid #cfd4da; border-radius: 8px; background: #fff; }
.bulk-bar button:disabled { opacity: 0.45; cursor: default; }
.dense-table { font-size: 14px; }
.dense-table th { padding: 8px 10px; }
.dense-table td { padding: 7px 10px; }
.dense-table tbody tr:hover td { background: #fffaf0; }
.dense-table tr.selected td { background: #fff3d6; }
.dense-table tfoot td { padding: 9px 10px; font-weight: 700; background: #f0f2f4; border-top: 2px solid #d5d9de; }
.c-check { width: 32px; }
.c-comment { color: var(--muted); max-width: 220px; }
.nowrap { white-space: nowrap; }
.doc-link { font-weight: 700; }

@media (max-width: 700px) {
  .dense-table tfoot { display: block; }
  .dense-table tfoot tr { display: block; }
  .dense-table tfoot td { display: inline-block; border: 0; }
  .c-check { width: auto; }
}

/* Producție: cardurile de lucru (gândite pentru telefon) */
.work-section { margin-bottom: 24px; }
.work-section h2 { font-size: 18px; color: var(--slate); }
.work-card {
  background: #fff; border: 1px solid #e3e6ea; border-left: 5px solid var(--accent);
  border-radius: var(--radius); padding: 14px; margin: 10px 0;
}
.work-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.work-product { font-size: 17px; }
.work-qty { font-size: 18px; font-weight: 700; white-space: nowrap; }
.work-meta { color: var(--muted); font-size: 14px; margin: 4px 0 8px; }
.steps { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; padding: 0; margin: 8px 0 12px; counter-reset: step; }
.steps li { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #eef0f2; color: var(--muted); }
.steps li.done { background: #dcfce7; color: #166534; }
.steps li.done::before { content: "✓ "; }
.steps li.current { background: var(--accent); color: var(--slate-dark); font-weight: 700; }
.work-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-work { width: 100%; margin: 0; font-size: 17px; padding: 14px; }
.work-actions form { flex: 1 1 260px; }
.history { margin: -4px 0 12px; font-size: 14px; }
.history summary { cursor: pointer; color: var(--muted); }
.production-line { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.progress { flex: 0 0 120px; height: 8px; background: #eef0f2; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.pill.prod-open { --pill: #3b82f6; }
.pill.prod-done { --pill: #16a34a; }
.pill.prod-cancelled { --pill: #b42318; }

/* Plăți: „Achitat” cu bara verde */
.paid { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 80px; }
.paid-bar { display: block; width: 100%; height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; }
.paid-bar span { display: block; height: 100%; background: #16a34a; }
.paid-full { color: #166534; }
.pay-box .paid { width: 100%; max-width: 360px; align-items: stretch; }
.pay-box .paid { font-size: 0; }
.pay-box .paid-bar { height: 8px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.inline-form input { padding: 8px; font-size: 15px; border: 1px solid #cfd4da; border-radius: 8px; }

/* Curier */
.cod-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1 1 260px; }
.cod-form input { width: 120px; padding: 10px; font-size: 16px; border: 1px solid #cfd4da; border-radius: 8px; }

/* Stoc */
.stock-ok { color: #16a34a; font-weight: 700; }
.stock-short { color: var(--danger); font-weight: 700; }
.line-shipped { display: block; }
.plain-list { list-style: none; padding: 0; margin: 0 0 8px; }
.plain-list li { padding: 6px 0; border-top: 1px solid #eef0f2; }
tr.below-min td { background: #fff7ed; }
tr.below-min td:nth-child(3) { color: var(--danger); font-weight: 700; }
.flash-warning { background: #fff7ed; color: #9a3412; }
.flash-warning a { color: inherit; font-weight: 600; }
.pill.status-draft { --pill: #6b7280; }
.pill.status-posted { --pill: #16a34a; }
.pill.status-cancelled { --pill: #b42318; }

.share-link { display: flex; gap: 8px; flex-wrap: wrap; }
.share-link input { flex: 1 1 260px; padding: 9px 10px; font-size: 14px; border: 1px solid #cfd4da; border-radius: 8px; background: #f4f5f6; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 10px 0 4px; }
.share-actions a { font-weight: 600; }
.logo-preview { max-height: 80px; max-width: 240px; display: block; margin-bottom: 10px; }
.btn-link-muted { background: none; border: 0; color: var(--muted); font-size: 15px; text-decoration: underline; cursor: pointer; }
.lines-wrap, .card .table-wrap { overflow-x: auto; }
.lines-table input[type="text"], .lines-table input[type="number"] {
  width: 90px; padding: 6px 8px; font-size: 15px; text-align: right; border: 1px solid #cfd4da; border-radius: 6px;
}
.lines-table td { vertical-align: middle; }
.lines-table .line-name { font-weight: 600; }
.lines-table .line-code { display: block; }
.lines-table tr.deleted td { opacity: 0.4; text-decoration: line-through; }
.lines-table tr.has-error td { background: #fff5f5; }
.line-delete .delete { margin: 0; font-weight: 700; }
.totals { display: grid; justify-content: end; gap: 4px; margin-top: 14px; text-align: right; }
.totals div { display: flex; justify-content: space-between; gap: 32px; }
.totals .grand { font-size: 20px; color: var(--slate); border-top: 2px solid var(--accent); padding-top: 6px; margin-top: 4px; }

@media (max-width: 700px) {
  .lines-table thead { display: table-header-group; }
  .lines-table, .lines-table tbody { display: table; width: max-content; min-width: 100%; }
  .lines-table tr { display: table-row; padding: 0; }
  .lines-table td { display: table-cell; width: auto; padding: 6px; border-top: 1px solid #eef0f2; }
  .lines-table td::before { content: none !important; }
  .lines-table td:empty { display: table-cell; }
  .totals { justify-content: stretch; }
}

@media (max-width: 700px) {
  .thumb-cell { display: none !important; }
  .price-grid .table thead { display: table-header-group; }
  .price-grid .table, .price-grid .table tbody { display: table; }
  .price-grid .table tr { display: table-row; }
  .price-grid .table td { display: table-cell; width: auto; padding: 6px; }
  .price-grid .table td::before { content: none; }
  .price-grid input { width: 80px; }
}
.flash-error a { color: inherit; font-weight: 600; }

/* Importul: tabelul în care se corectează rândurile cu probleme. */
.edit-table input[type="text"] { min-width: 120px; padding: 4px 6px; font-size: 14px; }
.edit-table .row-error td { background: #fdf2f2; }
.edit-table .center { text-align: center; }
.edit-table .problem-cell { min-width: 220px; }
