:root {
  --bg: #f6f7f4;
  --text: #18181b;
  --muted: #52525b;
  --line: #d4d4d8;
  --brand: #b4232b;
  --brand-dark: #86181f;
  --brand-bright: #dc3038;
  --brand-soft: #fff1f1;
  --green: #16845b;
  --green-dark: #0d6645;
  --shadow: 0 10px 30px rgba(76, 18, 22, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  max-width: 900px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.login-card,
.result-card,
.empty {
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: #fff;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 22px;
}

h1 {
  margin: 0;
  font-size: 24px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

input:focus,
button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.primary,
.secondary {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 13px;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  width: 100%;
  margin-top: 16px;
  border: 0;
  background: var(--brand);
  color: #fff;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.error {
  margin-top: 12px;
  border-radius: 6px;
  background: #fef2f2;
  padding: 10px 12px;
  color: #b91c1c;
  font-size: 14px;
}

.top {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.search {
  padding: 20px 0;
}

.search input {
  height: 50px;
  font-size: 16px;
}

.results {
  display: grid;
  gap: 12px;
}

.result-card {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 16px;
}

.sku {
  font-size: 18px;
  font-weight: 700;
}

.name {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 9px;
  color: #71717a;
  font-size: 12px;
}

.stock {
  min-width: 120px;
  align-self: flex-start;
  border: 1px solid #047857;
  border-radius: 6px;
  background: #ecfdf5;
  padding: 11px 14px;
  text-align: center;
}

.stock-label {
  color: var(--green);
  font-size: 12px;
}

.stock-value {
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 22px;
  font-weight: 800;
}

.empty {
  padding: 22px;
  color: #71717a;
}

@media (max-width: 640px) {
  .top,
  .result-card {
    flex-direction: column;
    align-items: stretch;
  }

  .stock {
    width: 100%;
  }
}

.portal-shell .top {
  margin-bottom: 12px;
}

.nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 13px;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.nav-button.active {
  border-color: var(--green);
  background: #ecfdf5;
  color: var(--green-dark);
}

.page-head {
  padding: 20px 0 0;
}

.page-head h2,
.user-panel h3,
.admin-card h3 {
  margin: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 16px;
  align-items: start;
  padding-top: 18px;
}

.admin-card {
  max-width: none;
}

.user-panel {
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid #e4e4e7;
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 12px;
  font: inherit;
}

select:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.form-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.danger {
  color: #b91c1c;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.hint {
  margin-top: 6px;
  color: #71717a;
  font-size: 12px;
  line-height: 1.4;
}

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

.success {
  margin-top: 12px;
  border-radius: 6px;
  background: #ecfdf5;
  padding: 10px 12px;
  color: var(--green-dark);
  font-size: 14px;
}

.order-card {
  margin-top: 18px;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.order-items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  border-top: 1px solid #e4e4e7;
  padding-top: 16px;
}

.order-items-head h3 {
  margin: 0;
}

.order-items {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.order-item-row {
  display: grid;
  grid-template-columns: 1fr 1.7fr 100px 120px 100px 110px 42px;
  gap: 8px;
  align-items: end;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  padding: 10px;
  background: #fafafa;
}

.field.compact {
  margin-top: 0;
}

.line-subtotal {
  display: grid;
  gap: 7px;
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
}

.line-subtotal strong {
  display: flex;
  align-items: center;
  height: 42px;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  background: #fff;
  padding: 0 10px;
  color: var(--text);
}

.order-total {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  border-top: 1px solid #e4e4e7;
  padding-top: 14px;
  color: var(--muted);
}

.order-total strong {
  color: var(--green-dark);
  font-size: 24px;
}

.orders-panel {
  margin-top: 18px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid #fde68a;
  border-radius: 999px;
  background: #fffbeb;
  padding: 0 10px;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
}

.portal-number {
  display: grid;
  gap: 6px;
}

.order-actions {
  margin-top: 2px;
}

.status-badge.submitted {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.status-badge.cancelled {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(24, 24, 27, 0.45);
  padding: 18px;
}

.confirm-dialog {
  width: min(100%, 360px);
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(24, 24, 27, 0.18);
}

.confirm-dialog p {
  margin: 0 0 10px;
  color: var(--text);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.confirm-dialog .primary {
  width: auto;
  margin-top: 0;
}
@media (max-width: 900px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .order-item-row .product-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .order-item-row {
    grid-template-columns: 1fr;
  }
}

/* TOMATE red portal theme */
.portal-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.portal-sidebar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #951d24 0%, #741219 100%);
  padding: 18px 15px 14px;
  color: #fff;
  box-shadow: 8px 0 28px rgba(73, 12, 17, 0.12);
}

.portal-brand,
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.portal-brand {
  padding: 0 10px 16px;
}

.portal-brand strong {
  display: block;
  color: #fff;
  font-size: 22px;
  letter-spacing: 0.4px;
}

.portal-brand span:not(.brand-mark) {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.brand-mark {
  display: inline-grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
}

.brand-mark svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.3;
}

.portal-sidebar .nav-bar {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 3px;
  border: 0;
  padding: 0;
}

.portal-nav-item {
  width: 100%;
  min-height: 40px;
  justify-content: flex-start;
  gap: 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 0 13px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  font-weight: 600;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.portal-nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateX(2px);
}

.portal-nav-item.active {
  border: 0;
  background: linear-gradient(135deg, #e33940 0%, #c82630 100%);
  color: #fff;
  box-shadow: 0 7px 18px rgba(71, 5, 10, 0.24);
}

.nav-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px 8px 0;
}

.sidebar-user > span:last-child {
  min-width: 0;
}

.sidebar-user strong,
.sidebar-user small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user strong {
  font-size: 13px;
}

.sidebar-user small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.user-avatar {
  display: inline-grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  place-items: center;
  background: var(--brand-dark);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.sidebar-user .user-avatar {
  background: rgba(255, 255, 255, 0.16);
}

.portal-main {
  min-width: 0;
}

.portal-shell .top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 78px;
  align-items: center;
  gap: 18px;
  margin: 0;
  border-bottom: 1px solid #ebe7e7;
  background: rgba(255, 255, 255, 0.94);
  padding: 12px 30px;
  backdrop-filter: blur(12px);
}

.top-spacer {
  flex: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.language-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.language-control select {
  width: auto;
  min-width: 92px;
  height: 38px;
  border-color: #e3dede;
  border-radius: 8px;
}

.top-user {
  display: flex;
  align-items: center;
  gap: 9px;
  border-left: 1px solid #ebe7e7;
  padding-left: 14px;
  color: #393436;
  font-size: 13px;
  font-weight: 600;
}

.logout-button {
  min-height: 38px;
  border-color: #ead7d8;
  border-radius: 8px;
  color: var(--brand-dark);
}

.logout-button:hover {
  background: var(--brand-soft);
}

.mobile-brand {
  display: none;
  color: var(--brand-dark);
}

.mobile-brand .brand-mark,
.mobile-brand .brand-mark svg {
  width: 30px;
  height: 30px;
}

.portal-content {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 28px 30px 46px;
}

.page-head {
  padding-top: 0;
}

.page-head h2 {
  color: #211d1e;
  font-size: 27px;
  letter-spacing: -0.4px;
}

.page-head p {
  margin: 8px 0 0;
  color: #777174;
}

.inventory-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.page-eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sync-status {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 7px;
  align-items: center;
  border: 1px solid #eadfe0;
  border-radius: 10px;
  background: #fff;
  padding: 10px 13px;
  color: #847d80;
  font-size: 11px;
  box-shadow: 0 5px 16px rgba(76, 18, 22, 0.04);
}

.sync-status strong {
  grid-column: 2;
  color: #403a3c;
  font-size: 12px;
}

.status-dot {
  grid-row: 1 / 3;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #20a56e;
  box-shadow: 0 0 0 4px #e7f8f0;
}

.inventory-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0;
}

.metric-card {
  display: flex;
  min-width: 0;
  min-height: 112px;
  align-items: center;
  gap: 15px;
  border: 1px solid #ebe5e5;
  border-radius: 12px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric-icon {
  display: inline-grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-bright);
}

.metric-icon svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.metric-card > span:last-child {
  min-width: 0;
}

.metric-card small,
.metric-card strong {
  display: block;
}

.metric-card small {
  color: #777174;
  font-size: 13px;
}

.metric-card strong {
  margin-top: 8px;
  color: var(--brand-bright);
  font-size: clamp(17px, 1.55vw, 24px);
  letter-spacing: -0.7px;
  white-space: nowrap;
}

.user-panel,
.order-card,
.login-card {
  border-color: #ebe5e5;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.inventory-panel {
  padding: 0;
  overflow: hidden;
}

.inventory-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #eee9e9;
  padding: 19px 22px;
}

.inventory-toolbar h3 {
  margin: 0;
  font-size: 17px;
}

.inventory-toolbar > div > span {
  display: block;
  margin-top: 4px;
  color: #8a8386;
  font-size: 12px;
}

.inventory-search {
  position: relative;
  display: block;
  width: min(100%, 420px);
}

.inventory-search svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #928b8e;
  stroke-linecap: round;
  stroke-width: 1.8;
  transform: translateY(-50%);
  pointer-events: none;
}

.inventory-search input {
  height: 43px;
  border-color: #ddd6d7;
  border-radius: 9px;
  padding-left: 42px;
}

.inventory-table-wrap {
  margin: 0;
  overflow-x: auto;
}

.inventory-table {
  table-layout: fixed;
  margin: 0;
  font-size: 13px;
}

.inventory-table th,
.inventory-table td {
  height: 54px;
  border-color: #eee9e9;
  padding: 10px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-table th {
  height: 47px;
  background: #fbf9f9;
  color: #665f62;
  font-size: 11px;
  letter-spacing: 0.15px;
}

.inventory-table tbody tr {
  transition: background 120ms ease;
}

.inventory-table tbody tr:hover {
  background: #fff9f9;
}

.inventory-table th:nth-child(1) { width: 11%; }
.inventory-table th:nth-child(2) { width: 34%; }
.inventory-table th:nth-child(3) { width: 23%; }
.inventory-table th:nth-child(4) { width: 18%; }
.inventory-table th:nth-child(5) { width: 14%; }

.inventory-product-link {
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  padding: 2px 0;
  color: var(--brand-bright);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.inventory-product-link:hover,
.inventory-product-link:focus-visible {
  color: var(--brand);
}

.inventory-detail-dialog {
  width: min(100%, 760px);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid #eadfe0;
  border-radius: 16px;
  background: #fff;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(76, 18, 22, 0.24);
}

.inventory-detail-dialog header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.inventory-detail-dialog header span,
.inventory-detail-dialog header p {
  color: #847d80;
  font-size: 12px;
}

.inventory-detail-dialog h3 {
  margin: 4px 0;
  color: var(--brand-bright);
  font-size: 25px;
}

.inventory-detail-dialog header p { margin: 0; }

.inventory-detail-dialog header button {
  width: 38px;
  height: 38px;
  border: 1px solid #eadfe0;
  border-radius: 9px;
  background: #fff;
  color: #665f62;
  font-size: 24px;
  cursor: pointer;
}

.inventory-detail-context,
.inventory-detail-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.inventory-detail-context span,
.inventory-detail-values article {
  border: 1px solid #eee7e8;
  border-radius: 11px;
  background: #fbf9f9;
  padding: 15px;
  color: #847d80;
  font-size: 12px;
}

.inventory-detail-context strong,
.inventory-detail-values strong,
.inventory-detail-values span {
  display: block;
}

.inventory-detail-context strong {
  margin-top: 7px;
  color: #332e30;
  font-size: 14px;
}

.inventory-detail-values article {
  min-height: 112px;
  background: var(--brand-soft);
}

.inventory-detail-values small { color: #756e71; }
.inventory-detail-values strong {
  margin-top: 12px;
  color: var(--brand-bright);
  font-size: 24px;
}
.inventory-detail-values span {
  margin-top: 8px;
  color: #847d80;
  font-size: 11px;
}

.inventory-detail-dialog footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

.inventory-detail-dialog footer .primary { width: auto; margin: 0; }

.inventory-sale-history {
  margin-top: 22px;
}

.inventory-sale-history h4 {
  margin: 0 0 10px;
  color: #332e30;
  font-size: 15px;
}

.inventory-sale-history .table-wrap {
  margin: 0;
  border: 1px solid #eee7e8;
  border-radius: 10px;
  overflow: hidden;
}

.inventory-sale-history table {
  margin: 0;
  font-size: 12px;
}

.inventory-sale-history th,
.inventory-sale-history td {
  padding: 10px 12px;
}

.inventory-sale-history th {
  background: #fbf9f9;
}

.inventory-sale-history td strong {
  color: var(--brand-bright);
}

.sales-inventory-table th:nth-child(1) { width: 16%; }
.sales-inventory-table th:nth-child(2) { width: 34%; }
.sales-inventory-table th:nth-child(3) { width: 24%; }
.sales-inventory-table th:nth-child(4) { width: 12%; }
.sales-inventory-table th:nth-child(5) { width: 14%; }

.inventory-pagination {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 22px;
  color: #756e71;
  font-size: 13px;
}

.inventory-pagination > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inventory-pagination strong {
  display: inline-grid;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  place-items: center;
  background: var(--brand-bright);
  color: #fff;
}

.pagination-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  border: 1px solid #ded7d8;
  border-radius: 8px;
  place-items: center;
  background: #fff;
  color: #554f51;
  cursor: pointer;
  font-size: 21px;
}

.pagination-button:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.product-card-clickable {
  cursor: pointer;
  transition: box-shadow 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.product-card-clickable:hover,
.product-card-clickable:focus-visible {
  border-color: #d6b9bb;
  box-shadow: 0 10px 24px rgba(76, 18, 22, 0.11);
  outline: none;
  transform: translateY(-1px);
}

.dashboard-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.dashboard-source {
  max-width: 300px;
  overflow: hidden;
  border: 1px solid #eadfe0;
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  color: #817a7d;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.analysis-metric {
  display: flex;
  min-width: 0;
  min-height: 96px;
  align-items: center;
  gap: 11px;
  border: 1px solid #ebe5e5;
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  box-shadow: var(--shadow);
}

.analysis-metric.positive {
  border-color: #bfe7d5;
  background: #f1fbf7;
}

.analysis-metric.positive .metric-icon {
  background: #dcf7ea;
  color: #16845b;
}

.analysis-metric > span:last-child {
  min-width: 0;
}

.analysis-metric small,
.analysis-metric strong {
  display: block;
}

.analysis-metric small {
  color: #777174;
  font-size: 11px;
}

.analysis-metric strong {
  margin-top: 7px;
  color: #282325;
  font-size: clamp(18px, 1.5vw, 23px);
  letter-spacing: -0.6px;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  gap: 16px;
}

.analysis-panel {
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.analysis-panel > header {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #eee9e9;
  padding: 14px 17px;
}

.analysis-panel > header h3 {
  margin: 0;
  font-size: 16px;
}

.analysis-panel > header span {
  color: #817a7d;
  font-size: 11px;
}

.analysis-table-wrap {
  margin: 0;
  overflow-x: auto;
}

.analysis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.analysis-table th,
.analysis-table td {
  height: 43px;
  border-bottom: 1px solid #eee9e9;
  padding: 8px 9px;
  white-space: nowrap;
}

.analysis-table th {
  background: #8f1d24;
  color: #fff;
  font-size: 10px;
}

.analysis-table tbody tr:nth-child(even) {
  background: #fbf8f8;
}

.analysis-table tbody tr:hover {
  background: #fff2f2;
}

.series-table {
  min-width: 650px;
}

.reorder-table {
  min-width: 900px;
}

.reorder-table th:nth-child(3),
.reorder-table td:nth-child(3) {
  width: 240px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 7px;
  font-size: 10px;
  font-weight: 700;
}

.analysis-status.urgent {
  border-color: #fecaca;
  background: #fff1f2;
  color: #c21f2b;
}

.analysis-status.attention {
  border-color: #fcd79a;
  background: #fffaeb;
  color: #a85b08;
}

.analysis-status.normal {
  border-color: #b9ead3;
  background: #edfbf5;
  color: #11724c;
}

.analysis-status.high {
  border-color: #bae1f5;
  background: #eef8fd;
  color: #176b94;
}

.analysis-status.neutral {
  border-color: #e2dfe0;
  background: #f7f5f5;
  color: #6f686b;
}

@media (min-width: 1450px) {
  .dashboard-summary {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: minmax(420px, 0.85fr) minmax(700px, 1.45fr);
    align-items: start;
  }
}

.login-card {
  border-top: 4px solid var(--brand);
}

.login-card h1 {
  color: var(--brand-dark);
}

@media (max-width: 1350px) {
  .portal-shell {
    grid-template-columns: 202px minmax(0, 1fr);
  }

  .portal-sidebar {
    padding-right: 11px;
    padding-left: 11px;
  }

  .portal-content {
    padding-right: 22px;
    padding-left: 22px;
  }

  .metric-card {
    gap: 10px;
    padding: 14px;
  }

  .metric-icon {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 1100px) {
  .inventory-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-user > span:last-child,
  .language-control > span {
    display: none;
  }

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

@media (max-width: 860px) {
  .portal-shell {
    display: block;
  }

  .portal-sidebar {
    position: static;
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    padding: 10px 14px;
  }

  .portal-brand,
  .sidebar-user {
    display: none;
  }

  .portal-sidebar .nav-bar {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 0 0 3px;
  }

  .portal-nav-item {
    flex: 0 0 auto;
    width: auto;
    min-height: 39px;
    padding: 0 12px;
  }

  .portal-nav-item:hover {
    transform: none;
  }

  .portal-shell .top {
    min-height: 66px;
    padding: 10px 18px;
  }

  .mobile-brand {
    display: flex;
  }

  .top-user {
    display: none;
  }

  .portal-content {
    padding: 22px 18px 38px;
  }

  .inventory-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .inventory-search {
    width: 100%;
  }

  .inventory-table {
    min-width: 820px;
  }
}

@media (max-width: 560px) {
  .inventory-detail-dialog {
    padding: 18px;
  }

  .inventory-detail-context,
  .inventory-detail-values {
    grid-template-columns: 1fr;
  }

  .portal-shell .top {
    gap: 8px;
  }

  .top-actions {
    gap: 7px;
  }

  .language-control select {
    min-width: 76px;
    padding: 0 7px;
  }

  .logout-button {
    padding: 0 9px;
    font-size: 12px;
  }

  .inventory-page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .sync-status {
    align-self: flex-start;
  }

  .inventory-summary {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 92px;
  }

  .inventory-pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-head {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-source {
    max-width: 100%;
    align-self: flex-start;
  }

  .dashboard-summary {
    grid-template-columns: 1fr;
  }
}
