:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-elevated: #0f141b;
  --surface: #121821;
  --surface-strong: #171f2a;
  --surface-muted: #1b2430;
  --surface-hover: #202b38;
  --text: #eef3f8;
  --text-soft: #c4ced8;
  --muted: #8b98a8;
  --line: #263241;
  --line-strong: #344253;
  --green: #4da778;
  --green-soft: rgba(77, 167, 120, 0.16);
  --blue: #6aa7d8;
  --blue-soft: rgba(106, 167, 216, 0.14);
  --amber: #d8a24d;
  --amber-soft: rgba(216, 162, 77, 0.16);
  --red: #e07171;
  --red-soft: rgba(224, 113, 113, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  --field-bg: #0d131a;
  --placeholder: #667384;
  --header-bg: rgba(15, 20, 27, 0.92);
  --sidebar-bg: #0d131a;
  --body-glow: rgba(77, 167, 120, 0.08);
  --toolbar-bg: rgba(18, 24, 33, 0.72);
  --subtle-fill: rgba(255, 255, 255, 0.02);
  --row-fill: rgba(255, 255, 255, 0.018);
  --row-hover: rgba(255, 255, 255, 0.025);
  --active-text: #dceeff;
  --badge-text: #b9dcff;
  --warning-text: #f1c982;
  --primary-text: #b9f0d1;
  --danger-text: #ffb8b8;
}

body.light-mode {
  color-scheme: light;
  --bg: #eef2f6;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-strong: #f9fbfd;
  --surface-muted: #f1f5f9;
  --surface-hover: #e8eef5;
  --text: #111827;
  --text-soft: #243244;
  --muted: #5f6f82;
  --line: #d5dde8;
  --line-strong: #b9c5d4;
  --green: #27764e;
  --green-soft: rgba(39, 118, 78, 0.1);
  --blue: #236a9a;
  --blue-soft: rgba(35, 106, 154, 0.1);
  --amber: #96610f;
  --amber-soft: rgba(150, 97, 15, 0.11);
  --red: #b93636;
  --red-soft: rgba(185, 54, 54, 0.09);
  --shadow: 0 12px 30px rgba(20, 32, 48, 0.08);
  --field-bg: #ffffff;
  --placeholder: #8a95a3;
  --header-bg: rgba(255, 255, 255, 0.94);
  --sidebar-bg: #ffffff;
  --body-glow: rgba(35, 106, 154, 0.08);
  --toolbar-bg: rgba(255, 255, 255, 0.78);
  --subtle-fill: rgba(36, 50, 68, 0.035);
  --row-fill: #ffffff;
  --row-hover: rgba(35, 106, 154, 0.055);
  --active-text: #164f78;
  --badge-text: #175b86;
  --warning-text: #83540d;
  --primary-text: #1e6543;
  --danger-text: #9d2c2c;
}

* {
  box-sizing: border-box;
}

