/* ==========================================================================
   Admin Workspace - Production Design System
   Identity: Pure Deep Black, White & Neutral Greys
   Locale: LTR English First
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #07080a;
  --surface: #0d0f14;
  --surface-raised: #13161f;
  --surface-hover: #181c27;
  --field: #090a0f;
  --field-focus: #11141e;
  --line: #1c202c;
  --line-hover: #2b3244;
  --line-focus: #ffffff;
  --text: #ffffff;
  --text-secondary: #cbd5e1;
  --muted: #7e8b9f;
  --muted-light: #94a3b8;
  --sidebar: 248px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  direction: ltr;
  text-align: left;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
  pointer-events: none;
}

h1, h2, h3, h4, p {
  margin: 0;
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

/* Accessible Focus States */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--line-focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 20px;
  background: #ffffff;
  color: #000000;
  padding: 12px 18px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 14px;
}

/* ==========================================================================
   Sidebar Navigation (Desktop & Tablet)
   ========================================================================== */

.sidebar {
  width: var(--sidebar);
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 14px;
  border-inline-end: 1px solid var(--line);
  background: var(--bg);
  z-index: 50;
  box-sizing: border-box;
}

.workspace-name {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  padding: 4px 14px 24px;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.sidebar nav,
.mobile-nav nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

nav a:hover {
  background: var(--surface-hover);
  color: #ffffff;
}

nav a[aria-current="page"] {
  background: #ffffff;
  color: #000000;
  font-weight: 600;
}

nav a[aria-current="page"] .icon {
  stroke: #000000;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 20px 8px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-bottom .button {
  width: 100%;
  justify-content: flex-start;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 10px 12px;
  min-height: 42px;
  border-radius: var(--radius-md);
}

.sidebar-bottom .button:hover {
  color: #ffffff;
  background: var(--surface-hover);
  border-color: var(--line);
}

.preview-label {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  display: block;
}

/* ==========================================================================
   Main Workspace Layout
   ========================================================================== */

.workspace {
  margin-inline-start: var(--sidebar);
  min-height: 100vh;
  background: var(--bg);
  box-sizing: border-box;
}

main {
  max-width: 1440px;
  padding: 36px 40px 60px;
  margin: 0 auto;
  min-width: 0;
  box-sizing: border-box;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.page-heading h1 {
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.4px;
}

.heading-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: var(--radius-md);
  background: transparent;
  color: #ffffff;
  border: 1px solid var(--line-hover);
  padding: 9px 16px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  user-select: none;
}

.button:hover {
  background: var(--surface-raised);
  border-color: #555560;
  color: #ffffff;
}

.button:active {
  transform: scale(0.98);
}

.button.primary {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  font-weight: 650;
}

.button.primary:hover {
  background: #e8e8ed;
  border-color: #e8e8ed;
  color: #000000;
}

.button.primary:active {
  background: #d8d8de;
}

/* Small button for inside tables */
td .button {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Feedback & Alert Messages
   ========================================================================== */

.feedback {
  margin-bottom: 24px;
  padding: 14px 18px;
  border: 1px solid #33333d;
  background: var(--surface);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.6;
  color: #e2e8f0;
}

.feedback.error,
.form-error {
  color: #fca5a5;
  background: #140909;
  border-color: #552020;
}

.feedback[hidden],
.form-error[hidden] {
  display: none;
}

.feedback.toast {
  position: fixed;
  z-index: 1000;
  inset-block-start: 20px;
  inset-inline-end: 20px;
  max-width: min(420px, calc(100vw - 40px));
  margin: 0;
  color: #dcfce7;
  background: #0d1b13;
  border-color: #245b39;
  box-shadow: 0 12px 32px rgb(0 0 0 / 28%);
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty-state {
  grid-column: 1 / -1;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  line-height: 1.7;
  background: rgba(255, 255, 255, 0.01);
}

/* ==========================================================================
   Metrics Grid (Overview Cards)
   ========================================================================== */

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

.metric {
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), background var(--transition);
}

.metric:hover {
  border-color: var(--line-hover);
  background: var(--surface-raised);
}

.metric > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.metric > span .icon {
  color: var(--muted);
  opacity: 0.7;
  transition: opacity var(--transition), color var(--transition);
}

.metric:hover > span .icon {
  opacity: 1;
  color: #ffffff;
}

.metric strong {
  display: block;
  font-size: 32px;
  line-height: 1.25;
  margin-top: 18px;
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric:nth-child(7) strong {
  font-size: 23px; /* Wallet Total font adjustment */
}

/* ==========================================================================
   Product Grid & Cards (Catalog & Products)
   ========================================================================== */

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.product-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-width: 0;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

.product-card:hover {
  border-color: var(--line-hover);
}

.product-card[open] {
  border-color: #383844;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.card-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background var(--transition);
}

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

.card-summary:hover {
  background: var(--surface-hover);
}

.product-card[open] .card-summary {
  border-bottom: 1px solid var(--line);
  background: var(--surface-raised);
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-status-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chevron-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform var(--transition), color var(--transition);
}

.chevron-toggle .icon {
  width: 15px;
  height: 15px;
  transform: rotate(90deg); /* Points down v when closed */
  transition: transform var(--transition);
}

.product-card[open] .chevron-toggle .icon {
  transform: rotate(-90deg); /* Points up ^ when open */
  color: #ffffff;
}

.card-summary h2 {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
  color: #ffffff;
  margin: 0;
  overflow-wrap: anywhere;
}

.card-summary-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  padding-top: 2px;
}

.summary-price {
  color: #ffffff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.summary-stock {
  color: var(--muted);
  font-size: 12px;
}

.card-dropdown {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  animation: cardDropdownOpen 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardDropdownOpen {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.supplier-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Status Indicator Dot */
.state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #555555;
}

.state.active {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.08);
}

.state.active::before {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.product-card h2 {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.45;
  color: #ffffff;
  overflow-wrap: anywhere;
}

.product-image {
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #060608;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.product-description {
  font-size: 13px;
  color: var(--muted-light);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Metadata Key-Value Grid */
.metadata {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metadata > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  min-width: 0;
}

.metadata dt {
  color: var(--muted);
  flex-shrink: 0;
}

.metadata dd {
  margin: 0;
  color: #ffffff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: end;
  overflow-wrap: anywhere;
  min-width: 0;
}

/* Risk / Warning Note */
.risk-note {
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 14px;
  border-inline-start: 3px solid #ffffff;
  background: #141418;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
}

/* Supplier Raw Details Dropdown */
.supplier-details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.supplier-details summary {
  cursor: pointer;
  min-height: 32px;
  display: flex;
  align-items: center;
  user-select: none;
  font-weight: 500;
}

.supplier-details summary:hover {
  color: #ffffff;
}

.supplier-details pre,
.account-content {
  background: #060608;
  border: 1px solid var(--line);
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.7;
  max-height: 360px;
  overflow-y: auto;
  color: #d1d5db;
  border-radius: var(--radius-md);
  margin-top: 8px;
}

/* ==========================================================================
   Supplier Catalog - Horizontal List Row System
   ========================================================================== */

.catalog-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.catalog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.catalog-row:hover {
  border-color: var(--line-hover);
  background: #0f0f13;
}

.catalog-info {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.catalog-main-meta {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.catalog-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.4;
  word-break: break-word;
}

.catalog-supplier-price {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.catalog-price-label {
  color: var(--muted);
  font-size: 12px;
}

.catalog-price-val {
  color: #e2e8f0;
  font-weight: 650;
  font-family: inherit;
}

.catalog-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-warning {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  color: #fbbf24;
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
  align-self: flex-start;
}

.catalog-warning .icon {
  width: 15px;
  height: 15px;
  color: #f59e0b;
  flex-shrink: 0;
}

.catalog-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.catalog-row .publish-form {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 16px;
  margin: 0;
  padding: 0;
  border: none;
}

.publish-pricing-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.publish-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.publish-field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.input-with-currency {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-currency input {
  height: 40px;
  width: 120px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: #ffffff;
  padding: 0 44px 0 12px;
  font-size: 13px;
  font-weight: 650;
  direction: ltr;
  text-align: left;
  transition: border-color var(--transition), background var(--transition);
}

.input-with-currency input:focus {
  border-color: #ffffff;
  background: var(--field-focus);
  outline: none;
}

.input-unit {
  position: absolute;
  right: 10px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}

.publish-customer-price {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 110px;
}

.customer-price-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.customer-price-val {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  direction: ltr;
  text-align: left;
  white-space: nowrap;
}

.publish-submit-btn {
  height: 40px;
  min-height: 40px;
  padding: 0 22px;
  font-size: 13px;
  font-weight: 650;
  border-radius: var(--radius-md);
  white-space: nowrap;
}

.catalog-status-box {
  display: flex;
  align-items: center;
  padding: 6px 12px;
}

/* Fallback for general publish-form if used anywhere else */
.publish-form {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.publish-form label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.price-action {
  display: flex;
  gap: 10px;
  align-items: center;
}

.price-action input {
  text-align: start;
  direction: ltr;
  flex: 1;
}

.price-action button {
  min-width: 90px;
}

@media (max-width: 900px) {
  .catalog-row {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px;
  }
  .catalog-actions {
    width: 100%;
    border-top: 1px solid var(--line);
    padding-top: 14px;
  }
  .catalog-row .publish-form {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
  }
}

@media (max-width: 580px) {
  .catalog-row {
    padding: 14px;
  }
  .catalog-main-meta {
    flex-direction: column;
    gap: 4px;
  }
  .catalog-row .publish-form {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .publish-pricing-block {
    width: 100%;
    justify-content: space-between;
    align-items: flex-end;
  }
  .input-with-currency input {
    width: 120px;
  }
  .publish-submit-btn {
    width: 100%;
    min-height: 44px;
  }
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.stock-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* Stock & Wallet Totals */
.stock-totals {
  display: flex;
  gap: 32px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
}

.stock-totals strong {
  color: #ffffff;
  margin-inline-start: 8px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.wallet-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 26px;
  gap: 16px;
}

.wallet-total span {
  color: var(--muted);
  font-size: 14px;
}

.wallet-total strong {
  font-size: 28px;
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Search Tools & Filter Controls (Dropdowns)
   ========================================================================== */

.search-tools {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.search-tools input {
  max-width: 340px;
  flex: 1;
  min-width: 160px;
}

.search-tools select {
  min-width: 150px;
  max-width: 100%;
}

/* Form Inputs & Dropdown Styling */
input, select, textarea {
  background: var(--field);
  border: 1px solid var(--line-hover);
  border-radius: var(--radius-md);
  min-height: 44px;
  padding: 10px 14px;
  color: #ffffff;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  transition: border-color var(--transition), background var(--transition);
}

input:hover, select:hover, textarea:hover {
  border-color: #444450;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #ffffff;
  background: var(--field-focus);
}

input::placeholder, textarea::placeholder {
  color: #66666e;
}

/* Custom Dropdown Chevron in LTR (Chevron on right) */
select {
  width: auto;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-inline-start: 14px;
  padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2388888e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 15px;
}

select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

select option {
  background: #141418;
  color: #ffffff;
  padding: 12px;
}

select option:checked {
  background: #22222a;
  color: #ffffff;
  font-weight: 600;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
}

/* ==========================================================================
   Records Container & Data Tables
   ========================================================================== */

.records {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.settings-form {
  display: grid;
  gap: 18px;
  padding: 22px;
  margin-bottom: 24px;
}

.records > .empty-state {
  border: 0;
}

.provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  transition: background var(--transition);
}

.provider-row:hover {
  background: var(--surface-raised);
}

.provider-row:last-child {
  border-bottom: 0;
}

.provider-row > div {
  min-width: 0;
}

.provider-row h2 {
  font-size: 16px;
  font-weight: 650;
  color: #ffffff;
}

.provider-row p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.url {
  text-align: start;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

table {
  border-collapse: collapse;
  width: 100%;
  text-align: start;
  font-size: 13px;
}

caption.sr-only {
  position: absolute;
}

th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  background: #08080a;
  padding: 16px 22px;
  text-align: start;
  white-space: nowrap;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--line);
}

td {
  border-top: 1px solid var(--line);
  padding: 16px 22px;
  white-space: nowrap;
  color: #ffffff;
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover td {
  background: var(--surface-raised);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 13px;
}

.pagination > span:first-child {
  margin-inline-end: auto;
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */

dialog {
  background: var(--surface);
  color: #ffffff;
  border: 1px solid #33333d;
  border-radius: var(--radius-lg);
  padding: 28px;
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9);
  direction: ltr;
  text-align: left;
  box-sizing: border-box;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-heading h2 {
  font-size: 20px;
  font-weight: 650;
  color: #ffffff;
}

.dialog-heading .button {
  padding-inline: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: #e5e5e5;
}

.field small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.field select {
  width: 100%;
}

.form-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-footer .button {
  min-width: 110px;
}

.form-error {
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

#detail-content h3 {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  margin: 26px 0 14px;
}

#detail-content .table-scroll {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

#detail-content .metadata {
  padding-block: 8px;
}

#detail-content td,
#detail-content th {
  padding: 12px 16px;
}

.account-content {
  user-select: text;
}

/* ==========================================================================
   Mobile Navigation Header (<details class="mobile-nav">)
   ========================================================================== */

.mobile-nav {
  display: none;
}

/* ==========================================================================
   Responsive Breakpoints: 1600px, 1100px (Tablet 1024), 760px (Mobile 390)
   ========================================================================== */

@media (min-width: 1600px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Tablet (1024px ~ 1100px) */
@media (max-width: 1100px) {
  :root {
    --sidebar: 210px;
  }
  main {
    padding: 30px 24px 48px;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .product-card {
    padding: 20px;
  }
  .sidebar {
    padding-inline: 10px;
  }
  nav a {
    font-size: 13px;
    gap: 10px;
  }
  .product-grid {
    gap: 16px;
  }
}

/* Mobile (390px ~ 760px) */
@media (max-width: 760px) {
  :root {
    --sidebar: 0px;
  }
  .sidebar {
    display: none !important;
  }
  .workspace {
    margin: 0 !important;
    margin-inline-start: 0 !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Smooth Interactive Mobile Header */
  .mobile-nav {
    display: block;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background var(--transition);
  }

  .mobile-nav[open] {
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  }

  .mobile-nav summary {
    list-style: none;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 16px;
    font-weight: 650;
    color: #ffffff;
    user-select: none;
  }

  .mobile-nav summary::-webkit-details-marker {
    display: none;
  }

  .mobile-nav summary .icon {
    transition: transform var(--transition);
  }

  .mobile-nav[open] summary .icon {
    transform: rotate(90deg);
  }

  .mobile-nav nav {
    padding: 8px 0 20px;
    border-top: 1px solid var(--line);
  }

  .mobile-nav nav a {
    font-size: 14px;
    min-height: 46px;
    padding: 11px 14px;
  }

  main {
    padding: 22px 16px 40px;
  }

  .page-heading {
    margin-bottom: 20px;
    align-items: flex-start;
  }

  .page-heading h1 {
    font-size: 22px;
  }

  .page-heading .button {
    padding-inline: 14px;
  }

  .product-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .product-card {
    padding: 0;
  }

  .card-summary {
    padding: 14px 16px;
    gap: 8px;
  }

  .card-dropdown {
    padding: 16px;
    gap: 14px;
  }

  .metrics {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .metric {
    padding: 18px 20px;
  }

  .metric > span {
    font-size: 12.5px;
    gap: 8px;
  }

  .metric strong {
    font-size: 28px;
    margin-top: 14px;
  }

  .metric:nth-child(7) strong {
    font-size: 20px;
  }

  .provider-row {
    padding: 18px 20px;
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .provider-row .button {
    width: 100%;
  }

  .search-tools {
    gap: 10px;
  }

  .search-tools input {
    max-width: none;
    width: 100%;
  }

  .search-tools select {
    min-width: 0;
    flex: 1;
    width: 100%;
  }

  .search-tools .button {
    width: 100%;
  }

  .wallet-total {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
    gap: 12px;
  }

  .wallet-total strong {
    font-size: 24px;
  }

  th, td {
    padding: 14px 16px;
  }

  .form-columns {
    grid-template-columns: 1fr;
    gap: 0;
  }

  dialog {
    padding: 20px;
    width: calc(100vw - 24px);
    border-radius: var(--radius-md);
  }

  .pagination {
    gap: 10px;
    font-size: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .pagination > span:first-child {
    width: 100%;
    text-align: center;
    margin-inline-end: 0;
    margin-bottom: 6px;
  }

  .stock-totals {
    gap: 20px;
    font-size: 13px;
  }

  .stock-totals strong {
    font-size: 18px;
  }

  .supplier-details pre {
    font-size: 11px;
  }

  .price-action {
    flex-direction: column;
    align-items: stretch;
  }

  .price-action input {
    width: 100%;
  }

  .card-actions .button {
    flex: 1;
  }

  /* Table Cards on Mobile */
  .records table thead {
    display: none;
  }
  .records table,
  .records tbody,
  .records tr,
  .records td {
    display: block;
  }
  .records tr {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
  }
  .records tr:last-child {
    border-bottom: 0;
  }
  .records td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 0;
    padding: 7px 0;
    white-space: normal;
    text-align: end;
    overflow-wrap: anywhere;
    min-width: 0;
  }
  .records td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-align: start;
    flex-shrink: 0;
  }
  .records td .button {
    min-width: 100px;
    min-height: 40px;
  }
  .records td > span,
  .records td > time {
    min-width: 0;
    font-size: 12px;
  }
  .records td > time {
    white-space: normal;
  }
  .records .table-scroll {
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
