/* LoadPilot - professional B2B logistics UI (desktop first, responsive) */
:root {
  --brand: #12356b;
  --brand-dark: #0b2547;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --ok: #1e7a44;
  --ok-soft: #e6f4ea;
  --warn: #b7791f;
  --warn-soft: #fdf6e3;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --grey-50: #f7f9fc;
  --grey-100: #eef2f8;
  --grey-200: #dde5ee;
  --grey-400: #9aa7b8;
  --grey-600: #5b6472;
  --text: #16202c;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 32, 56, 0.08), 0 4px 12px rgba(16, 32, 56, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: var(--text);
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0; letter-spacing: 0.01em; text-transform: uppercase; color: var(--brand); }
h3 { font-size: 14px; margin: 0 0 8px; }
h4 { font-size: 13px; margin: 12px 0 6px; }
p { margin: 0 0 8px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--grey-100); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--grey-600); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------------- top navigation ---------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--brand); color: #fff;
  padding: 0 20px; height: 58px; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand strong { display: block; font-size: 15px; letter-spacing: 0.01em; }
.brand small { display: block; font-size: 11px; opacity: 0.75; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px;
  background: rgba(255,255,255,0.14); font-weight: 700; font-size: 13px;
}
.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a {
  color: rgba(255,255,255,0.85); padding: 8px 12px; border-radius: var(--radius);
  font-weight: 500; font-size: 13.5px;
}
.main-nav a:hover { background: rgba(255,255,255,0.1); text-decoration: none; }
.main-nav a.active { background: rgba(255,255,255,0.18); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.version { font-size: 11px; opacity: 0.7; }
.lang-selector { position: relative; }
.lang-btn {
  background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius); padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.lang-menu {
  position: absolute; right: 0; top: 38px; min-width: 170px; margin: 0; padding: 4px;
  list-style: none; background: #fff; border: 1px solid var(--grey-200);
  border-radius: var(--radius); box-shadow: var(--shadow); z-index: 40;
}
.lang-menu button {
  display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0;
  background: none; cursor: pointer; font-size: 13px; border-radius: 4px; color: var(--text);
}
.lang-menu button:hover { background: var(--grey-100); }
.lang-menu button.active { background: var(--accent-soft); color: var(--brand); font-weight: 600; }

/* ---------------- layout ---------------- */
.content { flex: 1; padding: 20px; max-width: 1500px; margin: 0 auto; width: 100%; }
.page { display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.app-footer {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; border-top: 1px solid var(--grey-200); background: var(--grey-50);
  color: var(--grey-600); font-size: 12px;
}

/* ---------------- panels, tables ---------------- */
.panel { background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--grey-200); background: var(--grey-50);
  border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap;
}
.panel-body { padding: 14px; }
.panel-actions { display: flex; gap: 8px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--grey-200); vertical-align: top; }
.table thead th { background: var(--grey-50); color: var(--grey-600); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.table tfoot th { background: var(--grey-50); }
.table.compact th, .table.compact td { padding: 5px 8px; font-size: 12.5px; }
.table tbody tr:hover { background: var(--grey-50); }
.table tr.clickable { cursor: pointer; }
.row-bad { background: var(--bad-soft); }
.row-warn { background: var(--warn-soft); }
.row-inactive { opacity: 0.55; }
.issue-row td { border-bottom: 1px solid var(--grey-200); background: #fff; }
.actions-col { width: 118px; white-space: nowrap; }
.table-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.search { padding: 7px 10px; border: 1px solid var(--grey-200); border-radius: var(--radius); min-width: 260px; font-size: 13px; }

/* ---------------- buttons, badges, tags ---------------- */
.btn {
  border: 1px solid var(--grey-200); background: #fff; color: var(--text);
  padding: 7px 12px; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500;
}
.btn:hover { background: var(--grey-50); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1a5fd0; }
.btn-secondary { border-color: var(--grey-200); }
.icon-btn {
  border: 1px solid transparent; background: none; cursor: pointer; font-size: 14px;
  padding: 3px 5px; border-radius: 4px; color: var(--grey-600);
}
.icon-btn:hover { background: var(--grey-100); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--accent-soft); color: var(--brand); }
.badge-neutral { background: var(--grey-100); color: var(--grey-600); }
.tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11.5px; margin: 0 4px 2px 0; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-error { background: var(--bad-soft); color: var(--bad); }
.tag-info { background: var(--accent-soft); color: var(--brand); }
.tag-neutral { background: var(--grey-100); color: var(--grey-600); }
.alert { padding: 9px 12px; border-radius: var(--radius); font-size: 13px; margin: 8px 0; }
.alert-error { background: var(--bad-soft); color: var(--bad); border-left: 3px solid var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-left: 3px solid var(--warn); }

/* ---------------- forms ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; color: var(--grey-600); font-weight: 600; }
.field-hint { font-size: 11.5px; color: var(--grey-600); }
.field-msg { font-size: 11.5px; color: var(--bad); }
.req { color: var(--bad); }
.field input, .field select, .field textarea {
  padding: 7px 9px; border: 1px solid var(--grey-200); border-radius: var(--radius); font-size: 13px;
  font-family: inherit; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.inline-check { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* ---------------- KPIs ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { padding: 10px 12px; border: 1px solid var(--grey-200); border-radius: var(--radius); background: var(--grey-50); }
.kpi-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand); }
.kpi-label { font-size: 11.5px; color: var(--grey-600); text-transform: uppercase; letter-spacing: 0.02em; }
.kpi-ok .kpi-value { color: var(--ok); }
.kpi-warn .kpi-value { color: var(--warn); }
.kpi-bad .kpi-value { color: var(--bad); }
.kpi-info .kpi-value { color: var(--accent); }

/* ---------------- issues, lists ---------------- */
ul.issues { list-style: none; margin: 0; padding: 0; }
.issue { display: flex; gap: 8px; padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--grey-200); }
.issue-error { color: var(--bad); }
.issue-warning { color: var(--warn); }
.issue-info { color: var(--grey-600); }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { padding: 5px 0; border-bottom: 1px solid var(--grey-100); }
.details-list { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--grey-600); }
.details-list li { margin-bottom: 4px; }
.empty { padding: 24px; text-align: center; background: var(--grey-50); border-radius: var(--radius); }

