:root {
  --bg: #082e22;
  --bg-deep: #061f18;
  --panel: rgba(11, 55, 42, 0.94);
  --panel-strong: rgba(13, 66, 50, 0.98);
  --line: rgba(222, 196, 124, 0.18);
  --line-soft: rgba(255, 255, 255, 0.09);
  --text: #f4f6ef;
  --muted: rgba(255, 255, 255, 0.66);
  --gold-1: #f2dea2;
  --gold-2: #d8b25a;
  --gold-3: #a97823;
  --red: #ff7c7c;
  --red-bg: rgba(180, 43, 43, 0.22);
  --yellow: #f6ce63;
  --yellow-bg: rgba(216, 178, 90, 0.18);
  --blue: #8ec7ff;
  --green: #8ddca6;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(216, 178, 90, 0.12), transparent 31%),
    linear-gradient(180deg, #0a382b 0%, var(--bg-deep) 100%);
}

button,
input,
select {
  font: inherit;
}

.planning-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 24px auto 40px;
  display: grid;
  gap: 16px;
}

.planning-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 4px 8px;
}

.planning-back {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-bottom: 8px;
  color: var(--gold-1);
  text-decoration: none;
  font-size: 13px;
  font-weight: 750;
}

.planning-back::before {
  content: "<";
  margin-right: 8px;
}

.planning-eyebrow {
  margin: 0 0 7px;
  color: var(--gold-2);
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 760;
  color: #fff9e8;
}

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

.primary-upload,
.ghost-btn {
  min-height: 44px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
}

.primary-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 164px;
  padding: 0 18px;
  color: #13281d;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 62%, var(--gold-3) 100%);
  border: 1px solid rgba(255, 237, 183, 0.22);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
}

.secondary-upload {
  min-width: 150px;
  color: #f9e9b8;
  background: rgba(216, 178, 90, 0.12);
  border-color: rgba(216, 178, 90, 0.42);
  box-shadow: none;
}

.primary-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.ghost-btn {
  min-width: 128px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(244, 246, 239, 0.84);
}

.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.metric-card,
.decision-strip,
.control-panel,
.message-box,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 92px;
  padding: 15px 17px;
  display: grid;
  align-content: center;
  gap: 5px;
}

.metric-card span,
.field span,
.target-field span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-card strong {
  min-width: 0;
  color: #fff9e8;
  font-size: 25px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric-card small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

#reportFile,
#planFile {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-card.alert strong {
  color: #ffd0d0;
}

.metric-card.warn strong {
  color: var(--yellow);
}

.metric-card.plan strong {
  color: var(--blue);
}

.decision-strip {
  display: grid;
  grid-template-columns: 1.35fr 1fr 0.7fr;
  gap: 1px;
  overflow: hidden;
}

.decision-strip div {
  min-width: 0;
  padding: 15px 17px;
  background: rgba(255, 255, 255, 0.025);
}

