:root {
  --bg: #181411;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
  --text: #fff8ef;
  --muted: rgba(255, 248, 239, 0.68);
  --tomato: #e34d36;
  --olive: #9bb86f;
  --steel: #8ca7b7;
  --fire: #f0a34a;
  --wine: #7f2d2d;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  height: 100%;
  min-height: 100%;
}
body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(227, 77, 54, 0.2), transparent 34%),
    linear-gradient(245deg, rgba(155, 184, 111, 0.15), transparent 36%),
    var(--bg);
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }

.shell {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px;
}

.login-view {
  min-height: calc(100vh - 28px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(470px, 100%);
  display: grid;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(24,20,17,0.9), rgba(15,12,11,0.96)),
    url("https://thedoughlab.eu/wp-content/uploads/2025/12/kep-5.1-1024x1024.png") center/cover no-repeat;
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-logo {
  display: block;
  width: min(214px, 50vw);
  height: auto;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
}

.brand-context {
  color: rgba(255,248,239,0.74);
  font-size: 13px;
  font-weight: 900;
}

.login-copy {
  display: grid;
  gap: 8px;
}

.login-copy h1 {
  font-size: clamp(38px, 8vw, 62px);
  line-height: 0.96;
}

.login-copy p,
.auth-message,
.detail-head p,
.section-title span,
.next-action-hint {
  color: var(--muted);
}

.auth-message.error { color: #ffd0c2; }

.app-view {
  min-height: calc(100vh - 28px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}

.topbar {
  min-height: 70px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24,20,17,0.84);
  backdrop-filter: blur(18px);
}

.station-pill,
.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.station-pill {
  justify-self: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--olive);
  box-shadow: 0 0 0 5px rgba(155,184,111,0.18);
}

.top-actions {
  justify-self: end;
  flex-wrap: wrap;
}

.eyebrow {
  color: var(--tomato);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-height: 52px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255,255,255,0.08);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(227,77,54,0.62);
  box-shadow: 0 0 0 4px rgba(227,77,54,0.14);
}

.primary-button,
.ghost-button {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
}

.primary-button {
  background: linear-gradient(135deg, var(--tomato), var(--fire));
  box-shadow: 0 14px 28px rgba(227,77,54,0.24);
}

.primary-button:disabled,
.ghost-button[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.44;
}

.ghost-button {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.16);
}

.ghost-button.compact {
  min-height: 40px;
  padding: 0 12px;
  font-size: 12px;
}

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

.summary-card {
  min-height: 102px;
  display: grid;
  align-content: space-between;
  padding: 14px;
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.2);
}

