:root {
  --blue: #2455d8;
  --blue-dark: #153278;
  --green: #287b1a;
  --green-soft: #e7f5e4;
  --ink: #202938;
  --muted: #647084;
  --line: #d9e0ec;
  --paper: #ffffff;
  --bg: #f4f7fb;
  --danger: #b42318;
  --warning: #ad6800;
  --shadow: 0 18px 50px rgba(27, 44, 72, 0.12);
}

* { box-sizing: border-box; }

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

body.logged-out {
  overflow: hidden;
}

body.logged-out .sidebar,
body.logged-out .app-shell {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(244, 247, 251, 0.92);
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card img {
  width: 230px;
  max-width: 100%;
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.login-card small {
  color: var(--muted);
  line-height: 1.45;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: block;
  padding: 8px;
}

.brand img {
  width: 190px;
  max-width: 100%;
  display: block;
}

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

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
  border-radius: 8px;
  text-align: left;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  color: var(--blue-dark);
  background: #edf3ff;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--green);
}

.app-shell {
  margin-left: 248px;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1,
.hero h2,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 30px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}

.user-pill img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.view { display: none; }
.view.active { display: block; }

.hero {
  position: relative;
  min-height: 300px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--blue-dark);
  box-shadow: var(--shadow);
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.42;
}

.hero-copy {
  position: relative;
  max-width: 580px;
  padding: 44px;
  color: #fff;
}

.hero-copy p {
  margin: 0 0 8px;
  font-weight: 800;
  color: #bff1b7;
}

.hero-copy h2 {
  font-size: 42px;
  line-height: 1.05;
  margin-bottom: 22px;
}

