:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #66737c;
  --line: #d9e0e4;
  --blue: #2864d8;
  --blue-dark: #184ea9;
  --green: #16794a;
  --yellow: #8a5b00;
  --red: #b42318;
  --amber-bg: #fff7e6;
  --red-bg: #fff0ef;
  --green-bg: #eaf7ef;
  --shadow: 0 10px 28px rgba(20, 31, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #9fb0ba;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  width: 100%;
}

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

button.danger {
  border-color: #f2b8b5;
  color: var(--red);
}

button.icon-button {
  width: 38px;
  padding: 0;
  font-weight: 700;
}

button.compact {
  width: auto;
  min-width: 92px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 120px;
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(520px, 1fr) minmax(260px, 340px);
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.job-list {
  display: grid;
  gap: 8px;
}

.job-item {
  width: 100%;
  text-align: left;
  height: auto;
  min-height: 54px;
  padding: 9px;
}

.job-item strong {
  display: block;
  font-size: 13px;
}

.job-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.segments {
  display: grid;
  gap: 12px;
}

.segment {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment-head {
  min-height: 42px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f9fbfc;
  border-bottom: 1px solid var(--line);
}

.segment-key {
  font-weight: 700;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-width: 54px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.green {
  color: var(--green);
  background: var(--green-bg);
}

.yellow {
  color: var(--yellow);
  background: var(--amber-bg);
}

.red {
  color: var(--red);
  background: var(--red-bg);
}

.segment-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
}

.source-box {
  min-height: 120px;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: #2b373f;
  background: #fcfdfe;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
  font-size: 13px;
}

.segment-foot {
  padding: 0 12px 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.issues {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.empty-state {
  color: var(--muted);
  min-height: 240px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.risk-summary,
.logs,
.storewide-jobs {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.metric,
.log-item,
.storewide-job {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  font-size: 13px;
  background: #fcfdfe;
}

.storewide-job-head,
.storewide-job-body {
  display: grid;
  gap: 4px;
}

.storewide-job-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.metric strong {
  display: block;
  font-size: 20px;
}

.metric span,
.log-item span,
.storewide-job span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state.small {
  min-height: 86px;
}

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

  .log-panel {
    grid-column: 1 / -1;
  }
}

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

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

  .segment-body {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