/* ---------------- results / visualization ---------------- */
.section-h { color: var(--brand); border-bottom: 1px solid var(--grey-200); padding-bottom: 4px; }
.packing-view { display: flex; flex-direction: column; gap: 10px; }
.packing-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.packing-svg { width: 100%; height: auto; background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius); }
.svg-label { font-size: 11px; fill: #fff; font-weight: 600; }
.svg-label-sm { font-size: 10px; fill: #fff; opacity: 0.9; }
.svg-dim { font-size: 12px; fill: var(--grey-600); }
.packing-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.packing-detail { min-height: 46px; background: var(--grey-50); border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 8px 10px; font-size: 12.5px; }
.packing-detail-card strong { color: var(--brand); }
.legend-note { display: flex; gap: 16px; font-size: 12px; color: var(--grey-600); flex-wrap: wrap; }
.legend-note i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: middle; }
.swatch-boundary { border: 2px solid #334155; background: #f8fafc; }
.swatch-occupied { background: #2b6cb0; }
.swatch-free { background: #f8fafc; border: 1px solid var(--grey-200); }
.unplaced { margin-top: 12px; }
.result-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px; }
.zone-bars { display: flex; flex-direction: column; gap: 6px; }
.zone-row { display: grid; grid-template-columns: 70px 1fr 150px; gap: 8px; align-items: center; font-size: 12.5px; }
.zone-bar { height: 12px; background: var(--grey-100); border-radius: 3px; overflow: hidden; display: block; }
.zone-fill { display: block; height: 100%; background: var(--accent); }

/* ---------------- modal, wizard, toast ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 32, 56, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 60;
}
.modal { background: #fff; border-radius: 8px; width: min(920px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--grey-200); }
.modal-head h3 { margin: 0; color: var(--brand); }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--grey-200); background: var(--grey-50); }
.steps { display: flex; gap: 16px; list-style: none; padding: 0; margin: 0 0 14px; font-size: 12px; color: var(--grey-600); flex-wrap: wrap; }
.steps li.active { color: var(--brand); font-weight: 700; }
.upload { border: 2px dashed var(--grey-200); border-radius: var(--radius); padding: 18px; background: var(--grey-50); }
.import-summary { display: flex; gap: 10px; margin-bottom: 6px; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.lang-card { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid var(--grey-200); background: #fff; border-radius: var(--radius); cursor: pointer; }
.lang-card.active { border-color: var(--accent); background: var(--accent-soft); }
.toast {
  position: fixed; right: 20px; bottom: 20px; padding: 11px 16px; border-radius: var(--radius);
  background: var(--brand); color: #fff; box-shadow: var(--shadow); cursor: pointer; z-index: 70; font-size: 13px;
}
.toast-ok { background: var(--ok); }
.toast-error { background: var(--bad); }
.toast-warn { background: var(--warn); }
.spinner { display: flex; align-items: center; gap: 8px; color: var(--grey-600); padding: 20px; }
.spinner .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 0.3; } to { opacity: 1; } }

@media (max-width: 1100px) {
  .two-col, .result-columns { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; }
  .content { padding: 14px; }
  .search { min-width: 100%; }
}