.primary-action,
.secondary-action,
.icon-button {
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-action {
  background: var(--green);
  color: #fff;
  padding: 11px 16px;
}

.secondary-action {
  background: #fff;
  color: var(--blue-dark);
  border-color: var(--line);
  padding: 10px 14px;
}

.danger-action {
  color: var(--danger);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
  padding: 0;
}

.role-hidden {
  display: none !important;
}

.metrics-grid,
.catalog-grid,
.booking-grid,
.report-grid,
.setup-grid {
  display: grid;
  gap: 16px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.metric,
.panel,
.article-card,
.notice {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel {
  padding: 20px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.success {
  background: var(--green-soft);
  color: var(--green);
}

.badge.warning {
  background: #fff4d6;
  color: var(--warning);
}

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

.timeline span {
  padding: 12px;
  border-radius: 8px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  font-weight: 700;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr auto;
  gap: 14px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.toolbar-action {
  display: flex;
  align-items: end;
}

.catalog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.booking-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.booking-title {
  min-height: 44px;
  display: grid;
  place-items: center;
  background: linear-gradient(90deg, #64b9ad, #4a9f99);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.booking-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.booking-grid {
  display: block;
  overflow-x: auto;
}

.assortment-table {
  min-width: 920px;
  display: grid;
  grid-template-columns: 220px repeat(var(--size-count), minmax(138px, 1fr));
}

.assortment-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: center;
  font-weight: 900;
  color: var(--ink);
}

.assortment-header.article-column {
  text-align: left;
}

.article-column,
.booking-cell {
  min-height: 104px;
  border-bottom: 1px solid var(--line);
}

.article-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: #fff;
}

.article-row strong,
.article-row small {
  display: block;
}

.article-row small {
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.25;
}

.article-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #edf3ff;
  color: var(--blue);
  font-weight: 900;
}

.booking-cell {
  padding: 10px;
  background: #fff;
  border-left: 1px solid #edf1f6;
}

.booking-cell.selected {
  background: #cbf7a5;
}

.booking-cell.disabled {
  background: #f5f7fa;
  color: #9aa5b5;
}

.booking-cell input {
  width: 100%;
  height: 30px;
  min-height: 30px;
  border-radius: 3px;
  padding: 0 8px;
  background: #fff;
}

.booking-cell small,
.booking-cell em {
  display: block;
  color: #5d8ca0;
  font-size: 10px;
  font-style: normal;
  line-height: 1.25;
  margin-top: 6px;
}

.booking-cell em {
  color: #1f2f45;
  font-weight: 800;
}

.not-available {
  display: grid;
  place-items: center;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}

.article-card {
  overflow: hidden;
}

.article-visual {
  min-height: 150px;
  background: linear-gradient(135deg, #eaf0ff, #e8f7e6);
  display: grid;
  place-items: center;
  color: var(--blue-dark);
  font-size: 34px;
  font-weight: 900;
}

.article-body {
  padding: 16px;
}

.article-body h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.article-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.article-meta span {
  border-radius: 999px;
  padding: 4px 8px;
  background: #f1f4f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.price {
  font-weight: 900;
  color: var(--blue-dark);
}

dialog {
  border: 0;
  padding: 0;
  width: min(900px, calc(100vw - 28px));
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(10, 21, 38, 0.56);
}

.matrix-modal {
  padding: 22px;
}

.matrix-modal header,
.matrix-modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.matrix-modal h2 { margin: 0; }

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: #f1f4f8;
  color: var(--muted);
}

.modal-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  margin: 18px 0;
}

.modal-image {
  border-radius: 8px;
  background: linear-gradient(135deg, #edf3ff, #e7f5e4);
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--blue);
  font-size: 56px;
  font-weight: 900;
}

.rule-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.rule-strip span {
  background: #f7f9fc;
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.size-matrix {
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  gap: 10px;
}

.size-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.size-cell span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.size-cell input {
  width: 100%;
  padding: 0 8px;
}

.matrix-warning {
  min-height: 22px;
  color: var(--danger);
  font-weight: 800;
}

.cart-lines,
.approval-list,
.sync-list,
.top-skus,
.audit-log {
  display: grid;
  gap: 10px;
}

.line-item,
.approval-item,
.sync-item,
.audit-item,
.top-sku {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.line-item small,
.approval-item small,
.sync-item small,
.audit-item small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 20px;
}

.notice {
  margin-top: 16px;
  padding: 16px;
  border-color: #b9e6b4;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}

.hidden { display: none; }

.line-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.report-grid {
  grid-template-columns: 1fr 1fr;
}

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

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

.bar-row {
  display: grid;
  grid-template-columns: 86px 1fr 70px;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 14px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.size-curve {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.size-box {
  border-radius: 8px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  padding: 14px;
  text-align: center;
}

.size-box strong {
  display: block;
  font-size: 24px;
  color: var(--blue-dark);
}

.setup-grid {
  grid-template-columns: 1fr 1fr;
}

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

.import-list {
  display: grid;
  gap: 10px;
}

.form-action {
  display: flex;
  align-items: end;
}

@media print {
  .sidebar,
  .topbar,
  .toolbar,
  .primary-action,
  .secondary-action,
  .link-button,
  #login-screen {
    display: none !important;
  }

  .app-shell {
    margin: 0;
    padding: 0;
  }

  .view {
    display: none !important;
  }

  #reports {
    display: block !important;
  }
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 14px;
  }

  .app-shell {
    margin-left: 0;
    padding: 18px;
  }

  .nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .sidebar-foot { display: none; }
  .metrics-grid,
  .catalog-grid,
  .timeline,
  .toolbar,
  .report-grid,
  .setup-grid,
  .modal-body {
    grid-template-columns: 1fr;
  }

  .hero-copy h2 {
    font-size: 32px;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .hero-copy {
    padding: 28px;
  }

  .size-matrix,
  .size-curve,
  .setup-form {
    grid-template-columns: 1fr;
  }

  .line-item,
  .approval-item,
  .sync-item,
  .top-sku {
    grid-template-columns: 1fr;
  }
}
