/* ── Logibot Design System ─────────────────────────────────────────────────── */

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --lb-blue: #0768FF;
  --lb-accent: #52B5FF;
  --lb-near-black: #231F20;
  --lb-charcoal: #333333;
  --lb-text: #333333;
  --lb-muted: #6B7280;
  --lb-border: #E5E7EB;
  --lb-bg: #F5F6F8;
  --lb-surface: #FFFFFF;
  --lb-success: #1D9E75;
  --lb-warning: #D97706;
  --lb-danger: #DC2626;
  --lb-font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --lb-font-mono: 'DM Mono', 'Cascadia Code', monospace;
  --lb-sidebar-w: 220px;
  --lb-topbar-h: 52px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--lb-font-body);
  font-size: 14px;
  color: var(--lb-text);
  background: var(--lb-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ── Shell ────────────────────────────────────────────────────────────────── */
.lb-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.lb-sidebar {
  width: var(--lb-sidebar-w);
  flex-shrink: 0;
  background: var(--lb-near-black);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

.lb-sidebar__logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.lb-sidebar__logo img {
  height: 36px;
  width: auto;
}

.lb-sidebar__nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lb-sidebar__section {
  padding: 16px 18px 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}

.lb-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.lb-sidebar__link:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.04);
}
.lb-sidebar__link.active {
  color: #fff;
  background: rgba(7,104,255,0.15);
  border-left-color: var(--lb-blue);
  font-weight: 600;
}
.lb-sidebar__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.lb-sidebar__link.active svg {
  opacity: 1;
}

.lb-sidebar__badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--lb-font-mono);
  background: rgba(220,53,69,0.2);
  color: #f87171;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.lb-sidebar__badge--muted {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.45);
}

.lb-sidebar__footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.lb-sidebar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--lb-blue);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lb-sidebar__user-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  line-height: 1.2;
}
.lb-sidebar__user-company {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
}

/* ── Main area ────────────────────────────────────────────────────────────── */
.lb-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.lb-topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--lb-topbar-h);
  background: var(--lb-surface);
  border-bottom: 1px solid var(--lb-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.lb-topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lb-topbar__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--lb-near-black);
}

.lb-topbar__breadcrumb {
  font-size: 12px;
  color: var(--lb-muted);
}

.lb-topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#lb-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--lb-near-black);
  padding: 6px;
}

/* ── Flash messages ───────────────────────────────────────────────────────── */
.lb-flash {
  padding: 12px 28px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.4s;
}
.lb-flash--success { background: #ECFDF5; color: #065F46; border-bottom: 1px solid #A7F3D0; }
.lb-flash--error   { background: #FEF2F2; color: #991B1B; border-bottom: 1px solid #FECACA; }
.lb-flash--warning { background: #FFFBEB; color: #92400E; border-bottom: 1px solid #FDE68A; }
.lb-flash--info    { background: #EFF6FF; color: #1E40AF; border-bottom: 1px solid #BFDBFE; }

/* ── Content area ─────────────────────────────────────────────────────────── */
.lb-content {
  padding: 28px;
  overflow-y: auto;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.lb-card {
  background: var(--lb-surface);
  border: 1px solid var(--lb-border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-bottom: 20px;
}

.lb-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--lb-border);
}

.lb-card__header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lb-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--lb-near-black);
}

.lb-card__sub {
  font-size: 12px;
  color: var(--lb-muted);
}

.lb-card__body {
  padding: 18px 22px;
}

/* ── Grid helpers ─────────────────────────────────────────────────────────── */
.lb-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lb-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.lb-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Stat boxes (KPI) ─────────────────────────────────────────────────────── */
.lb-stat-strip {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.lb-stat {
  flex: 1;
  min-width: 150px;
  background: var(--lb-surface);
  border: 1px solid var(--lb-border);
  border-radius: 10px;
  padding: 18px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.lb-stat__label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lb-muted);
  margin-bottom: 8px;
}

.lb-stat__value {
  font-family: var(--lb-font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--lb-near-black);
  line-height: 1.1;
}
.lb-stat__value--success { color: var(--lb-success); }
.lb-stat__value--warning { color: var(--lb-warning); }
.lb-stat__value--danger  { color: var(--lb-danger); }

.lb-stat__meta {
  font-size: 11px;
  color: var(--lb-muted);
  margin-top: 4px;
}

/* ── Step wizard ──────────────────────────────────────────────────────────── */
.lb-steps {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
}
.lb-steps__step {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  border-bottom: 3px solid var(--lb-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--lb-muted);
  transition: all 0.2s;
}
.lb-steps__step.active { border-color: var(--lb-blue); color: var(--lb-text); }
.lb-steps__step.done   { border-color: var(--lb-success); color: var(--lb-success); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.lb-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.lb-field > label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--lb-muted);
}

.lb-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--lb-border);
  border-radius: 7px;
  font-family: var(--lb-font-body);
  font-size: 13px;
  color: var(--lb-text);
  background: #FAFBFC;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lb-input:focus {
  border-color: var(--lb-blue);
  box-shadow: 0 0 0 3px rgba(7,104,255,0.1);
}

