:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e3e7ef;
  --muted: #6b7280;
  --text: #161b26;
  --accent: #f36924;
  --accent-2: #4f46e5;
  --accent-3: #14b8a6;
  --shadow: 0 10px 30px rgba(20, 28, 45, 0.07);
  --radius: 12px;
  --sidebar-width: 360px;
  --header-height: 58px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.3px; }
.brand .logo { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: #fff6f0; border: 1px solid #ffd9c2; color: var(--accent); }
.brand .sub { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--text);
  transition: all 0.18s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow); }

.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #f36924, #f0b35c); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: 0.4px; }
/* Hide burger on desktop */
.burger-desktop-hide { display: none; }

/* Nav */
.primary-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 46px;
  background: #fff;
  overflow: visible;
  transition: height 0.25s ease, opacity 0.2s ease, transform 0.2s ease;
}
.primary-nav.is-hidden { display: none; }

.nav-link {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.18s ease;
  font-size: 13px;
}
.nav-link:hover { color: var(--text); border-color: var(--border); background: #f9fafb; }
.nav-link.active { color: var(--accent); border-color: #ffd9c2; background: #fff6f0; }

/* Dropdown (reusable) */
.dropdown { position: relative; }
.dropdown-toggle { display: inline-flex; align-items: center; gap: 6px; }
.dropdown-toggle::after {
  content: '';
  width: 6px; height: 6px;
  border: 1.5px solid currentColor;
  border-left: transparent; border-top: transparent;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0.7;
}
.dropdown-menu {
  position: absolute;
  top: 110%;
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.12);
  padding: 8px;
  display: none;
  z-index: 40;
}
.dropdown-menu.open { display: grid; gap: 4px; }
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.dropdown-item:hover { background: #fff6f0; color: var(--accent); }
.dropdown-item .hint { font-size: 11px; color: var(--muted); }
.dropdown-item.has-children { flex-direction: column; align-items: flex-start; }
.dropdown-item.has-children > .dropdown-submenu { display: none; width: 100%; padding-left: 10px; }
.dropdown-item.has-children.open > .dropdown-submenu { display: grid; gap: 4px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 2px;
  padding: 10px 2px;
  transition: grid-template-columns 0.25s ease;
}
.layout.sidebar-collapsed { grid-template-columns: 1fr; }
.layout.sidebar-collapsed .sidebar { display: none; }
.layout.side-email { grid-template-columns: var(--sidebar-width) minmax(0,1fr) 520px; }
.layout.side-email .main { grid-column: 2; }
.layout.side-email .email-panel-slot { display: block; grid-column: 3; }
.layout.full-email { grid-template-columns: var(--sidebar-width) 1fr; }
.layout.full-email .main { display: none; }
.layout.full-email .email-panel-slot { display: block; grid-column: 2; }

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.sidebar.collapsed { transform: translateX(-105%); opacity: 0; pointer-events: none; }

.sidebar-topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 6px; border-bottom: 1px solid var(--border); gap: 8px; }
.sidebar-icons { display: flex; gap: 6px; align-items: center; }
.sidebar-icons .icon-btn { width: 34px; height: 34px; border-radius: 8px; }
.sidebar-icons .icon-btn.gear { position: relative; }
.mailbox-dropdown { position: relative; }
.mailbox-menu {
  position: absolute;
  top: 115%;
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
  padding: 8px;
  min-width: 180px;
  display: none;
  z-index: 12;
}
.mailbox-menu.open { display: grid; gap: 6px; }
.mailbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  color: #1f2937;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.mailbox-option:hover { background: #f8fafc; border-color: var(--border); }
.mailbox-option.active { background: #fff6f0; border-color: #ffd9c2; color: var(--accent); }
.mailbox-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-search { display: flex; align-items: center; gap: 8px; padding: 8px 12px 10px; border-bottom: 1px solid var(--border); }
.search-icon { color: var(--muted); }
.search-field {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #fff1e6; }

.email-list { overflow: auto; padding: 8px 10px 12px; display: grid; gap: 6px; }

.email-card {
  position: relative;
  padding: 9px 12px 9px 14px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid #eff1f5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.email-card::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 6px;
  width: 3px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--bar-color, #7c3aed), var(--bar-color, #7c3aed));
  opacity: 0.9;
}
.email-card:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08); border-color: #e3d9ff; }
.email-card .checkbox { margin-top: 4px; }

.mail-main { display: grid; gap: 4px; }
.mail-from { font-weight: 700; font-size: 12px; color: #1f2937; }
.mail-subject { font-weight: 700; color: #111827; font-size: 12px; }
.mail-snippet { color: #475569; font-size: 11.5px; }
.mail-meta { display: flex; align-items: center; gap: 6px; color: #6b7280; font-size: 11.5px; }
.mail-meta .badge { background: #eef2ff; color: #4338ca; padding: 2px 7px; border-radius: 7px; font-weight: 700; font-size: 11px; border: 1px solid #e0e7ff; }
.mail-right { text-align: right; display: grid; gap: 4px; font-size: 11.5px; color: #374151; align-content: center; }
.mail-time { font-weight: 700; }
.mail-date { color: #6b7280; }
.mail-flag { display: inline-flex; gap: 4px; justify-content: flex-end; color: #6b7280; }
.mail-attachment { font-size: 11px; margin-left: 4px; vertical-align: middle; }
.mail-direction {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e5f6ff;
  color: #0284c7;
  margin-left: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.mail-direction.in { background: #e7f9ed; color: #16a34a; }
.mail-direction.out { background: #fff4e5; color: #ea580c; }

/* Main content */
.main { display: grid; gap: 1px; align-content: start; padding-top: 0; margin-top: 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.trip-page .card { padding: 10px 12px; }
.trip-page .trip-header { padding: 8px 10px 9px; }
.trip-page .main { gap: 1px; }
.trip-header { display: grid; gap: 6px; }
.trip-id-block { display: flex; gap: 8px; align-items: center; }
.trip-id-text { display: grid; gap: 2px; line-height: 1.2; }
.trip-id-text .muted { font-size: 12px; line-height: 1.1; }
.trip-id-block .back-circle { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: #fff; display: inline-flex; align-items: center; justify-content: center; color: #111827; transition: all 0.18s ease; box-shadow: var(--shadow); }
.trip-id-block .back-circle:hover { background: #f8fafc; color: var(--accent-2); transform: translateY(-1px); }
.trip-id { font-size: 17px; font-weight: 800; color: var(--accent-2); margin-bottom: 0; line-height: 1.15; }
.tail { font-size: 14px; font-weight: 800; color: #d946ef; line-height: 1.15; }
.trip-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 4px 8px; font-size: 12.5px; }
.trip-header .chip,
.trip-header .assignee-chip,
.trip-header .status-pill { padding: 4px 10px; font-size: 12px; }
.trip-meta-grid .label { font-weight: 700; color: #4b5563; margin-right: 4px; }
.trip-filters .filters-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.trip-filters input[type="checkbox"] { margin-right: 6px; }
.trip-filters select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; }

.sector-list { display: grid; gap: 2px; }
.sector-card { border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; background: #fff; }
.sector-summary { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px; padding: 10px 12px; background: #f8fafc; cursor: pointer; }
.sector-actions { display: flex; gap: 8px; justify-content: flex-end; }
.sector-left { display: grid; gap: 4px; }
.sector-leg { font-weight: 700; color: #111827; }
.sector-route { font-size: 14px; color: #374151; font-weight: 700; }
.sector-times { display: flex; gap: 8px; flex-wrap: wrap; }
.sector-times .soft { font-weight: 500; color: #4b5563; }
.sector-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.sector-body { display: grid; gap: 10px; padding: 0 12px; border-top: 1px solid var(--border); background: #fff; max-height: 0; overflow: hidden; transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.2s ease; opacity: 0; }
.sector-body.open { padding: 10px 12px 12px; max-height: 1200px; opacity: 1; }
.subsection { display: grid; gap: 8px; }
.subsection-title { font-weight: 800; color: #111827; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.service-row {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 6px;
  column-gap: 10px;
  font-size: 13px;
  padding: 10px 12px;
  align-items: start;
}
.service-main { grid-column: 1; grid-row: 1; }
.service-note { grid-column: 1; grid-row: 2; }
.service-toolbar { grid-column: 2; grid-row: 1 / span 2; }
.service-row + .service-row { border-top: 1px solid #e5e7eb; }
.service-group { border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; background: #fff; }
.service-main { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.service-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-left: auto; align-self: flex-start; margin-top: 0; }
.actions-inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions-compact { display: none; position: relative; align-items: center; }
.actions-compact summary { list-style: none; cursor: pointer; padding: 0; }
.actions-compact summary::-webkit-details-marker { display: none; }
.actions-compact summary:focus { outline: none; box-shadow: 0 0 0 2px #e5e7eb; border-radius: 10px; }
.actions-compact .action-icon.more { top: 0; }
.actions-compact[open] .action-icon.more { box-shadow: var(--shadow); }
.actions-popover {
  position: absolute;
  right: 0;
  top: 32px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
  justify-items: center;
  gap: 6px;
  z-index: 22;
  min-width: 180px;
  max-height: 260px;
  overflow: auto;
}
.service-airport { font-weight: 700; color: #0f172a; background: #f8fafc; border: 1px solid #e2e8f0; padding: 5px 9px; border-radius: 10px; }
.service-handler { color: #4b5563; font-weight: 600; }
.service-title { font-weight: 700; color: #111827; }
.service-note { color: #b91c1c; font-weight: 700; font-size: 12px; margin-top: 4px; }
.service-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(243, 105, 36, 0.15);
  background: #f97316;
}
.service-dot.gray { background: #9ca3af; box-shadow: 0 0 0 4px rgba(156,163,175,0.18); }
.service-dot.orange { background: #f97316; }
.pill-btn {
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pill-btn.blue { background: #2563eb; border-color: #2563eb; color: #fff; }
.pill-btn.green { background: #10b981; border-color: #10b981; color: #fff; }
.pill-btn.outline { background: #fff; border-color: #d1d5db; color: #111827; }
.pill-btn.ghost { background: #f8fafc; }
.pill-btn.small { padding: 7px 10px; font-size: 12px; }
.pill-btn:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-weight: 700;
  color: #1f2937;
  transition: all 0.14s ease;
  position: relative;
  top: -1px;
}
.action-icon svg { width: 14px; height: 14px; stroke: currentColor; }
.action-icon:hover { background: #fff; border-color: #d1d5db; color: var(--accent-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.action-icon.email { color: #f59e0b; border-color: #fef3c7; background: #fffbeb; }
.action-icon.strip { margin-left: auto; }
.pill.soft { background: #f8fafc; border-color: #e5e7eb; color: #1f2937; }
.pill.quiet { background: #f9fafb; border-style: dashed; color: #4b5563; }
.status-pill[data-tone="warn"] { color: #c2410c; background: #fff6f0; border-color: #ffd9c2; }
.status-pill[data-tone="good"] { color: #0f766e; background: #ecfeff; border-color: #a5f3fc; }
.status-pill[data-tone="muted"] { color: #4b5563; background: #f3f4f6; border-color: #e5e7eb; }
.sub-icons { font-size: 13px; margin-left: 6px; vertical-align: middle; }
.icon-btn.ghost.tiny { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 12px; }
.icon-btn.ghost.tiny svg { pointer-events: none; }

.email-inline {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: min(340px, 90vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
  display: none;
  z-index: 80;
}
.email-inline.open { display: block; }
.email-inline-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-weight: 700; }
.email-pill { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: #f8fafc; border: 1px solid #e5e7eb; margin: 2px; font-size: 12px; }

.email-drawer {
  width: 100%;
  max-height: calc(100vh - var(--header-height) - 24px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
  grid-template-rows: auto auto 1fr;
  padding: 12px;
  overflow: hidden;
  position: sticky;
  top: calc(var(--header-height) + 12px);
  align-self: start;
  transform: translateX(0);
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
}
.email-drawer.open {
  display: grid;
  opacity: 1;
  pointer-events: auto;
}
.email-inline-panel { width: 100%; }
.page-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  align-items: start;
  padding: 0 12px 16px;
}
.trip-page.has-email-drawer .page-shell {
  grid-template-columns: 360px 1fr;
}

.email-drawer-header { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.email-drawer-search { padding: 8px 0; }
.email-drawer-search input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: #f8fafc; }
.email-drawer-list { overflow: auto; display: grid; gap: 8px; }
.email-card.compact { grid-template-columns: 1fr auto; padding: 10px 12px; }

.trip-page.has-email-drawer .main {
  margin-left: 0;
}
.email-card.compact .mail-subject { font-weight: 700; }
.service-id { font-weight: 700; }
.service-type { font-weight: 700; color: #111827; }
.service-note { color: #b91c1c; font-weight: 700; }
.ops-remark { background: #fffbea; border: 1px solid #fcd34d; padding: 10px; border-radius: 10px; line-height: 1.5; color: #92400e; }

.pill { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid transparent; font-weight: 700; }
.chip.green { background: #ecfdf3; border-color: #bbf7d0; color: #15803d; }
.chip.teal { background: #ecfeff; border-color: #a5f3fc; color: #0f766e; }
.chip.orange { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.chip.blue { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.chip.gray { background: #f3f4f6; border-color: #e5e7eb; color: #374151; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-weight: 700; border: 1px solid transparent; }
.status-pill.pending { color: var(--accent); background: #fff6f0; border-color: #ffd9c2; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(243,105,36,0.15); }

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.pending-toolbar { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pending-search { position: relative; width: clamp(200px, 28vw, 320px); }
.pending-search .pending-search-input { padding-right: 38px; }
.pending-search .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.pending-search .pending-search-input { height: 38px; line-height: 1.25; display: block; }
.tab-group { display: inline-flex; gap: 6px; align-items: center; }
.tab { padding: 8px 14px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 700; transition: all 0.18s ease; }
.tab.active { background: #fff6f0; border-color: #ffd9c2; color: var(--accent); }
.tag { padding: 6px 10px; border-radius: 8px; background: #eef2ff; color: #364152; font-weight: 600; border: 1px solid #e0e7ff; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid #edf0f4; }
th { font-weight: 700; color: #4b5563; font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

.table-scroll { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; max-height: 480px; scroll-behavior: smooth; }
.table-scroll table { min-width: 2000px; }
.pending-table th, .pending-table td { white-space: nowrap; }
.pending-table thead th { background: #f9fafb; position: sticky; top: 0; z-index: 1; }
.pending-table thead tr.filters th { background: #fff; top: 44px; z-index: 2; }
.pending-card .panel-header { margin-bottom: 6px; }
.pending-table { table-layout: auto; }
.pending-table th, .pending-table td { padding: 10px 8px; font-size: 12.5px; }
.table-scroll table { min-width: var(--pending-table-min, 1400px); width: 100%; }

.filter-input {
  width: 100%;
  padding: 8px 11px;
  border-radius: 11px;
  border: 1px solid #dfe6f2;
  background: #f8fbff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 1px 2px rgba(15,23,42,0.04);
  font-size: 12.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.filter-input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px #e7f0ff, inset 0 1px 0 rgba(255,255,255,0.95); background: #fff; }
.filter-input::placeholder { color: #8d99ab; }

.row-clickable { cursor: pointer; transition: background 0.14s ease; }
.row-clickable:hover td { background: #fff6f0; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-weight: 700; border: 1px solid transparent; }
.status-pill.pending { color: var(--accent); background: #fff6f0; border-color: #ffd9c2; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(243,105,36,0.15); }

.assignee-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: #ecfdf3; border: 1px solid #bbf7d0; color: #166534; font-weight: 700; }

.table-link { border: 0; background: transparent; color: var(--accent-2); font-weight: 700; padding: 0; }
.table-link:hover { text-decoration: underline; }

.ellipsis { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

@media (max-width: 1400px) {
  .table-scroll table { min-width: 1200px; }
  .pending-table th, .pending-table td { padding: 9px 7px; font-size: 12px; }
}

@media (max-width: 1100px) {
  .table-scroll table { min-width: 1000px; }
  .pending-table th, .pending-table td { padding: 8px 6px; font-size: 11.5px; }
  .pending-table th:nth-child(n+15),
  .pending-table td:nth-child(n+15) { display: none; }
}

@media (max-width: 900px) {
  /* email drawer becomes slide-in overlay on mobile */
  .trip-page .page-shell { grid-template-columns: 1fr; }
  .trip-page .email-drawer {
    position: fixed;
    inset: var(--header-height) auto 0 0;
    width: min(90vw, 360px);
    max-height: calc(100vh - var(--header-height));
    box-shadow: 0 18px 40px rgba(0,0,0,0.14);
    transform: translateX(-105%);
    z-index: 50;
  }
  .trip-page .email-drawer.open { transform: translateX(0); }
  .trip-page.has-email-drawer .page-shell { grid-template-columns: 1fr; }
  .trip-page.has-email-drawer .main { margin-left: 0; }

  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: var(--header-height) auto 0 0;
    z-index: 25;
    max-height: calc(100vh - var(--header-height));
    width: 300px;
    max-width: 88vw;
    transform: translateX(-105%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.2s ease;
    display: block;
  }
  .sidebar.show-mobile { transform: translateX(0); opacity: 1; }
  .layout.sidebar-collapsed { grid-template-columns: 1fr; }

  .table-scroll {
    width: 100vw;
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-scroll table { min-width: 1100px; }
}

/* Form */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; color: #4b5563; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: #fdfefe; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px #e7f0ff; }
.hint { font-size: 12px; color: var(--muted); }

.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { padding: 10px 14px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; color: #fff; transition: transform 0.12s ease, box-shadow 0.18s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(0,0,0,0.08); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.orange { background: #f97316; }
.btn.red { background: #e11d48; }
.btn.blue { background: #2563eb; }
.btn.cyan { background: #0891b2; }
.btn.gray { background: #9ca3af; }
.btn.yellow { background: #eab308; color: #3b2f05; }
.btn.white { background: #fff; color: var(--text); border: 1px solid var(--border); }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
  padding: 16px;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  width: min(820px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 30px 80px rgba(0,0,0,0.18);
  padding: 18px;
  display: grid;
  gap: 12px;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s ease;
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }
.modal header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal header h3 { margin: 0; font-size: 16px; }
.modal input, .modal textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); }
.modal .email-body { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px; color: #374151; line-height: 1.6; }

/* Toasts */
.toast-stack { position: fixed; top: 14px; right: 14px; display: grid; gap: 8px; z-index: 40; }
.toast { min-width: 240px; padding: 12px 14px; border-radius: 10px; color: #fff; background: #1f2937; box-shadow: var(--shadow); animation: slideIn 0.25s ease; border-left: 4px solid #10b981; }
.toast.error { border-left-color: #ef4444; background: #1f2430; }
@keyframes slideIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }

/* Utilities (reusable) */
.btn-primary { background: var(--accent-2); color: #fff; }
.btn-secondary { background: #e5e7eb; color: #1f2937; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: #1f2937; }
.rounded-sm { border-radius: 8px; }
.rounded-md { border-radius: 12px; }
.shadow-sm { box-shadow: 0 6px 18px rgba(0,0,0,0.06); }
.shadow-md { box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; }
.text-muted { color: var(--muted); }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }

/* Email dialog placements */
.email-dialog-shell { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.email-dialog-overlay { display: none; }
.email-dialog {
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.14);
  padding: 14px 16px 18px;
  width: min(780px, 90%);
  max-height: 80vh;
  overflow: auto;
  pointer-events: auto;
  z-index: 60;
  transition: transform 0.2s ease, opacity 0.2s ease, width 0.2s ease;
}
.email-dialog.hidden { display: none; }
.email-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.email-dialog header h3 { margin: 0; font-size: 15px; }
.email-dialog footer { margin-top: 10px; text-align: right; }
.email-dialog--center {
  left: calc(var(--sidebar-width) + 20px);
  right: 16px;
  top: calc(var(--header-height) + 32px);
  transform: none;
}
.email-dialog--footer { left: calc(var(--sidebar-width) + 16px); right: 16px; bottom: 12px; top: auto; width: calc(100% - var(--sidebar-width) - 32px); max-width: none; margin: 0 auto; transform: none; }
.email-dialog--side { right: 16px; left: auto; top: calc(var(--header-height) + 12px); bottom: 12px; width: min(620px, 60vw); transform: none; }
.email-dialog--full { left: calc(var(--sidebar-width) + 12px); right: 12px; top: calc(var(--header-height) + 8px); bottom: 12px; width: 100%; transform: none; }
.email-dialog--full header { position: sticky; top: 0; background: #fff; padding-bottom: 6px; }
.email-dialog--footer .email-body, .email-dialog--side .email-body { max-height: 60vh; overflow: auto; }
.email-dialog--full .email-body { height: calc(100% - 50px); overflow: auto; }
.email-panel-slot { display: none; }
.email-panel-slot .email-dialog {
  position: sticky;
  top: calc(var(--header-height) + 8px);
  width: 100%;
  box-shadow: var(--shadow);
  height: calc(100vh - var(--header-height) - 24px);
}
.email-dialog--side-slot {
  position: sticky;
  top: calc(var(--header-height) + 8px);
  width: 100%;
  height: calc(100vh - var(--header-height) - 24px);
  box-shadow: var(--shadow);
}

/* Responsive */
@media (max-width: 1080px) { .layout { grid-template-columns: 260px 1fr; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: var(--header-height) auto 0 0;
    z-index: 25;
    max-height: calc(100vh - var(--header-height));
    width: 300px;
    max-width: 80vw;
    transform: translateX(-105%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.2s ease;
  }
  .sidebar.show-mobile { transform: translateX(0); opacity: 1; }
  .layout.sidebar-collapsed { grid-template-columns: 1fr; }
  .primary-nav {
    position: fixed;
    inset: var(--header-height) auto 0 0;
    width: 280px;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
    gap: 8px;
    background: #fff;
    border-right: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(0,0,0,0.14);
    display: inline-table;
    transform: translateX(-100%);
    z-index: 26;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    background: #fff;
    opacity: 0;
    pointer-events: none;
  }
  .primary-nav.show-mobile { transform: translateX(0); opacity: 1; pointer-events: auto; }
  .primary-nav .nav-link { width: 100%; text-align: left; }
  .primary-nav .dropdown { width: 100%; }
  .primary-nav .dropdown-toggle { width: 100%; justify-content: space-between; }
  .primary-nav .dropdown-menu {
    position: static;
    width: 100%;
    box-shadow: none;
    border: 1px solid var(--border);
    padding: 6px;
    margin-top: 4px;
  }
  .primary-nav .dropdown-item.has-children > .dropdown-submenu { padding-left: 12px; }
  .topbar-left { width: 100%; gap: 8px; }
  .burger-desktop-hide { display: inline-flex; }
}
@media (max-width: 640px) {
  .panel-header { align-items: flex-start; }
  .tab-group { flex-wrap: wrap; }
  .primary-nav { gap: 4px; }
  .nav-link { padding: 9px 10px; font-size: 13px; }
  .topbar { padding: 0 10px; }

  /* keep pending search + counter aligned on small screens */
  .pending-card .panel-header { align-items: center; }
  .pending-toolbar { width: 100%; justify-content: space-between; gap: 8px; }
  .pending-toolbar .hint { white-space: nowrap; line-height: 1.2; }
  .pending-search { flex: 1; min-width: 0; width: 100%; }
  .pending-search .pending-search-input { width: 100%; }

  /* mobile actions: collapse to compact dropdown */
  .actions-inline { display: none; }
  .actions-compact { display: inline-flex; }

  .trip-page .trip-header { padding: 8px 10px; gap: 5px; }
  .trip-header { gap: 5px; }
  .trip-id { font-size: 16px; }
  .tail { font-size: 13px; }
  .trip-meta-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 4px 6px; font-size: 12px; }
}

/* Trip details mobile tuning */
@media (max-width: 768px) {
  .page-shell { padding: 8px 8px 14px; }
  .card { padding: 10px; }
  .trip-header { gap: 6px; }
  .trip-id { font-size: 16px; }
  .tail { font-size: 14px; }
  .trip-meta-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 8px; }
  .trip-filters .filters-inline { flex-direction: column; align-items: flex-start; gap: 8px; }

  .sector-summary { grid-template-columns: 1fr; align-items: flex-start; gap: 6px; }
  .sector-times, .sector-meta { justify-content: flex-start; }
  .sector-meta .chip, .status-pill, .pill { font-size: 12px; padding: 5px 8px; }

  .service-row { gap: 8px; align-items: flex-start; }
  .service-toolbar { justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
  .service-toolbar .action-icon { width: 24px; height: 24px; }
  .pill-btn { font-size: 12px; padding: 7px 10px; }

  .email-drawer {
    width: min(92vw, 360px);
    inset: calc(var(--header-height) + 4px) auto 0 0;
  }
}

/* Inline dialog (legacy callDialog support) */
.inline-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 45;
  padding: 16px;
}
.inline-dialog-backdrop.open { display: flex; }
.inline-dialog {
  width: min(96%, 820px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 28px 70px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  max-height: 82vh;
}
.inline-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.inline-dialog__title { margin: 0; font-size: 15px; }
.inline-dialog__body { padding: 14px; overflow: auto; }
.inline-dialog__close { border: none; background: transparent; }

/* Legacy dialog styles (callDialog support) */
.dialogBackground {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.dialog {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.dialogHeader {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: move;
}
.dialogHeader .title { font-weight: 700; color: var(--text); }
.dialogBody { padding: 12px; overflow: auto; }
.closeButtonDialog {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #f3f4f6;
  text-align: center;
  line-height: 22px;
  cursor: pointer;
  color: #111827;
  display: inline-block;
}
.loading { width: 100%; padding: 14px; text-align: center; color: var(--muted); }
