﻿:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --card: #fffaf2;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2d7c4;
  --accent: #b45309;
  --accent-dark: #7c2d12;
  --good: #166534;
  --warn: #a16207;
  --soft: #fef3c7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #fff7ed, var(--bg) 42%, #eef2ff);
  color: var(--ink);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 4vw, 38px); }
h2 { font-size: clamp(22px, 3vw, 34px); }
code {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 6px;
}

nav { display: flex; gap: 10px; }
button {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(180, 83, 9, 0.18);
}
button:hover { background: var(--accent-dark); }
.nav-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}
.nav-btn.active { background: var(--ink); color: white; }

main { padding: 28px; }
.page { display: none; }
.page.active { display: block; }

.hero-card, .card, .chat-panel, .sidebar {
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}
.hero-card { padding: clamp(24px, 5vw, 48px); max-width: 1100px; margin: 0 auto 24px; }

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 24px;
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: white;
}
textarea { resize: vertical; min-height: 56px; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
}
.card { padding: 18px; }
.card h3 { margin: 0 0 8px; font-size: 18px; }
.meta { color: var(--muted); font-size: 13px; margin: 8px 0; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--soft);
  color: #713f12;
  font-size: 12px;
  font-weight: 800;
  margin: 3px 5px 3px 0;
}
.ref-link {
  display: inline-block;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
  margin-top: 10px;
}

.chat-layout {
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  height: calc(100vh - 132px);
}
.chat-layout.active { display: grid; }
.sidebar { padding: 16px; overflow: auto; }
.full-btn { width: 100%; }
.side-title {
  margin: 18px 0 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.history-item {
  border: 1px solid var(--line);
  background: white;
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}
.history-item button {
  padding: 6px 8px;
  border-radius: 8px;
  background: #fee2e2;
  color: #991b1b;
  box-shadow: none;
}
.history-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }

.chat-panel {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}
.chat-area {
  overflow: auto;
  padding: 20px;
}
.message {
  display: flex;
  margin-bottom: 14px;
}
.message.user { justify-content: flex-end; }
.bubble {
  max-width: min(820px, 92%);
  padding: 14px 16px;
  border-radius: 18px;
  background: white;
  border: 1px solid var(--line);
  line-height: 1.5;
  white-space: pre-wrap;
}
.user .bubble {
  background: #172554;
  color: white;
  border-color: #172554;
}
.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.mini-card {
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.mini-label { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.mini-value { font-size: 18px; font-weight: 900; margin-top: 4px; }
.scenario {
  border-left: 4px solid var(--accent);
  padding-left: 12px;
  margin-top: 14px;
}
.option-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.option-btn {
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
  line-height: 1.35;
}
.option-btn:hover {
  background: var(--soft);
  color: var(--accent-dark);
}

dialog {
  width: min(1100px, 96vw);
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 40px 90px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(15, 23, 42, .68); }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--ink);
  color: white;
}
#sourceImage { display: block; max-width: 100%; height: auto; margin: 0 auto; background: white; }

@media (max-width: 780px) {
  .topbar { flex-direction: column; align-items: flex-start; padding: 18px; }
  main { padding: 14px; }
  .search-row, .chat-input-row, .chat-layout.active { grid-template-columns: 1fr; }
  .chat-layout { height: auto; }
  .chat-panel { min-height: 78vh; }
}

