:root {
  --bg: #f6f8fb;
  --panel: rgba(255, 255, 255, 0.74);
  --line: rgba(20, 38, 76, 0.15);
  --ink: #0f2240;
  --ink-soft: #5c6b89;
  --accent: #ff6a3d;
  --accent-2: #007ea7;
  --ok: #0f9d58;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Barlow", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 8% 10%, #ecfff8 0%, #f6f8fb 32%),
    radial-gradient(circle at 90% 20%, #e7f5ff 0%, rgba(231, 245, 255, 0) 35%),
    linear-gradient(130deg, #fefefe 0%, #f6f8fb 62%, #eef5ff 100%);
  min-height: 100vh;
}

.bg-orb {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(32px);
  opacity: 0.48;
}

.orb-a {
  width: 330px;
  height: 330px;
  background: #ff8b6b;
  top: -120px;
  left: -90px;
}

.orb-b {
  width: 360px;
  height: 360px;
  background: #60d8ff;
  right: -110px;
  bottom: -150px;
}

.app-shell {
  width: min(1240px, 92vw);
  margin: 28px auto 48px;
  display: grid;
  gap: 22px;
}

.calc-status-banner {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(12, 22, 39, 0.34);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.calc-status-banner[hidden] {
  display: none !important;
}

.calc-status-card {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: min(520px, 92vw);
  padding: 22px 24px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 34, 64, 0.92);
  color: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.calc-spinner {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ff8f68;
  animation: spin 0.8s linear infinite;
}

.calc-status-title {
  margin: 0 0 4px;
  font-family: "Syne", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.calc-status-copy {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.95rem;
}

.hero {
  padding: 28px 30px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  animation: rise 0.6s ease;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 700;
  font-size: 0.72rem;
}

h1,
h2,
h3 {
  font-family: "Syne", sans-serif;
}

h1 {
  margin: 10px 0 8px;
  font-size: clamp(2rem, 3.4vw, 3rem);
}

.version-id {
  margin: 0 0 10px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(20, 38, 76, 0.18);
  background: rgba(255, 255, 255, 0.86);
  color: #23395b;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  color: var(--ink-soft);
  max-width: 850px;
}

.page-nav {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

.nav-link {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.8);
}

.nav-link.active {
  background: #14264c;
  color: #fff;
  border-color: #14264c;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  padding: 20px;
  animation: rise 0.72s ease;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  padding: 16px;
}

.stack-form {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.form-mode-note {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-weight: 700;
}

.form-actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.calc-form {
  display: grid;
  gap: 14px;
}

.cargo-inline-row {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.cargo-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cargo-cbm-hint {
  font-weight: 700;
  color: #1f5e93;
  background: rgba(224, 243, 255, 0.9);
  border: 1px solid rgba(31, 94, 147, 0.22);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

#cargoRows {
  display: grid;
  gap: 8px;
}

.cargo-size-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 8px;
  border: 1px solid rgba(15, 34, 64, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
}

.cargo-size-row .cargo-remove-btn {
  white-space: nowrap;
  padding: 8px 10px;
}

.inventory-sync-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.inventory-sync-note {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 600;
}

.pallet-mode-field {
  display: grid;
  gap: 10px;
}

.solve-mode-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.solve-mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thinking-mode-hint {
  margin: 0;
  color: #b71c1c;
  font-weight: 700;
}

.pallet-mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.mode-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid rgba(20, 38, 76, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-weight: 700;
}

.mode-chip input:checked + span {
  background: #14264c;
  color: #fff;
  border-color: #14264c;
}

.pallet-mode-panel {
  border: 1px solid rgba(15, 34, 64, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
  padding: 12px;
}

.mode-help {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 600;
}

.pallet-choice-list,
.manual-pallet-rows {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.pallet-choice-row,
.manual-pallet-row {
  display: grid;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid rgba(15, 34, 64, 0.08);
  border-radius: 10px;
  background: rgba(248, 251, 255, 0.9);
}

.pallet-choice-row {
  grid-template-columns: minmax(0, 1fr) 120px;
}

.pallet-choice-meta {
  display: grid;
  gap: 2px;
}

.pallet-choice-title {
  color: var(--ink);
  font-weight: 700;
}

.pallet-choice-subtitle {
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.manual-pallet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.manual-pallet-row {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}

.manual-pallet-row .ghost-btn {
  white-space: nowrap;
}

.report-busy {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.report-busy .calc-spinner {
  width: 36px;
  height: 36px;
  border-width: 4px;
  border-top-color: var(--accent);
}

.report-busy-title {
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

.report-busy-copy {
  margin: 0;
  color: var(--ink-soft);
}

.report-busy-hot .report-busy-title {
  color: #c62828;
  font-size: 1.02rem;
}

.report-busy-hot .report-busy-copy {
  color: #b71c1c;
  font-weight: 700;
}

.report-busy-hot .calc-spinner {
  border-top-color: #e53935;
}

.ghost-btn {
  background: #eff8ff;
  color: #14264c;
  border: 1px solid rgba(20, 38, 76, 0.22);
}

.ghost-btn:hover {
  box-shadow: 0 6px 18px rgba(20, 38, 76, 0.16);
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
  color: var(--ink-soft);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: linear-gradient(120deg, var(--accent), #ff8656);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(255, 106, 61, 0.3);
}

.checkbox-line {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.table-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid rgba(15, 34, 64, 0.08);
  text-align: left;
  font-size: 0.93rem;
}

th {
  background: #eff8ff;
  position: sticky;
  top: 0;
}

td img {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.delete-btn {
  background: #14264c;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
}

.scenario-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.scenario-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  padding: 10px;
}

.scenario-card h4 {
  margin: 0 0 8px;
  color: #243b63;
  font-size: 0.95rem;
}

.scenario-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.scenario-head-row h4 {
  margin: 0;
}

.pallet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
}

.pallet-tab-btn {
  border: 1px solid rgba(20, 38, 76, 0.22);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.88);
  color: #1f3558;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.pallet-tab-btn.active {
  background: #1f3558;
  color: #fff;
  border-color: #1f3558;
}

.three-scenario {
  width: 100%;
  min-height: 280px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #f5fcff 0%, #edf4ff 100%);
  overflow: hidden;
  position: relative;
}

.cargo-hover-tip {
  position: absolute;
  z-index: 8;
  transform: translate(-50%, -110%);
  background: rgba(12, 25, 46, 0.9);
  color: #ecf4ff;
  border: 1px solid rgba(198, 218, 244, 0.35);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
}

.pallet-info-label {
  position: absolute;
  z-index: 7;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.76rem;
  line-height: 1.35;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.three-error {
  width: 100%;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8b1d2c;
  font-weight: 700;
  background: linear-gradient(180deg, #f5fcff 0%, #edf4ff 100%);
}

.report-card {
  display: grid;
  gap: 10px;
}

.report-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.report-head-row h3 {
  margin: 0;
}

#exportPdfBtn {
  padding: 8px 12px;
  border-radius: 10px;
}

#report {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  min-height: 120px;
  background: rgba(255, 255, 255, 0.8);
}

#report p {
  margin: 8px 0;
}

.good {
  color: var(--ok);
  font-weight: 700;
}

.dg-template-canvas {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: block;
}

.dg-template-cards {
  display: grid;
  gap: 10px;
}

.dg-template-size-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #f8fbff;
}

.dg-template-size-title {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.dg-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dg-template-face h4 {
  margin: 0 0 6px;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.dg-template-actions {
  display: flex;
  justify-content: flex-start;
}

.dg-template-tip {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

select[multiple] {
  padding: 6px 8px;
  min-height: 76px;
}

/* DG label checkbox list (input page) */
.dg-label-field { display: flex; flex-direction: column; gap: 4px; }
.dg-label-field .field-label {
  font-size: .78rem; font-weight: 600; color: var(--text-muted, #6b7a99);
  text-transform: uppercase; letter-spacing: .05em;
}
.dg-checkbox-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface, #f8faff);
  padding: 6px 8px;
  min-height: 60px;
  max-height: 120px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px 8px;
}
.dg-check-item {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 4px; border-radius: 5px; cursor: pointer;
  font-size: .85rem; color: var(--text, #1a2a4a);
  transition: background .15s;
  min-width: 0;
}
.dg-check-item:hover { background: rgba(74,144,217,.12); }
.dg-check-item input[type="checkbox"] { accent-color: #4a90d9; width: 14px; height: 14px; }
.dg-label-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-diamond { color: #c04010; font-size: .9rem; }
.dg-size { color: var(--text-muted, #6b7a99); font-size: .78rem; margin-left: 2px; }
.dg-empty { font-size: .82rem; color: #8899b0; padding: 6px 2px; grid-column: 1 / -1; }

/* Inventory DG table shape badges */
.diamond-badge {
  background: #fff3e0; color: #c04010;
  border: 1px solid #f5c07a; border-radius: 4px;
  padding: 1px 6px; font-size: .78rem; font-weight: 600;
}
.rect-badge {
  background: #e8f0fe; color: #2a4a73;
  border: 1px solid #a8c4e0; border-radius: 4px;
  padding: 1px 6px; font-size: .78rem;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .grid-2,
  .output-grid {
    grid-template-columns: 1fr;
  }

  .dg-template-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cargo-inline-row {
    grid-template-columns: 1fr;
  }

  .cargo-size-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .three-scenario {
    min-height: 250px;
  }

  .dg-checkbox-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .manual-pallet-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pallet-choice-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .cargo-inline-row {
    grid-template-columns: 1fr;
  }

  .cargo-size-row {
    grid-template-columns: 1fr;
  }

  .dg-checkbox-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manual-pallet-head {
    align-items: stretch;
    flex-direction: column;
  }

  .manual-pallet-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calc-status-card {
    min-width: 0;
    width: 100%;
    align-items: flex-start;
  }
}
