:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #6b7890;
  --line: #dce3ee;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --soft: #eef2ff;
  --shadow: 0 10px 30px rgba(22, 31, 52, 0.08);
}

.warehouse-search-wrap {
  position: relative;
  flex: 1 1 420px;
  min-width: 240px;
}

.warehouse-search-wrap > input {
  width: 100%;
}

.warehouse-search-suggestions {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 430px;
  overflow-y: auto;
  border: 1px solid #cbd9e8;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(15, 35, 60, 0.18);
}

.warehouse-suggestion {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  color: #10213a;
  text-decoration: none;
  border-bottom: 1px solid #e5edf5;
}

.warehouse-suggestion:last-child { border-bottom: 0; }
.warehouse-suggestion:hover { background: #eef8f8; }
.warehouse-suggestion span { color: #52677e; font-size: 0.88rem; }
.warehouse-suggestion small,
.search-match-reason { color: #087f7b; font-weight: 700; }
.search-match-reason { display: block; margin-top: 4px; }
.warehouse-suggestion-empty { padding: 16px; color: #52677e; }

.column-filter-head { position: relative; display: block; min-width: max-content; }
.column-filter-title { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.column-filter-button { display: inline-grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: #176c70; cursor: pointer; width: 24px; height: 24px; padding: 3px; }
.column-filter-button:hover,
.column-filter-button:focus-visible { background: #dff4f2; outline: none; }
.column-filter-button svg { width: 16px; height: 16px; fill: currentColor; }
.column-filter-active { display: block; width: fit-content; max-width: 190px; margin-top: 5px; padding: 3px 7px; border-radius: 999px; background: #dff4f2; color: #087f7b; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.column-filter-menu { position: absolute; z-index: 45; top: calc(100% + 7px); left: 0; min-width: 250px; max-width: 340px; padding: 12px; border: 1px solid #cbd9e8; border-radius: 11px; background: #fff; box-shadow: 0 15px 34px rgba(15,35,60,.2); }
.column-filter-menu input,
.column-filter-menu select { width: 100%; margin-bottom: 8px; }
.warehouse-data-row[hidden] { display: none; }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: linear-gradient(135deg, #4f46e5, #14b8a6);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  color: #334155;
  font-weight: 600;
}

.nav-link.active,
.nav-link:hover {
  color: var(--primary-dark);
  background: var(--soft);
  text-decoration: none;
}

.main {
  margin-left: 280px;
  padding: 34px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.entry-head {
  display: grid;
  gap: 10px;
  justify-items: start;
  margin-bottom: 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  color: #344054;
  background: #e9eef7;
  font-weight: 800;
}

.back-link:hover {
  color: var(--primary-dark);
  background: var(--soft);
  text-decoration: none;
}

.head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  margin-bottom: 16px;
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metrics.compact {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  padding: 20px;
}

.metric span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

.metric strong {
  font-size: 25px;
}

.panel {
  margin-bottom: 24px;
  padding: 22px;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(360px, 0.9fr);
  gap: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.recent-records {
  align-self: start;
  padding: 0;
  overflow: hidden;
}

.recent-records summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 0 22px;
  cursor: pointer;
  font-size: 20px;
  font-weight: 800;
  list-style: none;
  user-select: none;
}

.recent-records summary::-webkit-details-marker {
  display: none;
}

.recent-records summary:hover {
  background: #f8faff;
}

.recent-records-arrow {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 0.18s ease, color 0.18s ease;
}

.recent-records[open] .recent-records-arrow {
  color: var(--primary);
  transform: rotate(-90deg);
}

.recent-records-table {
  overflow-x: auto;
  padding: 0 22px 22px;
  border-top: 1px solid var(--line);
}

.recent-records-table table {
  margin-top: 14px;
}

.ai-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 14px;
}

.ai-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fbff;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.ai-card strong,
.ai-card span,
.ai-card em {
  display: block;
}

.ai-card em {
  color: #d92d20;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.ai-card span {
  margin-top: 8px;
  color: var(--text);
  font-weight: 700;
}

.ai-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2,
.section-head .hint {
  margin-bottom: 0;
}

.inline-filter select {
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.ai-scope-form {
  align-items: flex-end;
}

.copy-box {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
  color: var(--text);
  font: 13px/1.55 Consolas, "Courier New", monospace;
}

.report-rendered {
  line-height: 1.6;
}

.report-rendered h3,
.report-rendered h4,
.report-rendered h5 {
  margin: 18px 0 10px;
}

.report-rendered ul {
  padding-left: 22px;
}

.risk-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef2ff;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.risk-critical,
.risk-high {
  background: #fee2e2;
  color: #b91c1c;
}

.risk-medium {
  background: #fef3c7;
  color: #92400e;
}

.risk-low {
  background: #dcfce7;
  color: #166534;
}

.ai-metadata-panel .detail-grid strong {
  line-height: 1.45;
}

.report-table {
  overflow-x: auto;
  margin: 14px 0;
}

.manual-ai-box {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.manual-ai-box summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 260px 1fr;
  align-items: center;
  gap: 26px;
  min-height: 300px;
}

.donut {
  width: 240px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}

.donut::after {
  content: "";
  position: absolute;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--panel);
}

.donut span {
  position: relative;
  z-index: 1;
  color: var(--text);
  font-size: 28px;
  font-weight: 900;
}

.donut-svg {
  width: 240px;
  aspect-ratio: 1;
  overflow: visible;
}

.donut-track,
.donut-segment {
  fill: none;
  stroke-width: 56;
}

.donut-track {
  stroke: #e2e8f0;
}

.donut-segment {
  cursor: pointer;
  transition: stroke-width 0.18s ease, opacity 0.18s ease;
}

.donut-segment:hover {
  stroke-width: 62;
  opacity: 0.88;
}

.donut-hole {
  fill: var(--panel);
}

.donut-svg text {
  fill: var(--text);
  font-size: 28px;
  font-weight: 900;
}

.chart-legend {
  display: grid;
  gap: 12px;
}

.chart-legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.chart-legend-row:hover {
  color: var(--primary-dark);
  text-decoration: none;
}

.chart-legend-row span:last-child {
  color: var(--muted);
  font-weight: 700;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.risk-list {
  display: grid;
  gap: 14px;
}

.risk-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(160px, 260px) 54px;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfdff;
}

.risk-row:hover {
  border-color: rgba(79, 70, 229, 0.45);
  background: var(--soft);
  text-decoration: none;
}

.risk-row strong,
.risk-row span {
  display: block;
}

.risk-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.risk-row b {
  text-align: right;
}

.risk-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.risk-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.risk-low {
  background: #10b981;
}

.risk-mid {
  background: #f59e0b;
}

.risk-high {
  background: #ef4444;
}

.form-panel {
  max-width: 720px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
}

.action-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfdff;
}

.action-card:hover {
  border-color: rgba(79, 70, 229, 0.45);
  background: var(--soft);
  text-decoration: none;
}

.action-card strong {
  font-size: 17px;
}

.action-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.field-group {
  display: grid;
  gap: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}

.detail-grid div {
  display: grid;
  gap: 7px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.detail-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.detail-grid strong {
  font-size: 16px;
}

.detail-wide {
  grid-column: 1 / -1;
}

.notice {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1e3a8a;
  background: #eff6ff;
  font-weight: 700;
}

.plain-text {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 20px;
  align-items: start;
}

.grid.two {
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
}

.wide {
  overflow-x: auto;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.button.muted {
  color: #344054;
  background: #e9eef7;
}

.button.muted:hover {
  background: #dde5f2;
}

.button.danger {
  color: white;
  background: #dc2626;
}

.button.danger:hover {
  background: #991b1b;
}

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.form {
  display: grid;
  gap: 14px;
}

.calc-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.calc-box div {
  display: grid;
  gap: 5px;
}

.calc-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.calc-box strong {
  color: #0f172a;
  font-size: 18px;
}

.inline-form {
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: #40506a;
  font-size: 14px;
  font-weight: 650;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.checkbox-line input {
  width: auto;
  min-height: auto;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: white;
  font: inherit;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(79, 70, 229, 0.2);
  border-color: var(--primary);
}

input[readonly] {
  color: #1e3a8a;
  background: #eef4ff;
  font-weight: 800;
}

.mini-form {
  margin: 0;
}

.mini-form select {
  min-height: 34px;
  padding: 5px 8px;
}

.rate-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rate-form input {
  width: 110px;
  min-height: 34px;
  padding: 5px 8px;
}

.offer-edit-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.offer-edit-form select {
  width: 88px;
  min-height: 34px;
  padding: 5px 8px;
}

.offer-edit-form input {
  width: 110px;
  min-height: 34px;
  padding: 5px 8px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.offer-workflow-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--primary);
  background: var(--soft);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #42526b;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:has(a[href]) {
  cursor: pointer;
}

tbody tr:has(a[href]):hover {
  background: #f8fbff;
}

.empty,
.hint {
  color: var(--muted);
}

.hint {
  margin: -6px 0 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  width: min(920px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  padding: 24px;
}

.wide-modal {
  width: min(1120px, 96vw);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #f8fafc;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.summary-grid strong {
  font-size: 20px;
}

.modal-table {
  overflow-x: auto;
}

.price-up {
  color: #dc2626;
  font-weight: 800;
}

.price-down {
  color: #16a34a;
  font-weight: 800;
}

.price-same {
  color: #64748b;
  font-weight: 800;
}

.focus-panel {
  border-color: #8b7cf6;
  background: #fbfaff;
}

@media (max-width: 1100px) {
  .dashboard-charts,
  .donut-wrap {
    grid-template-columns: 1fr;
  }

  .donut-wrap {
    justify-items: center;
  }

  .risk-row {
    grid-template-columns: 1fr;
  }

  .risk-row b {
    text-align: left;
  }

  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
    padding: 22px;
  }

  .metrics,
  .metrics.compact,
  .grid.two,
  .action-grid,
  .detail-grid,
  .inline-form,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-user {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 5px;
  font-size: 13px;
}

.sidebar-user strong,
.sidebar-user span {
  overflow-wrap: anywhere;
}

.sidebar-user span {
  color: var(--muted);
}

.sidebar-user a {
  margin-top: 5px;
  color: var(--primary);
  font-weight: 800;
}

.local-mode {
  color: #166534 !important;
  font-weight: 800;
}

.auth-body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f2f5fa;
}

.auth-card {
  width: min(460px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.12);
}

.auth-card h1 {
  margin: 28px 0 10px;
}

.auth-brand {
  margin: 0;
}

.auth-note,
.auth-error {
  margin: 18px 0;
  padding: 12px 14px;
  border-radius: 8px;
}

.auth-note {
  color: #1e3a8a;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.auth-error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.google-button {
  display: block;
  margin-top: 20px;
  text-align: center;
}

.access-message {
  max-width: 680px;
}

.user-access-list {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.user-access-card {
  display: block;
  padding: 0;
  overflow: hidden;
}

.user-access-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.user-access-summary::-webkit-details-marker {
  display: none;
}

.user-access-summary::marker {
  content: "";
}

.user-access-arrow {
  color: var(--muted);
  font-size: 30px;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 160ms ease;
}

.user-access-card[open] .user-access-arrow {
  transform: rotate(-90deg);
}

.user-access-card[open] .user-access-summary {
  border-bottom: 1px solid var(--border);
}

.user-access-body {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.user-access-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.user-access-head h2,
.user-access-head p {
  margin: 0;
}

.user-access-head p {
  margin-top: 5px;
  color: var(--muted);
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(210px, 1fr));
  gap: 12px;
}

.permission-grid label,
.user-status {
  display: grid;
  gap: 6px;
}

.permission-grid span,
.user-status span {
  font-size: 13px;
  font-weight: 800;
  color: #42526b;
}

.status-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-badge.owner,
.status-badge.active {
  color: #166534;
  background: #dcfce7;
}

.status-badge.pending {
  color: #92400e;
  background: #fef3c7;
}

.status-badge.blocked {
  color: #991b1b;
  background: #fee2e2;
}

.price-change,
.catalog-history-mark {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.price-change.up {
  color: #b42318;
}

.price-change.down {
  color: #087a68;
}

.price-change.neutral,
.catalog-history-mark {
  color: var(--muted);
}

.catalog-history-mark.included {
  color: #087a68;
}

@media (max-width: 900px) {
  .permission-grid {
    grid-template-columns: 1fr;
  }
}

/* Lovable reference visual system: presentation only, business logic unchanged. */
:root {
  --bg: #f3f7fa;
  --panel: #ffffff;
  --text: #142033;
  --muted: #6c7b8f;
  --line: #dbe4ea;
  --primary: #0f9f96;
  --primary-dark: #0b7f79;
  --soft: #e6f7f5;
  --sidebar: #142136;
  --sidebar-muted: #9aa8ba;
  --shadow: 0 2px 8px rgba(20, 32, 51, 0.06);
}

body {
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

a {
  color: #0b8f87;
}

.sidebar {
  width: 248px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 12px;
  border-right: 0;
  background: var(--sidebar);
  color: #f8fafc;
}

.brand {
  gap: 10px;
  margin-bottom: 18px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  background: var(--primary);
  font-size: 12px;
}

.brand strong {
  color: #fff;
  font-size: 15px;
}

.brand span {
  color: var(--sidebar-muted);
  font-size: 11px;
  line-height: 1.35;
}

nav {
  gap: 3px;
}

.nav-link {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 6px;
  color: #c5cfdb;
  font-size: 13px;
  font-weight: 650;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.nav-link.active {
  color: #fff;
  background: var(--primary);
}

.sidebar-user {
  margin-top: auto;
  padding: 16px 8px 4px;
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-user strong,
.sidebar-user a {
  color: #fff;
}

.sidebar-user span {
  color: var(--sidebar-muted);
}

.local-mode {
  color: #75ddd5 !important;
}

.main {
  margin-left: 248px;
  padding: 26px 28px 44px;
}

.page-head {
  min-height: 54px;
  margin: -26px -28px 24px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.page-head h1 {
  font-size: 23px;
}

.entry-head {
  margin-bottom: 20px;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.eyebrow {
  color: #728096;
  font-size: 11px;
}

.metrics,
.metrics.compact {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.panel,
.modal-card,
.auth-card {
  border-color: var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 104px;
  padding: 18px;
}

.metric span {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  color: #111c2e;
  font-size: 23px;
}

.panel {
  margin-bottom: 18px;
  padding: 20px;
}

.dashboard-charts,
.grid-2 {
  gap: 18px;
}

.action-card,
.risk-row,
.ai-card,
.calc-box,
.chart-empty {
  background: #f8fbfc;
}

.action-card:hover,
.risk-row:hover,
.ai-card:hover {
  border-color: rgba(15, 159, 150, 0.5);
  background: var(--soft);
}

.button {
  min-height: 40px;
  border-radius: 6px;
  background: var(--primary);
  font-size: 13px;
}

.button:hover {
  background: var(--primary-dark);
}

.button.muted,
.back-link {
  color: #344054;
  background: #eaf0f4;
}

.button.muted:hover,
.back-link:hover {
  color: #18343a;
  background: #dce9e9;
}

input,
select,
textarea,
.inline-filter select {
  min-height: 40px;
  border-color: #cfdbe3;
  border-radius: 6px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 159, 150, 0.13);
}

table {
  font-size: 13px;
}

th,
td {
  padding: 11px 10px;
}

th {
  color: #566579;
  background: #f7fafb;
  font-size: 11px;
  letter-spacing: 0.01em;
}

.warehouse-balance-table thead,
.panel:has(.search-form) + .panel.wide thead {
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 5px 10px rgba(23, 32, 51, 0.08);
}

.warehouse-balance-table thead th,
.panel:has(.search-form) + .panel.wide thead th {
  color: #26364d;
  background: #f7fafb;
  box-shadow: inset 0 -1px 0 #cfd9e6;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.table-filter-row th {
  padding-top: 8px;
  padding-bottom: 8px;
  background: #ffffff;
}

.panel:has(.search-form) + .panel.wide {
  overflow: visible;
}

tbody tr:has(a[href]):hover {
  background: #eef9f8;
}

.notice {
  border-color: #a8ded9;
  color: #155e59;
  background: #ecfdfb;
}

.donut-track {
  stroke: #e7eef1;
}

.risk-low {
  background: #16a394;
}

.risk-row:hover,
.chart-legend-row:hover {
  color: var(--primary-dark);
}

.focus-panel {
  border-color: rgba(15, 159, 150, 0.5);
  background: #f4fcfb;
}

.analysis-is-loading {
  overflow: hidden;
}

.analysis-loading-overlay {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 28, 46, 0.58);
}

.analysis-loading-card {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid #cfe1e5;
  border-radius: 8px;
  color: #111c2e;
  text-align: center;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 28, 46, 0.28);
}

.analysis-loading-card h2 {
  margin: 18px 0 8px;
  font-size: 21px;
}

.analysis-loading-card p,
.analysis-loading-card strong,
.analysis-loading-card span {
  display: block;
}

.analysis-loading-card p {
  margin: 0 0 14px;
  color: #526176;
}

.analysis-loading-card strong {
  color: #123f43;
}

.analysis-loading-card span {
  margin-top: 8px;
  color: #738195;
  font-size: 13px;
}

.analysis-spinner {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border: 5px solid #dceceb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: analysis-spin 0.8s linear infinite;
}

@keyframes analysis-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .sidebar {
    position: static;
    width: auto;
    max-height: none;
  }

  .brand {
    margin-bottom: 10px;
  }

  nav {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .main {
    margin-left: 0;
    padding: 20px;
  }

  .page-head {
    margin: -20px -20px 20px;
    padding: 12px 20px;
  }
}

.mobile-bottom-nav,
.mobile-menu-backdrop {
  display: none;
}

@media (max-width: 640px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

  .sidebar {
    position: fixed; z-index: 110; inset: 0 auto 0 0;
    width: min(86vw, 330px); max-height: none; padding: 18px 12px 90px;
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 18px 0 50px rgba(7,18,34,.28);
  }
  .mobile-menu-open .sidebar { transform: translateX(0); }
  .mobile-menu-backdrop {
    position: fixed; z-index: 105; inset: 0; border: 0;
    background: rgba(8,18,32,.5);
  }
  .mobile-menu-open .mobile-menu-backdrop { display: block; }

  .mobile-bottom-nav {
    position: fixed; z-index: 100; right: 0; bottom: 0; left: 0;
    display: grid; grid-template-columns: repeat(4,1fr); gap: 0;
    padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: rgba(255,255,255,.97);
    box-shadow: 0 -8px 24px rgba(20,32,51,.1);
  }
  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    min-width: 0; min-height: 52px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px; padding: 3px;
    border: 0; border-radius: 8px; color: #66758a; background: transparent;
    font: inherit; font-size: 10px; font-weight: 750;
  }
  .mobile-bottom-nav span { font-size: 23px; line-height: 1; }
  .mobile-bottom-nav .active,
  .mobile-bottom-nav a:active,
  .mobile-bottom-nav button:active { color: var(--primary-dark); background: var(--soft); }

  nav {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 14px;
  }

  .page-head {
    align-items: flex-start;
    margin: -14px -14px 16px;
    padding: 14px;
  }

  .head-actions {
    justify-content: flex-start;
  }

  .metric,
  .panel {
    padding: 16px;
  }

  .page-head h1 { font-size: 21px; }
  .head-actions, .search-form { width: 100%; }
  .head-actions .button { flex: 1 1 140px; }
  .search-form, .warehouse-search-wrap { min-width: 0; }
  .search-form input, .search-form .warehouse-search-wrap { flex: 1 1 100%; width: 100%; }

  #warehouse-table,
  #warehouse-table tbody,
  #warehouse-table tr,
  #warehouse-table td,
  .stock-movement-row,
  .stock-movement-row td { display: block; width: 100%; }

  .panel.wide table:has(.stock-movement-row) thead { display: none; }

  #warehouse-table thead {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f7fafb;
  }
  #warehouse-table thead tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  #warehouse-table thead th { display: none; }
  #warehouse-table thead th:has(.column-filter-head) {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
  }
  #warehouse-table .column-filter-head { min-width: 0; }
  #warehouse-table .column-filter-title {
    width: 100%;
    justify-content: space-between;
    padding: 9px 10px;
    border: 1px solid #cfdbe3;
    border-radius: 8px;
    color: #344054;
    background: #fff;
  }
  #warehouse-table .column-filter-menu {
    position: fixed;
    z-index: 140;
    top: auto;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    min-width: 0;
    max-width: none;
  }

  #warehouse-table .warehouse-data-row,
  .stock-movement-row {
    margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: 10px; background: #fff; box-shadow: var(--shadow);
  }
  #warehouse-table td,
  .stock-movement-row td {
    min-height: 34px; padding: 8px 0 8px 43%; position: relative;
    border-bottom: 1px solid #edf2f5; text-align: left; overflow-wrap: anywhere;
  }
  #warehouse-table td:last-child, .stock-movement-row td:last-child { border-bottom: 0; }
  #warehouse-table td::before, .stock-movement-row td::before {
    content: attr(data-label); position: absolute; top: 8px; left: 0; width: 39%;
    color: var(--muted); font-size: 11px; font-weight: 750;
  }
  #warehouse-table td[data-label="Ապրանք"],
  .stock-movement-row td[data-label="Ապրանք"] { padding-left: 0; font-size: 15px; font-weight: 750; }
  #warehouse-table td[data-label="Ապրանք"]::before,
  .stock-movement-row td[data-label="Ապրանք"]::before { display: none; }
}
/* AI jobs stay visible while the separate local worker is processing them. */
.ai-job-waiting {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 10px;
}

.ai-job-spinner {
  width: 46px;
  height: 46px;
  border: 5px solid #dce5ef;
  border-top-color: #0f9f95;
  border-radius: 50%;
  animation: ai-job-spin .8s linear infinite;
}

@keyframes ai-job-spin {
  to { transform: rotate(360deg); }
}

.health-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.health-check {
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: #fff;
}

.health-check-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.health-check h3 { margin: 0; font-size: 16px; }
.health-check p { margin: 12px 0 6px; color: #40536a; }
.health-check small { color: var(--muted); }
.health-healthy { border-left-color: #15966f; }
.health-warning { border-left-color: #d88b0a; }
.health-critical { border-left-color: #dc2626; }
.health-neutral { border-left-color: #94a3b8; }

.health-status,
.log-level {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.health-healthy .health-status, .log-info { color: #116149; background: #dcf7ec; }
.health-warning .health-status, .log-warning { color: #8a5400; background: #fff0c9; }
.health-critical .health-status, .log-error, .log-critical { color: #a31515; background: #fee2e2; }
.health-neutral .health-status { color: #536277; background: #e9eef4; }

.overall-health {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: #fff;
}

.overall-health span { color: var(--muted); font-size: 12px; }
.technical-error-list { margin: 10px 0 0; padding-left: 20px; }
.technical-error-list li { margin: 7px 0; color: #40536a; }
.compact-head { margin: 0 0 14px; padding: 0; border: 0; background: transparent; }

@media (max-width: 640px) {
  .health-check-grid { grid-template-columns: 1fr; }
  .overall-health { width: 100%; justify-content: space-between; }
}
