:root {
  --bg: #f7f4f1;
  --card: #ffffff;
  --border: #e4ddd6;
  --text: #2b2b2b;
  --muted: #6b6560;
  --primary: #d0643b;
  --primary-hover: #b8532f;
  --primary-soft: #fceee8;
  --accent-dark: #1f1f1f;
  --sidebar-w: 280px;
  --topbar-h: 56px;
  --font-body: "Open Sans", "Segoe UI", system-ui, sans-serif;
  --font-head: "Oswald", "Open Sans", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: #b42318; }

.screen { min-height: 100vh; }
.login-card { max-width: 380px; margin: 10vh auto; padding: 2rem 2rem 1.75rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(43, 35, 28, 0.08);
}
.brand-login {
  margin: 0 0 0.25rem;
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
label { display: block; margin: 1rem 0 0.35rem; font-size: 0.85rem; font-weight: 600; }
.password-wrap {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
}
.password-wrap input { flex: 1; min-width: 0; }
.password-toggle {
  flex-shrink: 0;
  padding: 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.password-toggle:hover { border-color: var(--primary); color: var(--primary); }
input, textarea, select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}
button { font: inherit; cursor: pointer; border-radius: 8px; border: none; }
.btn-primary {
  padding: 0.55rem 1.1rem;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  padding: 0.55rem 1.1rem;
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--border);
  font-weight: 600;
}
.btn-secondary:hover { background: var(--primary-soft); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
#login-form .btn-primary { width: 100%; margin-top: 1.25rem; }

.topbar {
  display: flex;
  align-items: stretch;
  min-height: var(--topbar-h);
  background: var(--accent-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.brand-mark {
  flex-shrink: 0;
  align-self: center;
  padding: 0 0.75rem;
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
}
.brand-mark:hover { color: #f0c4b0; }
.topbar .icon-btn {
  flex-shrink: 0;
  align-self: center;
  margin-left: 0.35rem;
  color: #fff;
  background: transparent;
  padding: 0.4rem 0.55rem;
  font-size: 1.2rem;
}
.topbar .text-btn {
  flex-shrink: 0;
  align-self: center;
  margin-right: 0.65rem;
  color: #f0c4b0;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
}
.topbar .text-btn:hover { color: #fff; }

.section-nav {
  flex: 1;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.section-nav::-webkit-scrollbar { display: none; }
.section-tab {
  flex-shrink: 0;
  padding: 0 1rem;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: rgba(255,255,255,.72);
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.section-tab:hover { color: #fff; background: rgba(255,255,255,.06); }
.section-tab.active {
  color: #fff;
  border-bottom-color: var(--primary);
  background: rgba(208, 100, 59, 0.2);
}

.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-heading {
  padding: 0.85rem 1rem 0.4rem;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.catalog-link {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border-radius: 0;
  padding: 0.5rem 1rem;
  font-size: 0.94rem;
  border-left: 3px solid transparent;
}
.catalog-link:hover, .catalog-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-left-color: var(--primary);
}
.catalog-link .count { float: right; color: var(--muted); font-size: 0.8rem; }

.main { flex: 1; padding: 1rem 1.25rem; overflow: auto; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; }
.catalog-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 120px;
}
.toolbar h2 {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  font-family: var(--font-head);
  font-size: 1.35rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.toolbar .btn-delete-catalog {
  flex-shrink: 0;
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  opacity: 0.75;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}
.toolbar .btn-delete-catalog:hover {
  opacity: 1;
  color: #b42318;
}
.toolbar-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}
.toolbar-sort select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  box-shadow: 0 2px 12px rgba(43, 35, 28, 0.04);
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
td.cell-num, th.cell-num { text-align: right; font-variant-numeric: tabular-nums; }
td.cell-title { font-weight: 600; color: var(--text); max-width: 320px; }
td.cell-plain { color: var(--text); }
.catalog-warehouse tbody tr { cursor: pointer; }
.catalog-warehouse tbody tr:hover td { background: #f5f0eb; }
.op-badge-in { background: #d0fbbf; color: #1a4d12; }
.op-badge-out { background: #fceee8; color: #8b3a20; }
.warehouse-op-bar { position: relative; z-index: 2; }
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-selling { background: #d0fbbf; color: #1a4d12; }
.status-assembly { background: #d3e3ff; color: #1a3a6b; }
.status-emergency { background: #f9c2c2; color: #6b1a1a; }
th {
  background: #faf7f4;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
tbody tr:hover td { background: #fdfbf9; cursor: pointer; }
.pager { display: flex; gap: 1rem; align-items: center; margin-top: 0.75rem; flex-wrap: wrap; }

.wh-lines { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.5rem; }

#record-dialog {
  border: none;
  border-radius: 12px;
  max-width: 640px;
  width: calc(100% - 2rem);
  padding: 0;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  overflow: visible;
}
#record-form {
  display: flex;
  flex-direction: column;
  max-height: min(92vh, 720px);
}
#record-form .dialog-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--card);
}
#record-dialog:not([open]) {
  display: none;
}
.wh-line {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fdfbf9;
}
.wh-line-main { flex: 1; min-width: 0; }
.wh-line-delete {
  flex-shrink: 0;
  align-self: stretch;
  min-width: 2.25rem;
  border: 1px solid #f5c2c2;
  border-radius: 8px;
  background: #fff;
  color: #b42318;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.35rem 0.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wh-line-delete:hover { background: #fef3f2; }
.wh-line-delete[disabled],
.wh-line-delete.wh-line-delete--hidden {
  visibility: hidden;
  pointer-events: none;
}
.wh-line-product { width: 100%; margin-bottom: 0.5rem; }
.wh-line-qty-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.25rem;
}
.wh-line-qty-label {
  font-weight: 600;
  padding-top: 0.45rem;
  min-width: 3.25rem;
}
.wh-line-qty {
  width: 5rem;
  text-align: right;
  padding: 0.4rem 0.5rem;
}
.wh-line-balance { font-size: 0.85rem; color: var(--muted); margin: 0.35rem 0 0; }
.wh-line-applicability { margin-top: 0.65rem; }
.wh-line-applicability .field-label { display: block; margin-bottom: 0.35rem; font-weight: 600; }
.btn-text-add {
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
  margin-bottom: 0.5rem;
}
.btn-text-add:hover { text-decoration: underline; }
.wh-global-hint { margin-top: 0; }

#warehouse-op-dialog {
  border: none;
  border-radius: 12px;
  max-width: 720px;
  width: calc(100% - 2rem);
  padding: 0;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
}
#record-dialog::backdrop,
#warehouse-op-dialog::backdrop { background: rgba(31, 31, 31, 0.45); }
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #faf7f4;
}
.dialog-header h3 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 1.1rem;
  text-transform: uppercase;
}
.record-fields {
  padding: 1rem 1.25rem;
  flex: 1;
  min-height: 0;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overflow-x: clip;
}
.record-relations {
  padding: 0 1.25rem 1rem;
  border-top: 1px dashed var(--border);
  margin-top: 0;
}
.record-relations h4 {
  margin: 0.75rem 0 0.5rem;
  font-family: var(--font-head);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.component-products-field .object-multiselect {
  max-height: 320px;
}
.relation-list { list-style: none; margin: 0; padding: 0; }
.relation-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.field-row { margin-bottom: 1rem; }
.field-row > label:first-child { display: block; margin: 0 0 0.35rem; font-weight: 600; color: var(--text); }
.field-row label { font-weight: 600; color: var(--text); }
.role-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.15rem;
}
.role-checkbox-group .field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  line-height: 1.35;
}
.role-checkbox {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  margin: 0 !important;
  font-weight: 500 !important;
  cursor: pointer;
}
.role-checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}
#record-form .dialog-footer .btn-danger {
  margin-right: auto;
}
.field-readonly {
  padding: 0.55rem 0.65rem;
  background: #faf7f4;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}
.link-chip {
  display: inline-block;
  margin: 0.15rem 0.35rem 0.15rem 0;
  padding: 0.2rem 0.55rem;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #f0d4c8;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-chip:hover { background: #f9ddd3; }
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #faf7f4;
}
.warehouse-op-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.btn-op {
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: 8px;
  color: #fff;
}
.btn-op-sell { background: var(--primary); }
.btn-op-sell:hover { background: var(--primary-hover); }
.warehouse-op-bar .btn-op.btn-op-return {
  background-color: #4a5159;
  color: #fff;
}
.warehouse-op-bar .btn-op.btn-op-return:hover { background-color: #383e45; }
.btn-op-in { background: #3d7a4a; }
.btn-op-in:hover { background: #32653d; }
.btn-op-adj { background: #6b5b8a; }
.btn-op-adj:hover { background: #574a72; }
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 200px;
}
.btn-qty {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--border);
  font-weight: 700;
}
.btn-qty:hover { background: var(--primary-soft); }
#wh-qty {
  width: 5rem;
  text-align: center;
  flex: 0 0 auto;
}
.warehouse-op-body {
  padding: 1rem 1.25rem;
  max-height: min(70vh, 520px);
  overflow-y: auto;
}
.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.chip-select {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip-select label {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
}
.chip-select label:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.chip-select input { margin-right: 0.35rem; width: auto; }
.brand-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 160px;
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.brand-grid label {
  margin: 0;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  background: #faf7f4;
}
.brand-grid label:has(input:checked) {
  background: #d3e3ff;
  border-color: #6b8fc7;
}
.brand-grid input { display: none; }
.buyer-chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.buyer-1 { background: #d3e3ff; color: #1a3a6b; }
.buyer-2 { background: #eeffb8; color: #3a4d12; }
.buyer-3 { background: #dfe0e0; color: #333; }
.buyer-4 { background: #f9c2c2; color: #6b2020; }
.wh-balance-preview {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  background: #faf7f4;
  border-radius: 8px;
  font-size: 0.9rem;
}

.notif-wrap { position: relative; align-self: center; margin-right: 0.25rem; }
.notif-btn { position: relative; color: #fff; font-size: 1.1rem; }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
}
.notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(360px, 92vw);
  max-height: 70vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  z-index: 50;
}
.notif-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: #faf7f4;
}
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  cursor: pointer;
}
.notif-list li:hover { background: #fdfbf9; }
.notif-list li.unread { background: #fff8f5; font-weight: 600; }
.notif-list .notif-time { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: var(--muted); font-weight: 400; }

.toast-stack {
  position: fixed;
  left: 0;
  right: 0;
  top: max(1rem, env(safe-area-inset-top));
  bottom: auto;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  padding: 0 1rem;
}
.toast {
  pointer-events: auto;
  max-width: 420px;
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--accent-dark);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  font-size: 0.92rem;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.record-form-error {
  margin: 0 1.25rem 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #fdecec;
  border: 1px solid #f5c2c2;
  color: #9b1c1c;
  font-size: 0.92rem;
  font-weight: 600;
}
.record-form-error.hidden {
  display: none;
}

.object-multiselect {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: #fff;
}
.object-multiselect-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.object-check {
  display: block;
  margin: 0.35rem 0;
  font-weight: 400;
  font-size: 0.88rem;
  cursor: pointer;
}
.object-check input { width: auto; margin-right: 0.35rem; }

.report-total-card {
  padding: 1rem 1.25rem 1.25rem;
  margin-bottom: 1rem;
}
.report-total-qty {
  margin: 0.25rem 0 0.5rem;
  font-size: 2.75rem;
  font-weight: 700;
  font-family: var(--font-head);
  line-height: 1.1;
}
.report-table-card {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.report-table-card h3,
.report-total-card h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-head);
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--muted);
}
.report-period-table { width: 100%; border-collapse: collapse; }
.report-period-table th,
.report-period-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.report-filter-applicability select { width: 100%; }
.report-brand-chips { flex-wrap: wrap; margin-top: 0.35rem; }
.report-brand-chips label { margin-right: 0.65rem; }

.reports-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.report-filter-field { margin: 0; flex: 1 1 160px; min-width: 0; }
.report-filter-field label { display: block; margin-bottom: 0.35rem; }
.report-filter-product { flex: 2 1 220px; }

.unit-cost-card { padding: 0; overflow: hidden; }
.unit-cost-table { width: 100%; border-collapse: collapse; }
.unit-cost-table th,
.unit-cost-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.unit-cost-table .unit-cost-total { font-weight: 600; }
.unit-cost-toggle {
  margin-right: 0.35rem;
  padding: 0 0.25rem;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}
.unit-cost-product-link {
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.unit-cost-product-link:hover {
  color: var(--accent, #d0643b);
  text-decoration: underline;
}
.unit-cost-detail td { background: var(--bg-soft, #f8f9fb); padding: 0.5rem 1rem 0.75rem 2rem; }
.unit-cost-components-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.unit-cost-components-table th,
.unit-cost-components-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.report-filter-product select { width: 100%; }
.reports-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.report-chart-card { padding: 1rem 1.25rem 1.5rem; }
.report-chart-card h3 {
  margin: 0 0 1rem;
  font-family: var(--font-head);
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--muted);
}
.report-chart-card canvas { max-height: 320px; }
.report-period-chart-wrap {
  margin: 0 0 1.25rem;
  padding: 0 0.25rem;
}
.report-period-chart-wrap canvas {
  width: 100% !important;
  max-height: 280px;
}

/* Операции: выбор строк и удаление (как Bpium) */
#records-table.catalog-warehouse .col-select {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
  padding: 0.35rem 0.25rem;
}
#records-table.catalog-warehouse .col-select input {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}
#records-table.catalog-warehouse .col-actions {
  width: 2.5rem;
  text-align: center;
  vertical-align: middle;
  padding: 0.25rem;
}
#records-table.catalog-warehouse .btn-row-delete {
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  opacity: 0.75;
}
#records-table.catalog-warehouse tr:hover .btn-row-delete {
  opacity: 1;
}
#records-table.catalog-warehouse .btn-row-delete:hover {
  color: #b42318;
}

/* Операции с товарами: список + карточка (как Bpium) */
.catalog-view--ops .catalog-master-detail {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: calc(100vh - var(--topbar-h) - 10rem);
}
.catalog-view--ops .catalog-list-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.catalog-view--ops .catalog-list-pane .table-wrap {
  flex: 1;
  max-height: none;
}
.catalog-view--ops.catalog-view--split .catalog-list-pane .table-wrap {
  border-radius: 10px 0 0 10px;
}
.op-detail-panel {
  display: flex;
  flex-direction: column;
  width: 0;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 10px 10px 0;
  box-shadow: -4px 0 20px rgba(43, 35, 28, 0.06);
  transition: width 0.2s ease;
}
.catalog-view--split .op-detail-panel {
  width: min(440px, 44vw);
}
.op-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.op-detail-header h3 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 600;
}
.op-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.op-detail-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-danger {
  padding: 0.55rem 1.1rem;
  background: #fff;
  color: #b42318;
  border: 1px solid #f5c2c2;
  font-weight: 600;
  margin-right: auto;
}
.btn-danger:hover { background: #fef3f2; }
.op-section { margin-bottom: 1.25rem; }
.op-section h4 {
  margin: 0 0 0.65rem;
  font-family: var(--font-head);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.op-detail-panel .chip-select { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.op-detail-panel .chip-select label {
  margin: 0;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.op-detail-panel .chip-select label:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.op-detail-panel .chip-select input { width: auto; margin-right: 0.25rem; }
.op-goods-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.op-goods-table th,
.op-goods-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.op-goods-table th { color: var(--muted); font-weight: 600; font-size: 0.75rem; }
.op-goods-table th.col-qty,
.op-goods-table td.col-qty {
  width: 4.5rem;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
.op-goods-table .col-product { vertical-align: middle; }
.op-goods-table .col-brand { vertical-align: middle; }
.op-readonly {
  padding: 0.5rem 0;
  font-size: 0.95rem;
}
#records-body tr { cursor: pointer; }
#records-body tr.row-selected {
  background: var(--primary-soft);
}
#records-body tr.row-selected td { border-bottom-color: #e8d5cc; }
.catalog-view:not(.catalog-view--ops) .op-detail-panel { display: none !important; }

.tool-photo-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
}
.cell-photo { width: 64px; padding: 0.35rem 0.5rem !important; vertical-align: middle; }
.cell-photo-empty { color: var(--muted); font-size: 0.85rem; }

.file-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}
.file-gallery-item {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
  max-width: 160px;
}
.file-gallery-item img {
  display: block;
  width: 140px;
  height: 140px;
  object-fit: cover;
}
.file-gallery-note { width: 100%; margin: 0.25rem 0 0; font-size: 0.8rem; }
.file-doc-link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
  max-width: 100%;
  word-break: break-word;
}
.file-doc-link:hover { background: var(--primary-soft); }

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.photo-lightbox.hidden { display: none !important; }
.photo-lightbox-img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 4px;
}
.photo-lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 768px) {
  .topbar {
    padding-left: max(0.35rem, env(safe-area-inset-left));
    padding-right: max(0.35rem, env(safe-area-inset-right));
  }
  .brand-mark { display: none; }
  .section-tab { padding: 0 0.65rem; font-size: 0.82rem; min-height: 44px; }
  .topbar .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .btn-primary,
  .btn-secondary,
  .toolbar .btn-primary {
    min-height: 44px;
    padding: 0.65rem 1rem;
  }
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    bottom: 0;
    z-index: 25;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .layout.sidebar-open::after {
    content: "";
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0,0,0,.3);
    z-index: 24;
  }
  .catalog-view--split .op-detail-panel {
    position: fixed;
    right: 0;
    top: var(--topbar-h);
    bottom: 0;
    width: min(100%, 400px);
    z-index: 30;
    border-radius: 0;
  }
  .take-order-datetime-row {
    grid-template-columns: 1fr;
  }
  #records-table.catalog-service-wide {
    min-width: 720px;
  }
  .pwa-install-hint {
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
  }
  .pwa-install-btn {
    color: var(--primary);
    font-weight: 700;
    text-decoration: underline;
    padding: 0;
    background: none;
    border: none;
    font-size: inherit;
  }
}

.pwa-install-hint {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--primary-soft);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.4;
}
.pwa-install-hint span { flex: 1; }

.module-planned-view {
  margin: 1.25rem;
  max-width: 36rem;
}
.module-planned-view h2 {
  margin-top: 0;
}
.module-planned-hint {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 1rem;
}
.section-tab[title] {
  cursor: pointer;
}

#records-table.catalog-warehouse .col-num {
  width: 3rem;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.85rem;
}

#records-table.catalog-service-wide {
  min-width: 960px;
}
#records-table.catalog-service-wide th,
#records-table.catalog-service-wide td {
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#records-table.catalog-service-wide td.cell-plain {
  white-space: normal;
  max-width: 280px;
}
#records-table.catalog-service-wide .col-actions,
#records-table .col-actions {
  position: sticky;
  right: 0;
  z-index: 2;
  width: 2.75rem;
  min-width: 2.75rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  background: var(--card);
  box-shadow: -6px 0 8px -6px rgba(0, 0, 0, 0.12);
}
#records-table.catalog-service-wide thead .col-actions,
#records-table thead .col-actions {
  z-index: 3;
}

