:root {
  --line: #d7e9f7;
  --text: #1f3550;
  --muted: #63809b;
  --primary: #62b6ff;
  --primary2: #89ccff;
  --shadow: 0 16px 40px rgba(72, 123, 168, 0.12);
  font-family: Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #edf7ff 0%, #e7f3ff 100%);
  color: var(--text);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.brand {
  font-weight: 700;
  font-size: 20px;
}

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

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 70px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  padding: 18px;
}

.main {
  padding: 20px;
}

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

.cards {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

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

.two-col {
  grid-template-columns: 1fr 1fr;
}

.status-grid {
  margin-top: 8px;
  gap: 8px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.compact-card {
  padding: 10px 14px;
}

.card-title,
.compact-card-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.compact-card-label {
  font-size: 11px;
}

.big {
  font-size: 30px;
  font-weight: 700;
}

.compact-card-value {
  font-size: 18px;
  font-weight: 700;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 14px;
}

.subtext {
  font-size: 14px;
  color: var(--muted);
}

.section-gap {
  margin-top: 16px;
}

.section-gap-sm {
  margin-bottom: 12px;
}

.form-gap {
  margin-bottom: 16px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.action-row {
  gap: 4px;
  flex-wrap: wrap;
}

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

.form-submit-row {
  align-self: end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
textarea {
  padding: 11px 12px;
  border: 1px solid #cfe4f7;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.btn {
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #08314e;
  padding: 11px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

.btn.secondary {
  background: #dff0ff;
}

.nav-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 8px;
}

.nav-btn.active,
.nav-btn:hover {
  background: #dff0ff;
  border-color: #c6e6ff;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.empty-cell {
  text-align: center;
  color: #6b7a90;
  padding: 24px 12px;
}

.badge {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #dcfff4;
  color: #0d6a52;
}

.badge.warn {
  background: #fff1dd;
  color: #8f5d12;
}

.badge.danger {
  background: #ffe4e9;
  color: #9d2948;
}

.badge.info {
  background: #e4f3ff;
  color: #1d5b85;
}

.pre {
  white-space: pre-wrap;
  font-family: ui-monospace, monospace;
  background: #f7fbff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

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

.login-card {
  width: min(460px, 100%);
}

/* =========================
   Dashboard components
   ========================= */

.stat-card__title {
  margin-bottom: 8px;
}

.stat-card__value {
  line-height: 1;
}

.stat-card__subtitle {
  margin-top: 8px;
}

.stat-card--ok {
  border-color: #cfe9dc;
}

.stat-card--warn {
  border-color: #f4dfb3;
}

.stat-card--danger {
  border-color: #efc7cf;
}

/* unified progress */
.progress {
  display: grid;
  gap: 8px;
  width: 100%;
}

.progress__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
}

.progress__numbers,
.progress__percent {
  color: var(--text);
}

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

.progress__track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
  background: #7aa7d9;
}

.progress[data-tone="ok"] .progress__fill {
  background: #77c29a;
}

.progress[data-tone="info"] .progress__fill {
  background: #7aa7d9;
}

.progress[data-tone="warn"] .progress__fill {
  background: #e2b85d;
}

.progress[data-tone="danger"] .progress__fill {
  background: #de8d9d;
}

.progress--compact {
  min-width: 180px;
}

.progress--compact .progress__track {
  height: 8px;
}

.progress--compact .progress__meta {
  font-size: 12px;
}

.progress-cell {
  min-width: 180px;
}

.progress-text {
  margin-bottom: 6px;
  font-weight: 600;
}

.alert-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid #d7e4f2;
  background: #f7fbff;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.alert-banner--info {
  background: #f3f8ff;
}

.alert-banner--warn {
  background: #fff8e8;
  border-color: #f1dfae;
}

.alert-banner--danger {
  background: #fff1f4;
  border-color: #f0c8d0;
}

.alert-banner--ok {
  background: #f1fbf5;
  border-color: #cfe9dc;
}

.alert-banner__body {
  min-width: 0;
  flex: 1;
}

.alert-banner__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.alert-banner__message {
  color: var(--muted);
  line-height: 1.5;
}

.alert-banner__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.alert-banner__action {
  white-space: nowrap;
}

.alert-strip {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff4e5;
  border: 1px solid #ffd7a8;
  color: #9a5b00;
  font-weight: 600;
}

.quick-actions__grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.quick-actions__btn {
  white-space: nowrap;
}

.risk-good {
  color: #15803d;
}

.risk-warn {
  color: #b45309;
}

.risk-bad {
  color: #b91c1c;
}

.risk-muted {
  color: #64748b;
}

.risk-hint {
  margin-top: 2px;
  font-size: 11px;
}

.line-contact-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.line-contact-link img {
  display: block;
  height: 36px;
  max-width: 100%;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .dashboard-split,
  .two-col {
    grid-template-columns: 1fr;
  }

  .alert-banner {
    flex-direction: column;
  }

  .alert-banner__actions {
    width: 100%;
  }

  .quick-actions__grid {
    flex-direction: column;
  }

  .quick-actions__btn,
  .alert-banner__action {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .line-contact-link {
    justify-content: flex-start;
  }
}

/* W9.2 portal resilience + client-facing WMS polish */
:focus-visible {
  outline: 3px solid rgba(29, 91, 133, 0.32);
  outline-offset: 2px;
}

.portal-shell {
  min-height: 100vh;
  background: #f4f8fb;
}

.portal-shell .container {
  max-width: 1440px;
  padding: 24px 28px 48px;
}

.portal-shell .card {
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(31, 53, 80, 0.06);
}

.portal-shell .cards {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.portal-shell .card-title {
  min-height: 30px;
  letter-spacing: .02em;
}

.portal-shell .big {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}

.portal-shell .table-wrap {
  max-width: 100%;
  border: 1px solid #e4edf4;
  border-radius: 10px;
}

.portal-shell table {
  min-width: 760px;
}

.portal-shell th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fafc;
  white-space: nowrap;
}

.portal-shell td {
  font-variant-numeric: tabular-nums;
}

.portal-shell tbody tr:hover td {
  background: #f9fcfe;
}

.portal-state {
  border-style: solid;
  box-shadow: none;
}

.portal-state--error {
  border-color: #e9c4c4;
  background: #fff8f8;
}

.portal-state--empty {
  border-color: #d9e4ec;
  background: #fbfdff;
}

.portal-state .section-title {
  margin-bottom: 6px;
  font-size: 17px;
}

.portal-retry {
  margin-top: 12px;
}

#client-wms > .card:first-child {
  border-left: 4px solid #1d5b85;
}

#client-wms input,
#client-wms select {
  min-height: 42px;
}

#client-wms [data-testid="client-products"] td:nth-child(n+5):nth-child(-n+10),
#client-wms [data-testid="client-reconciliation"] td:nth-child(n+2):nth-child(-n+4),
#client-wms [data-testid="client-movements"] td:nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#client-wms [data-testid="client-products"] th:nth-child(n+5):nth-child(-n+10),
#client-wms [data-testid="client-reconciliation"] th:nth-child(n+2):nth-child(-n+4),
#client-wms [data-testid="client-movements"] th:nth-child(4) {
  text-align: right;
}

