:root {
  --sidebar: #0f1b2d;
  --sidebar-2: #162338;
  --sidebar-text: #c5d0e0;
  --sidebar-active: #1e90ff;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #122033;
  --muted: #6b7a90;
  --line: #e3e8ef;
  --primary: #1e90ff;
  --primary-ink: #ffffff;
  --ok: #16a34a;
  --ok-bg: #ecfdf3;
  --warn: #d97706;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.04), 0 8px 24px rgba(15, 27, 45, 0.06);
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg);
}

button, input, select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #0b1422 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.35rem 0.65rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1rem;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.sidebar-brand strong {
  display: block;
  color: #fff;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  display: block;
  font-size: 0.75rem;
  color: #8fa0b8;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  text-decoration: none;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.92rem;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: rgba(30, 144, 255, 0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.nav-ico {
  width: 1.1rem;
  text-align: center;
  opacity: 0.85;
}

.sidebar-foot {
  padding: 0.75rem 0.8rem;
  font-size: 0.78rem;
  color: #8fa0b8;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#health-pill { color: #4ade80; }

.main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.35rem 1.75rem 0.5rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.page-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

main {
  padding: 0.75rem 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.view { display: none; }
.view.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: rise 0.28s ease-out;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1.4rem;
}

.muted-card {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
}

.card-head h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.card-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.card-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.stat-row.compact { margin-top: 1rem; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  margin: 0.45rem 0 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 1.1rem;
  align-items: end;
}

.form-grid-wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.quote-grid, .import-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2 { grid-column: span 2; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

/* Shared field chrome — selects and free-style number boxes match */
select,
input[type="file"],
input.weight-input,
input.dim-input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  appearance: none;
  -webkit-appearance: none;
  max-height: 2.7rem;
  box-sizing: border-box;
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, #6b7a90 50%),
    linear-gradient(135deg, #6b7a90 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

select.country-select,
select.pieces-select,
select#service-select,
select.type-select {
  overflow-y: auto;
}

input.weight-input,
input.dim-input {
  font-variant-numeric: tabular-nums;
}

/* Hide native number spinners so fields match select height/look */
input.weight-input::-webkit-outer-spin-button,
input.weight-input::-webkit-inner-spin-button,
input.dim-input::-webkit-outer-spin-button,
input.dim-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input.weight-input,
input.dim-input {
  -moz-appearance: textfield;
  appearance: textfield;
}

.weight-box {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.weight-box .metric.chargeable {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.weight-box .metric.chargeable .v {
  color: var(--primary);
}

select:focus,
input:focus {
  outline: 2px solid rgba(30, 144, 255, 0.25);
  border-color: var(--primary);
}

input[type="file"] {
  background-image: none;
  padding: 0.55rem 0.7rem;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn.primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.btn.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.status {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  color: #1e3a5f;
  font-size: 0.9rem;
}

.status.error {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: #991b1b;
}

.table-wrap {
  margin-top: 1rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

td .file {
  color: var(--warn);
  font-size: 0.82rem;
  word-break: break-word;
}

.quote-result {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.quote-result .metric.chargeable {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.quote-result .metric.chargeable .v {
  color: var(--primary);
}

.metric {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem;
  background: #f8fafc;
}

.metric .k {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.metric .v {
  margin-top: 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric.total {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.metric.total .v { color: var(--primary); }

.result-card.success { border-color: #bbf7d0; }
.result-card.failed { border-color: #fecaca; }

.result-hero {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.result-hero h2 { margin: 0; font-size: 1.2rem; }
.result-hero p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.9rem; }

.check-circle,
.fail-circle {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 700;
  flex-shrink: 0;
}

.check-circle {
  background: var(--ok-bg);
  color: var(--ok);
}

.fail-circle {
  background: var(--danger-bg);
  color: var(--danger);
}

.confidence-row {
  margin-top: 1.1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.bar .fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: inherit;
  transition: width 0.4s ease;
}

.result-actions {
  margin-top: 1.15rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.help-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.help-grid article {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.help-grid h3 {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
}

.help-grid ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.audit-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.audit-list li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.audit-list .muted { color: var(--muted); border: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropzone {
  border: 1.5px dashed #c5d0e0;
  border-radius: 12px;
  padding: 1.25rem 1rem;
  background: #f8fafc;
  cursor: pointer;
  text-align: center;
  gap: 0.25rem !important;
}

.dropzone input[type="file"] {
  margin-top: 0.65rem;
}

.import-simple {
  grid-template-columns: 1fr;
}

.import-option {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.05rem;
  background: #f8fafc;
  gap: 0.4rem !important;
}

.import-option input[type="file"] {
  margin-top: 0.45rem;
}

.folder-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.55rem;
  min-height: 2.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
}

.folder-picker-actions {
  position: relative;
}

.sr-only-file {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.folder-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: #eef3f9;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
}

.folder-picker-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-hint {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
}

.folder-hint.warn {
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
}

.vendor-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.vendor-field span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.vendor-field input {
  max-width: 22rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

#import-folder-dropzone.is-dragover {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #93c5fd;
}

.folder-chip-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0;
}

.folder-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.55rem 0.75rem;
}

.folder-chip-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.folder-chip-meta strong {
  font-size: 0.9rem;
}

.folder-chip-meta span {
  color: var(--muted);
  font-size: 0.8rem;
}

.folder-chip-remove {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}

.folder-chip-remove:hover {
  background: #fee2e2;
  border-color: #fecaca;
}

.import-folder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: flex-end;
}

.btn.secondary {
  background: #eef3f9;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.secondary:hover {
  background: #e2e8f0;
}

.drop-title {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
}

.drop-sub {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.queue-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.queue-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.queue-list .badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
}

.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: #fff7ed; color: var(--warn); }
.badge.err { background: var(--danger-bg); color: var(--danger); }

.confidence-pill {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a5f;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.review-task-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.review-task-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}

.review-task-list .task-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.wizard-top #wizard-step-label {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.wizard-progress {
  display: flex;
  gap: 0.35rem;
  margin: 0.55rem 0 0.15rem;
}

.wiz-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #dbe3f0;
}

.wiz-dot.done {
  background: #93c5fd;
}

.wiz-dot.active {
  background: var(--primary);
  width: 1.1rem;
}

.wizard-ask {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid #bfdbfe;
  background: linear-gradient(180deg, #eff6ff 0%, #f8fbff 100%);
}

.wizard-ask-q {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: #0f2744;
}

.wizard-ask-hint {
  margin: 0.35rem 0 0;
  color: #3b5878;
  font-size: 0.88rem;
  line-height: 1.45;
}

.wiz-question-label {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet-legend {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  font-size: 0.82rem;
  color: #1e3a5f;
}

.sheet-legend-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 4px;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  flex-shrink: 0;
}

.sheet-range {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.sheet-preview th.row-num,
.sheet-preview td.row-num {
  position: sticky;
  left: 0;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
  min-width: 2.2rem;
  border-right: 1px solid var(--line);
}

.sheet-preview tr.hl th.row-num {
  background: #dbeafe;
}

.wizard-top h2 {
  margin: 0.35rem 0 0;
  font-size: 1.2rem;
}

.wizard-top p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.wizard-body {
  margin-top: 1.1rem;
}

.sheet-preview {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.sheet-preview table {
  font-size: 0.75rem;
}

.sheet-preview td.hl,
.sheet-preview tr.hl td {
  background: #dbeafe !important;
  font-weight: 600;
}

.choice-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.choice-stack label {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  color: var(--ink);
  font-size: 0.9rem;
  cursor: pointer;
}

.choice-stack label:has(input:checked) {
  border-color: var(--primary);
  background: #eff6ff;
}

.answer-summary {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.answer-summary ul {
  margin: 0;
  padding-left: 1.1rem;
}

.answer-summary li {
  margin: 0.25rem 0;
}

.country-map-table select {
  min-width: 8rem;
}

.candidate-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.candidate-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem;
  background: #f8fafc;
}

.candidate-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}

.candidate-card p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .stat-row,
  .form-grid,
  .quote-grid,
  .quote-result,
  .weight-box,
  .help-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .topbar, main { padding-left: 1rem; padding-right: 1rem; }
  .stat-row,
  .form-grid,
  .quote-grid,
  .quote-result,
  .weight-box,
  .help-grid {
    grid-template-columns: 1fr;
  }
  .span-2 { grid-column: span 1; }
}