.schedule-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-left: auto;
}
.field-inline {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.schedule-hint {
  margin: 0 0 1rem;
  padding: 0 0.25rem;
}
.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.schedule-day-title {
  margin: 1rem 0 0.35rem;
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.schedule-day-title:first-child {
  margin-top: 0;
}
.schedule-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.schedule-card:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.schedule-card strong {
  font-weight: 600;
}
.take-order-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: min(440px, 96vw);
  width: calc(100% - 2rem);
  background: var(--card);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  overflow: visible;
}
#take-order-dialog:not([open]) {
  display: none;
}
#take-order-dialog[open] {
  display: block;
  margin: auto;
}
#take-order-dialog::backdrop {
  background: rgba(31, 31, 31, 0.45);
}
.take-order-dialog .dialog-header,
.take-order-dialog .field-row,
.take-order-dialog .take-order-hint,
.take-order-dialog .take-order-suggested,
.take-order-dialog .take-order-datetime-row,
.take-order-dialog .dialog-footer {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.take-order-datetime-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.take-order-datetime-row .field-row {
  margin-bottom: 0;
}
.take-order-datetime-row .field-row > label:first-child {
  margin-top: 0;
}
.take-order-dialog .field-row {
  margin-bottom: 0.5rem;
}
.take-order-dialog .dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.75rem;
  padding-bottom: 1rem;
  background: var(--card);
}
.take-order-dialog #take-order-date,
.take-order-dialog #take-order-time {
  width: 100%;
}
.take-order-client {
  margin: 0 1.25rem 0.75rem;
  font-weight: 600;
}
.take-order-suggested {
  margin: -0.35rem 1.25rem 0.75rem;
  font-size: 0.88rem;
}
.take-order-dialog #btn-take-order-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.col-take {
  width: 8.5rem;
  white-space: nowrap;
}
.btn-take-order {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
}

.payroll-chart-wrap {
  margin: 0 0 1rem;
  padding: 1rem 1.25rem;
}
.payroll-chart-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
}
.payroll-chart-total {
  margin: 0.5rem 0 0;
}
#chart-payroll-monthly {
  max-height: 240px;
}

.client-search-wrap {
  position: relative;
  width: 100%;
  z-index: 20;
}
.client-search-input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.client-search-list {
  position: absolute;
  z-index: 500;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}
.client-search-list:not(.hidden) {
  display: block;
}
.client-search-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border: none;
  background: #fff;
  font: inherit;
  cursor: pointer;
  color: var(--text);
}
.client-search-item-main {
  font-weight: 600;
  font-size: 0.9rem;
}
.client-search-item-sub {
  margin-top: 0.15rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}
.client-search-item:hover {
  background: var(--primary-soft);
}
.client-card-preview {
  margin-top: 0.35rem;
  font-size: 0.85rem;
}
.file-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.file-upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.file-upload-input {
  margin-top: 0.5rem;
  width: 100%;
}
#btn-submit-service.hidden,
#btn-settle-billing.hidden {
  display: none;
}