.decision-strip span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.decision-strip strong {
  display: block;
  color: #fff9e8;
  font-size: 19px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 180px 180px minmax(230px, 0.8fr);
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.field,
.target-field {
  display: grid;
  gap: 7px;
}

.field input,
.field select {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: #0b2f24;
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: rgba(216, 178, 90, 0.7);
  box-shadow: 0 0 0 3px rgba(216, 178, 90, 0.12);
}

.target-field {
  align-self: stretch;
  justify-content: center;
}

.target-field strong {
  color: #fff9e8;
  font-size: 12px;
}

.target-field input {
  accent-color: var(--gold-2);
}

.message-box {
  min-height: 44px;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 14px;
}

.message-box.is-error {
  color: #ffd2d2;
}

.table-wrap {
  overflow: hidden;
}

.planning-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.planning-table th,
.planning-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

.planning-table th {
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.planning-table th:nth-child(1),
.planning-table td:nth-child(1) {
  width: 118px;
}

.planning-table th:nth-child(2),
.planning-table td:nth-child(2) {
  width: 240px;
}

.planning-table th:nth-child(3),
.planning-table td:nth-child(3) {
  width: 132px;
}

.planning-table th:nth-child(4),
.planning-table td:nth-child(4),
.planning-table th:nth-child(5),
.planning-table td:nth-child(5),
.planning-table th:nth-child(6),
.planning-table td:nth-child(6) {
  width: 132px;
}

.planning-table th:nth-child(7),
.planning-table td:nth-child(7) {
  width: 132px;
}

.planning-table th:nth-child(8),
.planning-table td:nth-child(8) {
  width: 230px;
}

.planning-table td {
  color: #f7f4e9;
  font-size: 14px;
  line-height: 1.35;
}

.data-row {
  cursor: pointer;
}

.data-row:hover td {
  background: rgba(255, 255, 255, 0.025);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.status-red {
  color: #ffd9d9;
  background: var(--red-bg);
  border-color: rgba(255, 124, 124, 0.3);
}

.status-yellow,
.status-seasonal {
  color: #ffe8a5;
  background: var(--yellow-bg);
  border-color: rgba(246, 206, 99, 0.28);
}

.status-review {
  color: #ffe8a5;
  background: rgba(216, 178, 90, 0.14);
  border-color: rgba(246, 206, 99, 0.24);
}

.status-dormant {
  color: #ffe8a5;
  background: rgba(216, 178, 90, 0.12);
  border-color: rgba(246, 206, 99, 0.22);
}

.status-ok,
.status-delivery {
  color: #d7f7dd;
  background: rgba(71, 160, 92, 0.18);
  border-color: rgba(141, 220, 166, 0.2);
}

.status-over {
  color: #d2e9ff;
  background: rgba(65, 135, 199, 0.18);
  border-color: rgba(142, 199, 255, 0.22);
}

.status-idle {
  color: rgba(244, 246, 239, 0.7);
  background: rgba(255, 255, 255, 0.06);
}

.status-stale {
  color: #d2e9ff;
  background: rgba(142, 199, 255, 0.1);
  border-color: rgba(142, 199, 255, 0.18);
}

.material-symbol {
  color: var(--gold-1);
  font-weight: 820;
}

.material-name {
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.material-category,
.small-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.qty-main {
  font-variant-numeric: tabular-nums;
  font-weight: 820;
}

.qty-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.plan-sub {
  color: var(--blue);
}

.shortage-sub,
.detail-warning {
  color: #ffd0d0;
}

.trend-up {
  color: #ffcd9b;
}

.trend-down {
  color: #a8dcff;
}

.trend-flat {
  color: rgba(244, 246, 239, 0.78);
}

.trend-mixed {
  color: #ffe8a5;
}

.recommendation {
  font-weight: 780;
  overflow-wrap: anywhere;
}

.reason-cell {
  color: rgba(244, 246, 239, 0.82);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.recommendation.warn {
  color: #ffe8a5;
}

.recommendation.good {
  color: #d7f7dd;
}

.detail-row td {
  padding: 0;
  background: rgba(2, 24, 18, 0.34);
}

.detail-panel {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 16px;
  padding: 16px;
}

.detail-panel.has-plan {
  grid-template-columns: minmax(690px, 1.35fr) minmax(230px, 0.48fr) minmax(360px, 0.75fr);
}

.detail-block {
  min-width: 0;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
}

.detail-title {
  color: var(--gold-1);
  font-size: 13px;
  font-weight: 820;
  margin-bottom: 10px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(13, minmax(42px, 1fr));
  gap: 6px;
}

.month-cell {
  min-height: 74px;
  display: grid;
  align-content: end;
  gap: 5px;
  padding: 7px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.month-cell.is-current {
  outline: 1px solid rgba(246, 206, 99, 0.28);
}

.month-bar {
  width: 100%;
  min-height: 3px;
  border-radius: 999px 999px 2px 2px;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
}

.month-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  white-space: nowrap;
}

.month-value {
  color: #fff9e8;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.detail-list {
  display: grid;
  gap: 7px;
  color: rgba(244, 246, 239, 0.84);
  font-size: 13px;
}

.detail-list div {
  overflow-wrap: anywhere;
}

.plan-detail-list {
  display: grid;
  gap: 14px;
  color: rgba(244, 246, 239, 0.84);
  font-size: 12px;
  line-height: 1.45;
}

.plan-detail-line {
  overflow-wrap: anywhere;
}

.plan-detail-item {
  display: grid;
  gap: 5px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.plan-detail-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.plan-detail-date,
.plan-detail-kg {
  color: #fff9e8;
  font-weight: 820;
}

.plan-detail-date {
  color: var(--gold-1);
}

.plan-detail-sku,
.plan-detail-customer {
  overflow-wrap: anywhere;
}

.plan-detail-customer {
  color: var(--muted);
}

.plan-detail-more {
  color: var(--muted);
}

.empty-row td {
  height: 112px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .planning-shell {
    width: min(100vw - 20px, 1380px);
    margin-top: 12px;
  }

  .planning-header {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .planning-actions,
  .primary-upload,
  .ghost-btn {
    width: 100%;
  }

  .metric-grid,
  .decision-strip,
  .control-panel,
  .detail-panel {
    grid-template-columns: 1fr;
  }

  .detail-panel.has-plan {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .planning-table {
    min-width: 1240px;
  }

  .month-grid {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
  }
}
