:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #102033;
  --muted: #64748b;
  --navy: #153a5b;
  --blue: #2563eb;
  --green: #0f766e;
  --orange: #b45309;
  --red: #dc2626;
  --line: #d7e0ea;
  --soft: #f8fbff;
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 16px auto 28px;
}

.hero {
  min-height: 148px;
  padding: 28px 32px;
  background: var(--navy);
  color: white;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.hero-copy h1 {
  margin: 4px 0 10px;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 700;
}

.hero-copy p {
  margin: 0;
  color: #d9eaf7;
  font-size: 18px;
  max-width: 860px;
}

.eyebrow {
  margin: 0;
  color: #9fd5ff;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.hero-meta {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-chip,
.badge {
  min-width: 150px;
  padding: 14px 16px;
  background: #e8f2fb;
  color: var(--navy);
}

.hero-chip-label {
  display: block;
  color: #5c7392;
  font-size: 12px;
  margin-bottom: 6px;
}

.badge {
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge.connected {
  background: #dcfce7;
  color: #166534;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0 0;
  flex-wrap: wrap;
}

.tab {
  border: 0;
  background: #dbe5f0;
  color: #334155;
  padding: 13px 18px;
  font-weight: 700;
  cursor: pointer;
  min-width: 146px;
}

.tab.active {
  background: var(--navy);
  color: white;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  margin-top: 18px;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.sidebar {
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

.panel-card {
  padding: 18px;
}

.panel-topbar {
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar-info {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
}

.topbar-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.topbar-actions,
.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.section-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dashboard-grid,
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-split {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.stat-card span,
.stat span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 600;
}

.stat-card strong,
.stat strong {
  font-size: 30px;
  line-height: 1;
}

.stat-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

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

.panel-head h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
}

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

.workflow-step {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.workflow-step.current {
  border-color: #8ab4df;
  background: #eef6ff;
}

.workflow-step.done {
  border-color: #86d6b8;
  background: #ecfdf5;
}

.workflow-step strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--navy);
  color: #fff;
  font-size: 15px;
}

.workflow-step.current strong {
  background: var(--blue);
}

.workflow-step.done strong {
  background: #16a34a;
}

.workflow-step span {
  font-weight: 700;
  color: #294a6b;
  line-height: 1.3;
}

.helper-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: linear-gradient(90deg, #f8fbff 0%, #eef6ff 100%);
}

.helper-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.helper-banner strong {
  display: block;
  font-size: 24px;
  margin-bottom: 6px;
}

.helper-banner p {
  margin: 0;
  color: #47627d;
}

.quick-actions {
  display: grid;
  gap: 10px;
}

.quick-action {
  justify-content: flex-start;
}

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

.list-summary-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.empty-state {
  color: var(--muted);
}

.upload-grid,
.rules-grid,
.split-grid,
.settings-grid {
  display: grid;
  gap: 16px;
}

.rules-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

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

.mini-card {
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 16px;
}

.mini-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.mini-list {
  margin: 0;
  padding-left: 18px;
  color: #42556b;
  display: grid;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  color: #334155;
}

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

textarea {
  min-height: 140px;
  padding: 12px;
  resize: vertical;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.inline-form input {
  flex: 1;
}

.search-input {
  min-width: 260px;
}

.combo {
  position: relative;
}

.combo-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(16, 32, 51, 0.12);
  z-index: 50;
}

.combo-option {
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 400;
}

.combo-option:hover {
  background: var(--soft);
}

.combo-option.empty {
  color: var(--muted);
  cursor: default;
}

.drop-zone {
  border: 2px dashed #93b6dc;
  background: #f6fbff;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--navy);
  text-align: center;
  padding: 12px;
}

.drop-zone.drag {
  border-color: var(--blue);
  background: #dbeafe;
}

.replace-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.license-meta {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.license-meta .stock {
  color: #166534;
  background: #dcfce7;
  padding: 3px 8px;
  font-weight: 700;
}

.license-meta .sku {
  background: #eaf2fb;
  color: var(--navy);
  padding: 3px 8px;
  font-family: Consolas, monospace;
}

.summary-banner {
  padding: 14px 16px;
  background: #f8fbff;
  border: 1px solid #cfe0f1;
  color: #294a6b;
  font-weight: 600;
}

.report-box {
  min-height: 240px;
  margin: 0;
  padding: 14px;
  background: #f8fbff;
  border: 1px solid var(--line);
  color: #294a6b;
  font: 14px Consolas, monospace;
  white-space: pre-wrap;
}

.stats .stat {
  min-height: 92px;
  border-left: 6px solid var(--blue);
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.stats .stat.ok {
  border-left-color: #16a34a;
}

.stats .stat.warn {
  border-left-color: var(--orange);
}

.stats .stat.error {
  border-left-color: var(--red);
}

.button {
  border: 0;
  min-height: 42px;
  padding: 0 18px;
  font-weight: 750;
  cursor: pointer;
  background: #64748b;
  color: white;
}

.button.small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
}

.button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.primary {
  background: var(--blue);
}

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

.accent,
.warn {
  background: var(--orange);
}

.danger {
  background: var(--red);
}

.secondary {
  background: #475569;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
}

.table-wrap.compact {
  max-height: 360px;
}

.table-wrap.tall {
  min-height: 420px;
  max-height: 520px;
}

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

th,
td {
  border-bottom: 1px solid #e2e8f0;
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eaf2fb;
  color: var(--navy);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  font-weight: 700;
  border-radius: 999px;
}

.status-pill.available {
  background: #dcfce7;
  color: #166534;
}

.status-pill.low {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.empty {
  background: #fee2e2;
  color: #991b1b;
}

.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  cursor: pointer;
}

.checkbox-card input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.checkbox-card span {
  display: grid;
  gap: 6px;
}

.checkbox-card strong {
  color: var(--ink);
}

.checkbox-card small {
  color: var(--muted);
}

.log {
  min-height: 640px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  background: #0f172a;
  color: #dceafe;
  font: 14px Consolas, monospace;
  padding: 14px;
  white-space: pre-wrap;
}

.log-textarea {
  min-height: 520px;
  font: 14px Consolas, monospace;
  background: #0f172a;
  color: #dceafe;
  border: 1px solid #20314d;
}

.login-dialog {
  width: min(560px, calc(100vw - 32px));
  border: 0;
  padding: 24px;
}

.login-dialog::backdrop {
  background: rgba(15, 23, 42, .45);
}

.copy-row {
  display: flex;
  gap: 10px;
}

.copy-row input {
  flex: 1;
}

.code {
  text-align: center;
  font: 700 18px Consolas, monospace;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

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

  .log {
    min-height: 220px;
    max-height: 280px;
  }
}

@media (max-width: 980px) {
  .dashboard-grid,
  .stats,
  .workflow-steps,
  .rules-grid,
  .split-grid,
  .settings-grid,
  .replace-controls,
  .dashboard-split {
    grid-template-columns: 1fr;
  }

  .panel-topbar,
  .hero,
  .panel-head,
  .helper-banner {
    flex-direction: column;
  }

  .search-input {
    min-width: 0;
    width: 100%;
  }
}