.shipment-layout.active { display: block; }
.shipment-hero { max-width: 1200px; }
.shipment-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
.upload-box { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-top: 12px; }
.upload-box input[type="file"] { background: white; border: 1px dashed var(--line); border-radius: 16px; padding: 14px; }
.shipment-grid { display: grid; grid-template-columns: minmax(320px, 0.9fr) minmax(380px, 1.1fr); gap: 18px; max-width: 1200px; margin: 0 auto; }
.shipment-summary h4 { margin: 18px 0 8px; }
.doc-row { border: 1px solid var(--line); background: white; border-radius: 14px; padding: 10px; margin: 8px 0; }
.warn-box { border-left: 4px solid var(--warn); background: #fffbeb; border-radius: 12px; padding: 10px; margin: 8px 0; overflow-wrap: anywhere; }
.shipment-chat { min-height: 360px; max-height: 58vh; overflow: auto; border: 1px solid var(--line); background: rgba(255,255,255,.55); border-radius: 18px; padding: 14px; margin-bottom: 12px; }
.info-box { border-left: 4px solid #2563eb; background: #eff6ff; border-radius: 12px; padding: 10px; margin: 8px 0; overflow-wrap: anywhere; }
.shipment-report { line-height: 1.55; }
.shipment-report h3 { margin: 0 0 10px; }
.shipment-report h4 { margin: 18px 0 8px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 9px; margin: 8px 0 12px; }
.report-card { border: 1px solid var(--line); background: rgba(255,255,255,.88); border-radius: 13px; padding: 10px; }
.report-label { color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.report-value { font-weight: 800; margin-top: 4px; overflow-wrap: anywhere; }
.formula-list { display: grid; gap: 8px; margin: 8px 0 12px; }
.formula-step { border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 10px; overflow-wrap: anywhere; }
.formula-step span { display: inline-block; margin-right: 10px; }
@media (max-width: 900px) { .shipment-grid, .upload-box { grid-template-columns: 1fr; } }


/* Shipment Bot UX refresh */
.shipment-hero { max-width: 1600px; }
.shipment-grid { grid-template-columns: minmax(340px, 0.75fr) minmax(720px, 1.45fr); max-width: 1600px; align-items: start; }
.shipment-grid > .card { min-height: auto; }
.shipment-chat { min-height: 68vh; max-height: none; overflow: auto; padding: 12px; background: rgba(255,255,255,.68); }
.shipment-chat .message.bot .bubble { max-width: 100%; width: 100%; }
.shipment-chat .message.user .bubble { max-width: min(760px, 85%); width: auto; }
.shipment-summary { font-size: .96rem; }
.shipment-status-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.compact-doc { padding: 9px 10px; margin: 7px 0; }
.compact-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px; margin: 8px 0; }
.kv-item { border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.92); padding: 10px; min-height: 64px; }
.kv-label { color: var(--muted); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; }
.kv-value { font-weight: 850; margin-top: 6px; overflow-wrap: anywhere; }
.kv-note { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.wide-report { white-space: normal; line-height: 1.45; }
.report-topline { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.report-topline h3 { margin: 0 0 8px; }
.report-download-btn { border: 1px solid var(--line); background: white; color: var(--ink); padding: 10px 14px; border-radius: 12px; cursor: pointer; font-weight: 800; }
.report-download-btn:hover { background: #fff7ed; }
.report-section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 14px; }
.report-section h4 { margin: 0 0 8px; }
.primary-report-section { background: rgba(255,251,235,.45); border: 1px solid #eadcc7; border-radius: 16px; padding: 12px; }
.formula-table { display: grid; gap: 8px; margin: 10px 0; }
.formula-row { display: grid; grid-template-columns: 34px 1fr minmax(150px, auto); gap: 10px; align-items: start; border: 1px solid var(--line); border-radius: 12px; background: white; padding: 10px; }
.formula-index { width: 26px; height: 26px; border-radius: 999px; background: #172554; color: white; display: grid; place-items: center; font-size: .78rem; font-weight: 900; }
.formula-numbers { text-align: right; display: grid; gap: 2px; font-size: .9rem; }
.conflict-card { border-left: 4px solid var(--warn); background: #fffbeb; border-radius: 12px; padding: 10px; margin: 8px 0; }
.conflict-values { display: grid; gap: 6px; margin-top: 8px; }
.conflict-values div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px dashed #e6d2aa; padding-top: 6px; }
.conflict-values small { color: var(--muted); text-align: right; }
@media (max-width: 1100px) { .shipment-grid { grid-template-columns: 1fr; } .shipment-chat { min-height: 55vh; } .formula-row { grid-template-columns: 28px 1fr; } .formula-numbers { grid-column: 2; text-align: left; } }

/* Detailed shipment calculation outcome */
.calculation-story h4 { margin: 16px 0 8px; }
.arrow-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 10px; align-items: center; margin: 10px 0 16px; }
.flow-node { border: 1px solid var(--line); background: white; border-radius: 16px; padding: 14px; min-height: 86px; }
.flow-node span { display: block; color: var(--muted); font-weight: 900; text-transform: uppercase; font-size: .72rem; letter-spacing: .03em; }
.flow-node strong { display: block; font-size: 1.18rem; margin-top: 6px; }
.flow-node small { display: block; color: var(--muted); margin-top: 5px; }
.flow-arrow { color: #92400e; font-size: 1.8rem; font-weight: 900; text-align: center; }
.benefit-table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: 10px 0 14px; }
.benefit-table th, .benefit-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.benefit-table th { background: #fff7ed; color: var(--muted); text-transform: uppercase; font-size: .75rem; letter-spacing: .03em; }
.benefit-table tr:last-child td { border-bottom: 0; }
@media (max-width: 900px) { .arrow-flow { grid-template-columns: 1fr; } .flow-arrow { transform: none; } }


/* Shipment Bot: chat-only layout */
.shipment-chat-layout.active { display: grid; }
.shipment-panel { min-height: 78vh; }
.shipment-panel .shipment-chat { min-height: 70vh; max-height: none; border: 0; margin-bottom: 0; }
.shipment-composer { grid-template-columns: minmax(220px, .75fr) minmax(320px, 1.5fr) auto; }
.shipment-id-inline { display: block; margin-top: 6px; }
.history-item.active { background: #fff7ed; }
@media (max-width: 900px) { .shipment-composer { grid-template-columns: 1fr; } }

.shipment-loading { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid #ead8bd; border-radius: 14px; background: #fffaf2; }
.spinner-dot { width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; border: 3px solid #f3d7b2; border-top-color: #b94f00; animation: spin .8s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.hs-options { display: grid; gap: 8px; margin-top: 8px; }
.hs-option-row { position: relative; padding-right: 150px; }
.hs-option-row strong { display: block; overflow-wrap: anywhere; }
.hs-option-btn { position: absolute; right: 10px; top: 10px; border: 1px solid var(--line); background: #172554; color: white; border-radius: 10px; padding: 7px 10px; font-weight: 800; cursor: pointer; }
.hs-option-btn:hover { background: #0f172a; }
.warn-text { color: #92400e; }
@media (max-width: 700px) { .hs-option-row { padding-right: 10px; } .hs-option-btn { position: static; margin: 8px 0 0; } }