.lb-select {
  width: 100%;
  padding: 9px 32px 9px 12px;
  border: 1.5px solid var(--lb-border);
  border-radius: 7px;
  font-family: var(--lb-font-body);
  font-size: 13px;
  color: var(--lb-text);
  background: #FAFBFC url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lb-select:focus {
  border-color: var(--lb-blue);
  box-shadow: 0 0 0 3px rgba(7,104,255,0.1);
}

.lb-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--lb-border);
  border-radius: 7px;
  font-family: var(--lb-font-body);
  font-size: 13px;
  color: var(--lb-text);
  background: #FAFBFC;
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lb-textarea:focus {
  border-color: var(--lb-blue);
  box-shadow: 0 0 0 3px rgba(7,104,255,0.1);
}

.lb-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.lb-toggle input { accent-color: var(--lb-blue); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.lb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 7px;
  font-family: var(--lb-font-body);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.lb-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.lb-btn--primary {
  background: var(--lb-blue);
  color: #fff;
}
.lb-btn--primary:hover { background: #0558D9; }

.lb-btn--secondary {
  background: var(--lb-charcoal);
  color: #fff;
}
.lb-btn--secondary:hover { background: #222; }

.lb-btn--ghost {
  background: transparent;
  color: var(--lb-blue);
  border: 1px solid rgba(7,104,255,0.3);
}
.lb-btn--ghost:hover {
  background: rgba(7,104,255,0.06);
  border-color: rgba(7,104,255,0.5);
}

.lb-btn--danger {
  background: var(--lb-danger);
  color: #fff;
}
.lb-btn--danger:hover { background: #B91C1C; }

.lb-btn--success {
  background: var(--lb-success);
  color: #fff;
}
.lb-btn--success:hover { background: #167A5B; }

.lb-btn--sm { padding: 5px 12px; font-size: 12px; height: 30px; }
.lb-btn--lg { padding: 12px 24px; font-size: 14px; height: 44px; }

/* ── Status pills ─────────────────────────────────────────────────────────── */
.lb-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.lb-pill--booked    { background: #FFFBEB; color: #B45309; border: 1px solid #FDE68A; }
.lb-pill--transit   { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.lb-pill--delivered { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.lb-pill--exception { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.lb-pill--pending   { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.lb-pill--cancelled { background: #F3F4F6; color: #6B7280; border: 1px solid #D1D5DB; }
.lb-pill--customs   { background: #FDF4FF; color: #7C3AED; border: 1px solid #E9D5FF; }
.lb-pill--disputed  { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.lb-pill--paid      { background: #ECFDF5; color: #059669; border: 1px solid #A7F3D0; }
.lb-pill--compliant { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.lb-pill--blocked   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.lb-pill--review    { background: #F3F4F6; color: #6B7280; border: 1px solid #D1D5DB; }
.lb-pill--dispatched { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.lb-pill--failed    { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.lb-pill--overdue   { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.lb-pill--expiring  { background: #FFFBEB; color: #B45309; border: 1px solid #FDE68A; }

/* ── Rate cards ───────────────────────────────────────────────────────────── */
.lb-rate-card {
  background: var(--lb-surface);
  border: 1px solid var(--lb-border);
  border-radius: 10px;
  padding: 18px 22px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lb-rate-card:hover {
  border-color: var(--lb-blue);
  box-shadow: 0 2px 8px rgba(7,104,255,0.08);
}

/* ── Data table ───────────────────────────────────────────────────────────── */
.lb-table-wrap {
  background: var(--lb-surface);
  border: 1px solid var(--lb-border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
}

.lb-table th {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lb-muted);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--lb-border);
  white-space: nowrap;
  background: #FAFBFC;
}

.lb-table td {
  padding: 13px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--lb-border);
  vertical-align: middle;
  color: var(--lb-text);
}
.lb-table tr:last-child td { border-bottom: none; }
.lb-table tbody tr:hover td { background: #F8FAFF; }

.lb-table td:first-child { font-weight: 600; }

.lb-table__actions {
  text-align: right;
  white-space: nowrap;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.lb-table__mono {
  font-family: var(--lb-font-mono);
  font-size: 12px;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.lb-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--lb-border);
  margin-bottom: 20px;
}
.lb-tabs [data-tab] {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--lb-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all 0.15s;
}
.lb-tabs [data-tab].active {
  color: var(--lb-blue);
  border-bottom-color: var(--lb-blue);
  font-weight: 600;
}
[data-panel] { display: none; }
[data-panel].active { display: block; }

/* ── Sort chips ───────────────────────────────────────────────────────────── */
.lb-sort-group {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.lb-sort-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border: 1px solid var(--lb-border);
  border-radius: 20px;
  background: transparent;
  color: var(--lb-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.lb-sort-chip.active {
  background: var(--lb-blue);
  color: #fff;
  border-color: var(--lb-blue);
}

/* ── Kanban ───────────────────────────────────────────────────────────────── */
.lb-kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.lb-kanban__col {
  background: var(--lb-surface);
  border: 1px solid var(--lb-border);
  border-radius: 10px;
  padding: 16px;
  min-height: 300px;
}

.lb-kanban__col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--lb-border);
}

.lb-kanban__col-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--lb-near-black);
}

.lb-kanban__col-count {
  margin-left: auto;
  font-family: var(--lb-font-mono);
  font-size: 11px;
  color: var(--lb-muted);
}

.lb-kanban__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lb-kanban__card {
  background: var(--lb-bg);
  border: 1px solid var(--lb-border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lb-kanban__card:hover {
  border-color: var(--lb-blue);
  box-shadow: 0 2px 8px rgba(7,104,255,0.08);
}

.lb-kanban__card-id {
  font-family: var(--lb-font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--lb-blue);
  margin-bottom: 6px;
}

.lb-kanban__card-route {
  font-size: 13px;
  font-weight: 600;
  color: var(--lb-text);
  margin-bottom: 4px;
}

.lb-kanban__card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.lb-kanban__card-carrier {
  font-size: 11px;
  color: var(--lb-muted);
}
.lb-kanban__card-weight {
  font-size: 11px;
  color: var(--lb-muted);
}
.lb-kanban__card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.lb-kanban__card-stops {
  font-size: 9px;
  font-weight: 600;
  background: rgba(82,181,255,0.12);
  color: var(--lb-accent);
  border: 1px solid rgba(82,181,255,0.3);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

.lb-kanban__empty {
  font-size: 13px;
  color: var(--lb-muted);
  text-align: center;
  padding: 40px 16px;
}

/* ── Action bar ───────────────────────────────────────────────────────────── */
.lb-action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.lb-search {
  padding: 8px 14px;
  border: 1.5px solid var(--lb-border);
  border-radius: 7px;
  font-family: var(--lb-font-body);
  font-size: 13px;
  color: var(--lb-text);
  background: #FAFBFC;
  outline: none;
  width: 260px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lb-search:focus {
  border-color: var(--lb-blue);
  box-shadow: 0 0 0 3px rgba(7,104,255,0.1);
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.lb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--lb-muted);
}
.lb-empty__icon { font-size: 40px; opacity: 0.35; }
.lb-empty__text { font-size: 14px; font-weight: 500; }

/* ── Utility classes ──────────────────────────────────────────────────────── */
.lb-text-muted { color: var(--lb-muted); }
.lb-text-sm    { font-size: 12px; }
.lb-text-xs    { font-size: 11px; }
.lb-text-mono  { font-family: var(--lb-font-mono); }
.lb-text-success { color: var(--lb-success); }
.lb-text-warning { color: var(--lb-warning); }
.lb-text-danger  { color: var(--lb-danger); }
.lb-text-blue    { color: var(--lb-blue); }
.lb-font-mono    { font-family: var(--lb-font-mono); }
.lb-fw-600       { font-weight: 600; }
.lb-mb-0  { margin-bottom: 0; }
.lb-mb-8  { margin-bottom: 8px; }
.lb-mb-16 { margin-bottom: 16px; }
.lb-mb-24 { margin-bottom: 24px; }
.lb-gap-8  { gap: 8px; }
.lb-flex { display: flex; }
.lb-flex-1 { flex: 1; }
.lb-items-center { align-items: center; }
.lb-justify-between { justify-content: space-between; }

/* ── Mobile overlay ───────────────────────────────────────────────────────── */
#lb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
#lb-overlay.visible { display: block; }

/* ── Responsive breakpoints ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .lb-sidebar {
    position: fixed;
    left: -240px;
    transition: left 0.3s;
    z-index: 101;
  }
  .lb-sidebar.open { left: 0; }
  #lb-menu-toggle { display: flex; }
  .lb-kanban { grid-template-columns: 1fr 1fr; }
  .lb-grid-4 { grid-template-columns: 1fr 1fr; }
  .lb-stat-strip { flex-direction: column; }
}

@media (max-width: 600px) {
  .lb-kanban { grid-template-columns: 1fr; }
  .lb-grid-3, .lb-grid-2 { grid-template-columns: 1fr; }
  .lb-content { padding: 16px; }
  .lb-topbar { padding: 0 16px; }
}