body {
  background:
    radial-gradient(circle at top left, var(--body-glow), transparent 30vw),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

.hidden {
  display: none !important;
}

button,
select,
input {
  font: inherit;
}

button {
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

input,
select {
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 34px;
  outline: none;
  padding: 7px 9px;
}

input::placeholder {
  color: var(--placeholder);
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(106, 167, 216, 0.12);
}

.login-screen {
  align-items: center;
  background: var(--bg);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: linear-gradient(180deg, var(--surface-strong), var(--surface));
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-width: 380px;
  padding: 28px;
  width: 100%;
}

.login-card img {
  height: 58px;
  justify-self: start;
  object-fit: contain;
}

.login-card h1 {
  font-size: 22px;
  margin: 0;
}

.login-card label,
.form-grid label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}

.app-header {
  align-items: center;
  backdrop-filter: blur(18px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 74px;
  padding: 14px 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header h1,
.toolbar h2 {
  color: var(--text);
  font-size: 21px;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 2px 0 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.role-switcher {
  align-items: center;
  color: var(--text-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.role-switcher label {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: calc(100vh - 74px);
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 10px;
  position: sticky;
  top: 74px;
  height: calc(100vh - 74px);
  overflow: auto;
}

.sidebar button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text-soft);
  cursor: pointer;
  min-height: 34px;
  padding: 8px 10px;
  text-align: left;
}

.sidebar button:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.sidebar button.active {
  background: var(--blue-soft);
  border-color: color-mix(in srgb, var(--blue) 26%, transparent);
  color: var(--active-text);
  font-weight: 850;
}

.content {
  min-width: 0;
  padding: 18px;
}

.toolbar {
  align-items: center;
  background: var(--toolbar-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 14px;
}

.view {
  display: none;
  overflow-x: auto;
}

.active-view {
  display: block;
}

.metric-grid,
.panel-grid {
  display: grid;
  gap: 12px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 12px;
}

.panel-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.metric,
.panel,
.form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  color: var(--text);
  display: block;
  font-size: 25px;
  line-height: 1.15;
  margin-top: 7px;
}

.panel {
  padding: 14px;
}

.panel h3,
.form-panel h3 {
  color: var(--text);
  font-size: 15px;
  margin: 0 0 10px;
}

.muted-text {
  color: var(--muted);
  margin: 0 0 10px;
}

.stock-detail-panel {
  margin-top: 12px;
}

.planego-missing-price,
.stock-equivalent-warning {
  color: #ff8f8f;
  font-weight: 800;
}

.form-panel {
  margin-bottom: 12px;
  padding: 14px;
}

.edit-panel {
  border-color: rgba(77, 167, 120, 0.55);
  box-shadow: 0 0 0 1px rgba(77, 167, 120, 0.08), var(--shadow);
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.search-field {
  display: block;
  position: relative;
}

.search-field input {
  padding-right: 38px;
  width: 100%;
}

.search-icon-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--blue);
  cursor: pointer;
  display: inline-flex;
  font-size: 15px;
  height: calc(100% - 2px);
  justify-content: center;
  min-height: 30px;
  position: absolute;
  right: 1px;
  top: 1px;
  width: 34px;
}

.search-icon-button:hover {
  background: var(--surface-hover);
}

.unit-checks {
  align-items: center;
  background: var(--subtle-fill);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 9px;
}

.unit-checks strong {
  color: var(--text-soft);
  font-size: 12px;
}

.unit-checks label,
.inline-check {
  align-items: center;
  color: var(--text-soft);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}

.unit-checks input,
.inline-check input {
  accent-color: var(--green);
  min-height: auto;
}

.form-actions {
  align-items: end;
  display: flex;
}

.list {
  display: grid;
  gap: 8px;
}

.list-row {
  align-items: center;
  background: var(--row-fill);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 9px 10px;
}

.badge {
  background: var(--blue-soft);
  border: 1px solid color-mix(in srgb, var(--blue) 22%, transparent);
  border-radius: 999px;
  color: var(--badge-text);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  padding: 4px 7px;
}

.badge.warning {
  background: var(--amber-soft);
  border-color: color-mix(in srgb, var(--amber) 24%, transparent);
  color: var(--warning-text);
}

.data-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-collapse: separate;
  border-radius: var(--radius);
  border-spacing: 0;
  box-shadow: var(--shadow);
  min-width: 760px;
  width: 100%;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

.data-table td {
  color: var(--text-soft);
  font-size: 13px;
}

.data-table tr:hover td {
  background: var(--row-hover);
  color: var(--text);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table input,
.data-table select {
  min-height: 30px;
}

.action-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.primary-action,
.secondary-action,
.danger {
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  min-height: 34px;
  padding: 7px 11px;
}

.primary-action {
  background: var(--green-soft);
  border: 1px solid color-mix(in srgb, var(--green) 35%, transparent);
  color: var(--primary-text);
}

.primary-action:hover {
  background: color-mix(in srgb, var(--green) 18%, transparent);
  border-color: color-mix(in srgb, var(--green) 52%, transparent);
}

.danger {
  background: var(--red-soft);
  border: 1px solid color-mix(in srgb, var(--red) 28%, transparent);
  color: var(--danger-text);
}

.secondary-action {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  color: var(--text-soft);
}

.secondary-action:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.danger:hover {
  background: color-mix(in srgb, var(--red) 16%, transparent);
  border-color: color-mix(in srgb, var(--red) 46%, transparent);
}

.primary-action:disabled,
.secondary-action:disabled,
.danger:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

body.light-mode .primary-action {
  border-color: rgba(47, 139, 93, 0.28);
  color: #1f6f49;
}

body.light-mode .primary-action:hover {
  background: rgba(47, 139, 93, 0.18);
  border-color: rgba(47, 139, 93, 0.44);
}

body.light-mode .danger {
  border-color: rgba(191, 66, 66, 0.24);
  color: #a83232;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 900px) {
  .app-header,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    position: static;
  }

  .content {
    padding: 12px;
  }

  .form-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}
