:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #17202a;
  background: #f3f6f8;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden], .view { display: none !important; }

.shell { min-height: 100vh; }
.connect-screen { min-height: 100vh; display: grid; align-items: center; padding: 28px; }
.connect-panel { width: min(620px, 100%); margin: 0 auto; border: 1px solid #d9e1e7; border-radius: 8px; padding: 28px; background: #fff; box-shadow: 0 10px 30px rgba(23, 32, 42, 0.08); }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: 0; text-transform: uppercase; color: #24706f; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 18px; }
.lead { margin: 10px 0 0; color: #5c6975; font-size: 16px; line-height: 1.45; }

.connection-card { display: grid; margin: 24px 0; border: 1px solid #e2e8ed; border-radius: 8px; overflow: hidden; }
.status-line { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 14px; border-top: 1px solid #e2e8ed; background: #f8fafb; }
.status-line:first-child { border-top: 0; }
.status-line span { color: #5c6975; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.status-line strong { overflow-wrap: anywhere; font-size: 14px; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; border: 1px solid #c7d2da; border-radius: 6px; padding: 0 14px; background: #fff; color: #17202a; font-weight: 700; text-decoration: none; cursor: pointer; }
.button:disabled, .button.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.primary { border-color: #24706f; background: #24706f; color: #fff; }
.connect-button { width: 100%; }
.message, .note { min-height: 20px; margin: 0; color: #5c6975; font-size: 13px; line-height: 1.4; }
.note { margin-top: 12px; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; border-right: 1px solid #d9e1e7; padding: 20px; background: #ffffff; }
.brand { display: grid; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid #e2e8ed; }
.brand span { color: #24706f; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.brand strong { font-size: 20px; }
.navmenu { display: grid; gap: 8px; }
.navitem { width: 100%; min-height: 42px; border: 0; border-radius: 6px; padding: 0 12px; background: transparent; color: #41505d; font: inherit; font-weight: 800; text-align: left; cursor: pointer; }
.navitem:hover { background: #edf4f4; }
.navitem.active { background: #24706f; color: #fff; }
.sidebar-action { margin-top: auto; }

.content { min-width: 0; padding: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.active-view { display: block !important; }
.workspace { display: grid; grid-template-columns: 380px 1fr; gap: 18px; margin-bottom: 18px; }
.panel { border: 1px solid #d9e1e7; border-radius: 8px; padding: 18px; background: #fff; box-shadow: 0 1px 2px rgba(23, 32, 42, 0.05); }
form { display: grid; gap: 14px; }
.compact-form { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 7px; color: #41505d; font-size: 13px; font-weight: 700; }
input { width: 100%; min-height: 40px; border: 1px solid #c7d2da; border-radius: 6px; padding: 8px 10px; font: inherit; background: #fff; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric { min-height: 76px; border: 1px solid #e2e8ed; border-radius: 6px; padding: 12px; background: #f8fafb; }
.metric span { display: block; color: #5c6975; font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin-top: 8px; font-size: 24px; line-height: 1; }
.count-label { color: #24706f; font-size: 14px; }
.table-panel { padding: 0; overflow: hidden; }
.secondary-table { margin-top: 18px; }
.table-panel .section-head { padding: 18px 18px 0; }
.table-panel input { max-width: 360px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { border-top: 1px solid #e2e8ed; padding: 12px; text-align: left; vertical-align: top; font-size: 13px; }
th { background: #f8fafb; color: #41505d; font-size: 12px; text-transform: uppercase; }
.product-cell strong { display: block; margin-bottom: 5px; }
.product-cell span { color: #5c6975; overflow-wrap: anywhere; }
.empty { height: 120px; text-align: center; color: #5c6975; }

@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .navmenu { grid-template-columns: repeat(3, 1fr); }
  .sidebar-action { margin-top: 0; }
  .workspace, .metrics { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .content, .connect-screen { padding: 16px; }
  .connect-panel { padding: 20px; }
  .status-line, .field-row { grid-template-columns: 1fr; }
  .navmenu { grid-template-columns: 1fr; }
  .topbar, .section-head { align-items: stretch; flex-direction: column; }
}

.stock-toolbar {
  grid-template-columns: 190px minmax(220px, 1fr);
  align-items: center;
}

.stock-toolbar .message {
  grid-column: 1 / -1;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: #edf4f4;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 42, 0.45);
}

.modal-panel {
  position: relative;
  width: min(1080px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 8px;
  border: 1px solid #d9e1e7;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(23, 32, 42, 0.25);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid #e2e8ed;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
}

.detail-grid article {
  min-width: 0;
  border: 1px solid #e2e8ed;
  border-radius: 6px;
  padding: 12px;
  background: #f8fafb;
}

.detail-grid span {
  display: block;
  color: #5c6975;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

#productHistoryMessage {
  padding: 0 18px 14px;
}

.modal-table {
  padding-bottom: 12px;
}

@media (max-width: 760px) {
  .stock-toolbar,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 12px;
  }

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