.summary-card span {
  color: rgba(255,255,255,0.82);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-card strong {
  font-size: 38px;
  line-height: 1;
}

.summary-card.ready { background: linear-gradient(135deg, #657b4e, #9bb86f); }
.summary-card.blocked { background: linear-gradient(135deg, #7f2d2d, #e34d36); }
.summary-card.progress { background: linear-gradient(135deg, #376173, #8ca7b7); }
.summary-card.planned { background: linear-gradient(135deg, #f0a34a, #d85d36); }

.production-command-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(560px, 1.8fr) minmax(340px, 0.85fr);
  gap: 12px;
}

.queue-panel,
.detail-panel,
.action-panel {
  min-height: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(24,20,17,0.92), rgba(15,12,11,0.96));
  box-shadow: var(--shadow);
}

.queue-panel,
.detail-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.action-panel {
  align-content: start;
  overflow: auto;
}

.panel-head,
.detail-head,
.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2,
.action-box h2,
.manual-plan-box h2,
.section-title h2 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1;
}

.detail-head {
  align-items: start;
}

.detail-head h1 {
  margin-top: 5px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 0.94;
}

.detail-head p {
  margin-top: 8px;
  font-weight: 750;
}

.flow-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.flow-step {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,0.07);
  font-size: 11px;
  font-weight: 900;
}

.flow-step.done {
  color: #fff;
  border-color: rgba(155,184,111,0.36);
  background: rgba(101,123,78,0.32);
}

.flow-step.current {
  color: #fff;
  border-color: rgba(240,163,74,0.55);
  background: rgba(240,163,74,0.24);
}

.flow-step.blocked {
  color: #fff;
  border-color: rgba(227,77,54,0.56);
  background: rgba(227,77,54,0.28);
}

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

.filter-button {
  min-height: 36px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  font-size: 11px;
  font-weight: 900;
}

.filter-button.active {
  color: #fff;
  background: rgba(227,77,54,0.72);
}

.production-queue-list,
.readiness-list,
.material-coverage {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 9px;
  overflow: auto;
  padding-right: 4px;
}

.production-row {
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 11px;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.12);
  border-left: 8px solid var(--steel);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

.production-row.active {
  border-color: rgba(255,255,255,0.3);
  box-shadow: 0 0 0 3px rgba(227,77,54,0.14);
}

.production-row.ready { border-left-color: var(--olive); }
.production-row.blocked { border-left-color: var(--tomato); }
.production-row.in-progress { border-left-color: var(--steel); }
.production-row.completed { border-left-color: var(--muted); opacity: 0.68; }

.production-row strong {
  font-size: 15px;
  line-height: 1.05;
}

.production-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-pill {
  width: max-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 8px;
  color: #fff;
  background: rgba(255,255,255,0.14);
  font-size: 11px;
  font-weight: 900;
}

.status-pill.ready { background: rgba(101,123,78,0.95); }
.status-pill.blocked { background: rgba(227,77,54,0.95); }
.status-pill.in-progress { background: rgba(55,97,115,0.95); }
.status-pill.completed { background: rgba(170,178,192,0.7); }

.readiness-section,
.coverage-section,
.action-box,
.manual-plan-box {
  display: grid;
  gap: 11px;
  padding: 13px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
}

.replenishment-plan-list {
  max-height: 210px;
  min-height: 92px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding-right: 3px;
}

.replenishment-row {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.13);
  border-left: 6px solid var(--olive);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  background: rgba(15,12,11,0.42);
}

.replenishment-row span,
.replenishment-row em {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.policy-editor {
  display: grid;
  gap: 9px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.checkbox-row {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.readiness-card,
.coverage-card,
.empty-card {
  display: grid;
  gap: 6px;
  padding: 11px;
  border: 1px solid rgba(255,255,255,0.12);
  border-left: 8px solid var(--steel);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
}

.readiness-card.blocked,
.coverage-card.short {
  border-left-color: var(--tomato);
}

.readiness-card.ready,
.coverage-card.ready {
  border-left-color: var(--olive);
}

.readiness-card strong,
.coverage-card strong,
.empty-card strong {
  font-size: 14px;
}

.readiness-card span,
.coverage-card span,
.empty-card span,
.action-box p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.next-action-details {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  border-left: 6px solid var(--fire);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
}

.next-action-details:empty {
  display: none;
}

.next-action-details strong {
  font-size: 13px;
}

.next-action-details span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.coverage-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}

.coverage-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tomato), var(--fire));
}

.coverage-card.ready .coverage-meter span {
  background: linear-gradient(90deg, #657b4e, #9bb86f);
}

.action-box .primary-button,
.action-box .action-link,
.manual-plan-box .ghost-button {
  width: 100%;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(380px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(24,20,17,0.96);
  box-shadow: var(--shadow);
}

@media (max-width: 1220px) {
  .topbar,
  .production-command-shell {
    grid-template-columns: 1fr;
  }
  .station-pill,
  .top-actions {
    justify-self: stretch;
  }
  .top-actions {
    justify-content: start;
  }
  .production-command-shell {
    min-height: auto;
  }
  .detail-panel { order: 1; }
  .action-panel { order: 2; }
  .queue-panel { order: 3; }
  .queue-panel,
  .detail-panel {
    max-height: none;
  }
}

@media (min-width: 1221px) {
  body {
    overflow: hidden;
  }

  .shell {
    height: 100vh;
    overflow: hidden;
  }

  .app-view {
    height: calc(100vh - 28px);
    min-height: 0;
  }

  .production-command-shell {
    overflow: hidden;
  }

  .queue-panel,
  .detail-panel {
    overflow: hidden;
  }
}

@media (max-width: 760px) {
  .shell { padding: 10px; }
  .summary-grid,
  .filter-row,
  .split {
    grid-template-columns: 1fr;
  }
  .panel-head,
  .detail-head,
  .section-title {
    display: grid;
  }
  .detail-head h1 {
    font-size: 34px;
  }
  .top-actions .ghost-button {
    width: 100%;
  }
}