#client-wms [data-reconciliation-row][data-mismatch="1"] td {
  background: #fff8f4;
}

@media (max-width: 1024px) {
  .portal-shell .container {
    padding: 20px;
  }

  .portal-shell .two-col {
    grid-template-columns: 1fr;
  }
}

.portal-state--loading {
  border-color: #d9e4ec;
  background: #fbfdff;
}
.portal-loading { display:flex; align-items:center; gap:10px; }
.portal-loading > span { width:16px; height:16px; border:2px solid #d8e5ef; border-top-color:#1d5b85; border-radius:50%; animation:portal-spin .8s linear infinite; }
@keyframes portal-spin { to { transform:rotate(360deg); } }
.portal-shell .two-col { grid-template-columns:repeat(2,minmax(0,1fr)); }
.portal-shell .two-col > .card { min-width:0; }
.portal-wms { scroll-margin-top:16px; }
.portal-wms-hero { border-left:4px solid #1d5b85; }
.portal-wms-eyebrow,.portal-wms-group { font-size:10px; font-weight:800; letter-spacing:.12em; color:#6a8298; }
.portal-wms-nav { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; position:sticky; top:0; z-index:3; padding:10px 0; background:#f4f8fb; }
.portal-wms-nav a { text-decoration:none; color:#315e7e; background:#fff; border:1px solid #dbe7ef; border-radius:999px; padding:8px 12px; font-size:12px; font-weight:700; }
.portal-wms-nav a:hover,.portal-wms-nav a:focus-visible { background:#eef6fb; border-color:#bcd8e9; }
.portal-wms-stat { min-height:118px; padding:14px 15px; }
.portal-wms-stat .card-title { min-height:auto; margin:4px 0 8px; text-transform:none; }
.portal-analytics-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.portal-chart-card { min-width:0; }
.portal-chart-card .card-title { margin-bottom:12px; }
.portal-chart-empty { padding:20px 12px; border:1px dashed #cbd9e4; border-radius:10px; background:#fafcfe; color:var(--muted); text-align:center; }
.portal-progress { display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:center; gap:10px; }
.portal-progress > div { height:14px; overflow:hidden; border-radius:999px; background:#e8eef3; }
.portal-progress i { display:block; height:100%; background:currentColor; }
.portal-progress strong,.portal-bar-row strong { font-variant-numeric:tabular-nums; white-space:nowrap; }
.portal-bar-chart { display:grid; gap:8px; max-height:280px; overflow:auto; padding-right:4px; }
.portal-bar-row { display:grid; grid-template-columns:minmax(88px,130px) minmax(90px,1fr) auto; gap:8px; align-items:center; font-size:12px; }
.portal-bar-row > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.portal-bar-row > div { height:10px; overflow:hidden; border-radius:999px; background:#e8eef3; }
.portal-bar-row i { display:block; height:100%; background:currentColor; }
.portal-chart-summary { margin-top:10px; }
.portal-filter-grid { display:grid; grid-template-columns:2fr repeat(4,minmax(130px,1fr)); gap:10px; align-items:end; }
.portal-supporting-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
.portal-supporting-grid > .card { min-width:0; }.portal-filter-grid label { min-width:0; }
.portal-filter-grid input,.portal-filter-grid select { width:100%; }
.portal-product-name { min-width:220px; max-width:320px; white-space:normal; }
.portal-section-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; }
.portal-inline-filter { flex-direction:row; align-items:center; color:var(--text); white-space:nowrap; }
.portal-return-summary { display:grid; grid-template-columns:repeat(6,minmax(130px,1fr)); gap:8px; }
.portal-return-summary > div { padding:10px 12px; border:1px solid #e2ebf2; border-radius:10px; background:#fafcfe; font-size:12px; color:#5d7488; }
.portal-return-summary strong { display:block; margin-top:3px; color:var(--text); font-size:18px; font-variant-numeric:tabular-nums; }
.portal-exception-summary { display:flex; align-items:center; justify-content:space-between; gap:20px; border-left:4px solid #b91c1c; }
.portal-exception-summary > div:last-child { text-align:right; }
.portal-empty { padding:18px; text-align:center; color:var(--muted); background:#f8fbfd; border-radius:10px; }

@media (max-width: 1280px) {
  .portal-filter-grid { grid-template-columns:2fr repeat(2,minmax(150px,1fr)); }
  .portal-return-summary { grid-template-columns:repeat(3,minmax(130px,1fr)); }
}
@media (max-width: 1024px) {
  .portal-filter-grid { grid-template-columns:1fr 1fr; }
  .portal-supporting-grid,.portal-analytics-grid { grid-template-columns:1fr; }
}
@media (max-width: 760px) {
  .portal-filter-grid,.portal-return-summary { grid-template-columns:1fr; }  .portal-section-head,.portal-exception-summary { flex-direction:column; align-items:stretch; }
  .portal-exception-summary > div:last-child { text-align:left; }
}