:root {
  /* Brand */
  --brand: #0A4488;
  --brand-strong: #073A75;
  --brand-soft: #EAF2FB;
  --accent: #23ACD6;
  --accent-soft: #E8F6FB;

  /* Ink & text */
  --ink: #16263F;
  --text: #1B2A41;
  --text-2: #5C6B82;
  --text-3: #8B97A8;
  --text-faint: #A3AEBF;
  --disabled: #C0C8D4;

  /* Surfaces */
  --page: #F4F6F9;
  --card: #FFFFFF;
  --card-subtle: #FAFBFD;
  --border: #E6EAF0;
  --border-2: #D8DEE8;
  --hairline: #F0F3F7;

  /* Status */
  --success: #1E8A5B;
  --success-bg: #E7F5EE;
  --warning: #B45309;
  --warning-bg: #FBF1E3;
  --danger: #CE3B3B;
  --danger-bg: #FBEBEB;
  --info: #1487AE;
  --info-bg: #E5F4FA;

  /* Shape & motion */
  --radius: 9px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 36, 58, 0.04);
  --shadow-md: 0 1px 2px rgba(16, 36, 58, 0.06), 0 1px 3px rgba(16, 36, 58, 0.04);
  --shadow-lift: 0 1px 2px rgba(16,36,58,.05), 0 10px 26px -16px rgba(16,36,58,.28);

  /* Category / accent hues */
  --cat-oil: #0E9AA5;
  --cat-oil-bg: rgba(14,154,165,.10);
  --cat-coupling: #7C3AED;
  --cat-coupling-bg: rgba(124,58,237,.10);
  --cat-resin: #BE3455;
  --cat-resin-bg: rgba(190,52,85,.10);
  --cat-defoam: #B45309;
  --cat-defoam-bg: rgba(180,83,9,.10);
  --cat-level: #1E8A5B;
  --cat-level-bg: rgba(30,138,91,.10);
  --cat-other: #0A4488;
  --cat-other-bg: #EAF2FB;

  /* Table header */
  --thead-grad: linear-gradient(180deg,#2E6FAF,#1B5794);
  --thead-label: #E8F2FF;

  /* Layout */
  --sidebar-w: 236px;
  --topbar-h: 64px;

  --font: 'IBM Plex Sans', 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

body {
  font-family: var(--font);
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

code,
.mono,
.cas,
.product-code,
.code-badge,
.badge-code,
.cell-id {
  font-family: var(--mono);
}

h1 {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}

body a {
  color: var(--brand);
}

body .card,
body .detail-card,
body .stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

body .card {
  padding: 22px;
}

body .stat-card {
  padding: 20px;
}

body .stat-card .number {
  color: var(--brand);
}

body .stat-card .label {
  color: var(--text-2);
}

body .btn {
  height: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, filter 0.12s;
}

body .btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

body .btn-primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  color: var(--card);
  border-color: var(--brand);
  box-shadow: 0 1px 2px rgba(10, 68, 136, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

body .btn-primary:hover {
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  color: var(--card);
  border-color: var(--brand-strong);
}

body .btn-secondary {
  background: var(--card);
  color: var(--text-2);
  border-color: var(--border-2);
  font-weight: 500;
}

body .btn-secondary:hover {
  background: var(--page);
  color: var(--ink);
  border-color: var(--text-faint);
}

body .btn-tonal {
  background: var(--brand-soft);
  color: var(--brand);
}

body .btn-tonal:hover {
  background: var(--accent-soft);
}

body .btn-accent {
  background: linear-gradient(135deg, var(--info), var(--accent));
  color: var(--card);
  box-shadow: 0 1px 2px rgba(20, 135, 174, 0.35);
}

body .btn-accent:hover {
  color: var(--card);
  filter: brightness(0.96);
}

.btn-glass,
.btn-glass-primary {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, filter 0.12s;
}

.btn-glass {
  border: 1px solid rgba(11, 77, 155, 0.22);
  color: #0B4D9B;
  background: rgba(11, 77, 155, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.70);
}

.btn-glass:hover {
  color: #0B4D9B;
  background: rgba(11, 77, 155, 0.10);
}

.btn-glass-primary {
  border: 1px solid rgba(11, 77, 155, 0.50);
  color: var(--card);
  background: linear-gradient(180deg, rgba(31, 110, 205, 0.95), rgba(11, 77, 155, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 4px 12px -5px rgba(11, 77, 155, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.btn-glass-primary:hover {
  color: var(--card);
  filter: brightness(1.06);
}

body .btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
  font-weight: 500;
}

body .btn-sm {
  height: 34px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

body table th,
body .crm-grid th,
body .supplier-grid th,
body .qs-grid th,
body .freight-grid th,
body .mini-table th {
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 1.25;
  text-align: left;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  background: var(--card-subtle);
  border-color: var(--border);
  border-bottom: 1px solid var(--border);
}

body table td,
body .crm-grid td,
body .supplier-grid td,
body .qs-grid td,
body .freight-grid td,
body .mini-table td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
  border-color: var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

body table tr:hover,
body .crm-grid tbody tr:hover,
body .supplier-grid tbody tr:hover,
body .qs-grid tbody tr:hover,
body .freight-grid tbody tr:hover,
body .mini-table tbody tr:hover {
  background: var(--card-subtle);
}

body table td a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

body table td a:hover {
  color: var(--brand-strong);
  text-decoration: underline;
}

body .cell-id {
  color: var(--text-3);
  font-size: 12.5px;
}

body .cell-muted {
  color: var(--text-3);
}

body .cell-empty,
body .empty-value,
body .field-value.empty {
  color: var(--disabled);
}

body .badge,
body .badge-type,
body .badge-status,
body .type-badge,
body .status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
}

body .badge-customer,
body .badge-open,
body .type-customer,
body .status-open {
  background: var(--brand-soft);
  color: var(--brand);
}

body .badge-supplier,
body .type-supplier {
  background: var(--info-bg);
  color: var(--info);
}

body .badge-won,
body .badge-sister,
body .status-won {
  background: var(--success-bg);
  color: var(--success);
}

body .badge-lost,
body .badge-dg,
body .status-lost,
body .dg-badge {
  background: var(--danger-bg);
  color: var(--danger);
}

body .badge-agent,
body .type-agent,
body .badge-review,
body .badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

body .badge-other,
body .type-other,
body .badge-code,
body .code-badge {
  background: var(--page);
  color: var(--text-2);
}

body .code-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.8rem;
  font-weight: 400;
}

.cat-oil {
  --cat: var(--cat-oil);
  --cat-bg: var(--cat-oil-bg);
}

.cat-coupling {
  --cat: var(--cat-coupling);
  --cat-bg: var(--cat-coupling-bg);
}

.cat-resin {
  --cat: var(--cat-resin);
  --cat-bg: var(--cat-resin-bg);
}

.cat-defoam {
  --cat: var(--cat-defoam);
  --cat-bg: var(--cat-defoam-bg);
}

.cat-level {
  --cat: var(--cat-level);
  --cat-bg: var(--cat-level-bg);
}

.cat-other {
  --cat: var(--cat-other);
  --cat-bg: var(--cat-other-bg);
}

body .form-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

body .form-group input,
body .form-group select,
body .form-group textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--card-subtle);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

body .form-group input:focus,
body .form-group select:focus,
body .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

body .pagination a,
body .pagination span {
  border-radius: calc(var(--radius) - 1px);
}

body .pagination a {
  color: var(--text-2);
  border: 1px solid var(--border);
}

body .pagination a:hover {
  color: var(--ink);
  background: var(--page);
}

body .pagination .current {
  color: var(--card);
  background: var(--brand);
  border-color: var(--brand);
}

body .detail-grid {
  gap: 12px;
}

body .detail-row {
  border-bottom-color: var(--hairline);
}

body .detail-card {
  overflow: hidden;
}

body .detail-card-head {
  background: var(--card-subtle);
  color: var(--text-2);
  border-bottom-color: var(--border);
}

body .detail-card-body {
  background: var(--card);
}

body .detail-label,
body .field-label,
body .info-label,
body .detail-field-label {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body .detail-value,
body .field-value,
body .info-value,
body .detail-field-value {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

body .section-title {
  padding-bottom: 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline);
}

body .inline-form-panel.tint-purple,
body .inline-form-panel.tint-green,
body .inline-form-panel.tint-orange,
body .inline-form-panel.tint-pink {
  background: var(--card-subtle);
}

body .inline-form-panel {
  border-bottom-color: var(--border);
}

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

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
  z-index: 30;
}

.sidebar-brand {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--hairline);
  overflow: hidden;
}

.sidebar-logo {
  height: 46px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.nav-group {
  margin-bottom: 6px;
}

.nav-group-label {
  padding: 14px 10px 6px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 36px;
  margin-bottom: 2px;
  padding: 8px 11px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex: none;
  stroke-width: 1.9;
}

.nav-item:hover {
  background: var(--page);
  color: var(--ink);
  text-decoration: none;
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-user {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--hairline);
}

.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: var(--card);
  font-size: 13px;
  font-weight: 600;
}

.sidebar-user-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
}

.sidebar-user-meta .name {
  max-width: 160px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-meta .role {
  color: var(--text-3);
  font-size: 11px;
}

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

.topbar {
  height: var(--topbar-h);
  flex: none;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 440px;
  min-width: 180px;
  margin: 0;
}

.topbar-search > svg {
  width: 17px;
  height: 17px;
  position: absolute;
  left: 13px;
  top: 50%;
  color: var(--text-faint);
  pointer-events: none;
  transform: translateY(-50%);
  z-index: 1;
}

.topbar .topbar-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  box-shadow: none;
}

.topbar .topbar-search input::placeholder {
  color: var(--text-faint);
}

.topbar .topbar-search input:focus {
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar .nav-search-dropdown {
  top: calc(100% + 7px);
  left: 0;
  right: auto;
  width: min(520px, calc(100vw - var(--sidebar-w) - 48px));
  border-color: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.topbar-spacer {
  flex: 1;
}

body .topbar .nav-add {
  flex: none;
  position: relative;
  margin: 0;
}

body .topbar .nav-add-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--card);
  box-shadow: var(--shadow-sm);
}

body .topbar .nav-add-btn svg {
  width: 18px;
  height: 18px;
}

body .topbar .nav-add-btn:hover,
body .topbar .nav-add[data-open="1"] .nav-add-btn {
  background: var(--brand-strong);
  color: var(--card);
}

body .topbar .nav-add-menu {
  top: calc(100% + 7px);
  right: 0;
  border-color: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.topbar-logout {
  flex: none;
  text-decoration: none;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

.content > .container {
  width: 100%;
}

.content > .container.list-container {
  padding-top: 0;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-w: 64px;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 0 8px;
  }

  .sidebar-logo {
    width: 42px;
    height: 30px;
    object-fit: contain;
  }

  .sidebar-nav {
    padding: 14px 8px;
  }

  .nav-item {
    justify-content: center;
    padding: 8px;
  }

  .nav-item span,
  .nav-group-label,
  .sidebar-user-meta {
    display: none;
  }

  .sidebar-user {
    justify-content: center;
    padding: 12px 8px;
  }
}

@media (max-width: 900px) {
  .topbar {
    gap: 10px;
    padding: 0 14px;
  }

  .topbar-search {
    min-width: 0;
  }

  .topbar-logout {
    width: 38px;
    padding: 0;
  }

  .topbar-logout span {
    display: none;
  }

  .content {
    padding: 16px;
  }
}

.record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 18px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.record-id {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.record-avatar {
  width: 48px;
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--brand), var(--info));
  color: var(--card);
  font-size: 20px;
  font-weight: 700;
}

.record-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.record-title-row h1 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.2;
}

.record-meta {
  margin-top: 7px;
  color: var(--text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.record-actions form {
  display: inline-flex;
  margin: 0;
}

.record-actions .btn {
  text-decoration: none;
}

.deal-header-main {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.deal-detail-heading {
  min-width: 0;
}

.deal-action-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.deal-action-group form {
  display: inline-flex;
}

.deal-action-tools {
  flex: none;
  flex-wrap: nowrap;
}

.deal-action-generators {
  width: 100%;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.deal-action-generators .btn-glass-primary {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

@media (max-width: 700px) {
  .deal-header-main {
    align-items: flex-start;
    flex-direction: column;
  }
}

.record-title-row .badge svg,
.record-actions .badge svg {
  width: 12px;
  height: 12px;
  margin-right: 3px;
  vertical-align: -1px;
}

@media (max-width: 700px) {
  .record-head {
    padding: 16px;
  }

  .record-actions {
    width: 100%;
  }
}

/* Phase 3c: dashboard */
.section-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
}

.section-icon svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.section-icon.ic-blue {
  color: var(--brand);
  background: var(--brand-soft);
}

.section-icon.ic-cyan {
  color: var(--info);
  background: var(--info-bg);
}

.section-icon.ic-green {
  color: var(--success);
  background: var(--success-bg);
}

.dash-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  padding: 24px 26px;
  border-radius: 18px;
  color: var(--card);
  background: linear-gradient(115deg, var(--brand) 0%, var(--brand-strong) 48%, var(--info) 100%);
  box-shadow: 0 10px 30px -14px rgba(10, 68, 136, 0.55);
}

.dash-hero-glow {
  position: absolute;
  top: -60px;
  right: -40px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(35, 172, 214, 0.45), rgba(35, 172, 214, 0) 70%);
}

.dash-hero-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.dash-hero-eyebrow {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

body .dash-hero h1 {
  margin: 7px 0 0;
  color: var(--card);
  font-size: 26px;
  font-weight: 700;
}

.dash-hero p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13.5px;
}

.dash-hero-actions {
  display: grid;
  justify-items: end;
  gap: 9px;
}

.seg {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.14);
}

body .seg-btn {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

body .seg-btn:hover {
  color: var(--card);
  background: rgba(255, 255, 255, 0.1);
}

body .seg-btn.is-active,
body .seg-btn.is-active:hover {
  color: var(--brand);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(16, 36, 58, 0.12);
  font-weight: 600;
}

.dash-quick-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body .dash-quick-links a {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

body .dash-quick-links a:hover {
  color: var(--card);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px 20px 18px 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-md), 0 10px 26px -16px rgba(16, 36, 58, 0.28);
}

.kpi-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
}

.kpi-bar.bar-brand {
  background: var(--brand);
}

.kpi-bar.bar-info {
  background: var(--info);
}

.kpi-bar.bar-success {
  background: var(--success);
}

.kpi .section-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
}

.kpi .section-icon svg {
  width: 22px;
  height: 22px;
}

.kpi-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.kpi-value {
  margin: 3px 0;
  color: var(--ink);
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.kpi-sub {
  color: var(--text-faint);
  font-size: 11.5px;
}

body .owners-panel.card {
  overflow: hidden;
  margin-bottom: 20px;
  padding: 0;
}

.card-head {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card-subtle);
}

body .card-head .section-title {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.card-head-note {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 12px;
}

.owner-grid,
.dash-columns {
  display: grid;
}

.owner-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding: 18px;
}

.owner {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card-subtle);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.owner:hover {
  border-color: var(--border-2);
  box-shadow: 0 8px 22px -14px rgba(16, 36, 58, 0.3);
}

.owner-top {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 14px;
}

.owner-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  color: var(--card);
  background: linear-gradient(135deg, var(--brand), var(--info));
  font-size: 15px;
  font-weight: 600;
}

.owner-id {
  min-width: 0;
  flex: 1;
}

.owner-name {
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
}

.owner-email {
  overflow: hidden;
  color: var(--text-3);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-overdue,
.pill-clear {
  flex: none;
  padding: 3px 11px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
}

body .pill-overdue {
  color: var(--danger);
  background: var(--danger-bg);
}

.pill-clear {
  color: var(--success);
  background: var(--success-bg);
}

.owner-update-summary {
  margin-bottom: 12px;
  padding: 11px 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--card);
}

.owner-update-summary > strong {
  color: var(--ink);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.owner-update-summary > span {
  margin-left: 5px;
  color: var(--text-2);
  font-size: 11.5px;
}

.owner-breakdown {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 5px;
  color: var(--text-3);
  font-size: 10.5px;
}

.owner-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.owner-stat {
  padding: 9px 6px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--card);
  text-align: center;
}

.owner-stat b {
  display: block;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.owner-stat span {
  color: var(--text-faint);
  font-size: 10.5px;
}

.owner-stat.s-act b {
  color: var(--brand);
}

.owner-stat.s-mail b {
  color: var(--info);
}

.owner-stat.s-qs b {
  color: var(--success);
}

.owner-foot {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--hairline);
  color: var(--text-3);
  font-size: 11.5px;
}

.owner-foot b {
  color: var(--text-2);
  font-weight: 600;
}

.dash-section {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.dash-section > .section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.dash-section > .section-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.dash-section > .section-title span {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.dash-columns {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.dash-columns.wide-left {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.email-list,
.feed-list {
  display: grid;
  gap: 9px;
}

.email-row,
.feed-item {
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--card-subtle);
}

.email-row {
  grid-template-columns: minmax(0, 1fr) 72px 125px;
}

.email-row.sales-row {
  border-left: 3px solid var(--warning);
}

.email-row strong,
.email-row span,
.email-status small,
.feed-main strong,
.feed-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-row span,
.email-status small,
.feed-item span,
.feed-item small {
  color: var(--text-2);
}

.email-meta,
.feed-side {
  text-align: right;
}

.email-meta b {
  display: block;
  color: var(--ink);
}

.email-status {
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  margin-right: 4px;
  border-radius: 50%;
}

.status-dot.good {
  background: var(--success);
}

.status-dot.bad {
  background: var(--danger);
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.dash-table th,
.dash-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

.dash-table th {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.dash-table a {
  color: var(--brand);
  text-decoration: none;
}

.soft-badge {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  color: var(--success);
  background: var(--success-bg);
  font-size: 11px;
  white-space: nowrap;
}

.feed-item {
  grid-template-columns: minmax(0, 1fr) 90px;
}

.empty-state {
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text-2);
  background: var(--card-subtle);
}

@media (max-width: 1100px) {
  .dash-columns,
  .dash-columns.wide-left {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .dash-hero {
    padding: 20px;
  }

  .dash-hero-actions {
    width: 100%;
    justify-items: start;
  }

  .seg {
    max-width: 100%;
    overflow-x: auto;
  }

  body .seg-btn {
    flex: none;
  }

  .dash-quick-links {
    justify-content: flex-start;
  }

  .card-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .card-head-note {
    width: 100%;
    margin-left: 50px;
  }

  .owner-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .dash-section > .section-title {
    display: block;
  }

  .dash-section > .section-title span {
    display: block;
    margin-top: 4px;
  }

  .email-row,
  .feed-item {
    grid-template-columns: 1fr;
  }

  .email-meta,
  .feed-side {
    text-align: left;
  }

  .dash-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Phase 5a: remaining list pages */
.remaining-list-page {
  padding-top: 0 !important;
}

.list-page-head {
  min-height: 70px;
  align-items: center !important;
  margin-bottom: 16px !important;
}

.list-page-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.list-page-title h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 22px;
}

.list-page-title p {
  margin: 4px 0 0;
  color: var(--text-3);
  font-size: 12px;
}

.list-page-title .badge {
  font-size: 11px;
  letter-spacing: 0;
}

body .list-table-card {
  padding: 0;
  overflow-x: auto;
  border-color: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.remaining-list-page .crm-grid,
.remaining-list-page .supplier-grid {
  background: var(--card);
}

.remaining-list-page .crm-grid thead th,
.remaining-list-page .supplier-grid thead th {
  color: var(--text-2);
  background: var(--card-subtle);
  border-color: var(--border);
}

.remaining-list-page .crm-grid td,
.remaining-list-page .crm-grid th,
.remaining-list-page .supplier-grid td,
.remaining-list-page .supplier-grid th {
  border-color: var(--hairline);
}

.person-list-avatar {
  width: 25px;
  height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

@media (max-width: 768px) {
  .list-page-head {
    align-items: stretch !important;
  }
}

/* Phase 5b: Activities and Freight */
.activity-list-page [data-col-key="activity_date"],
.activity-list-page [data-col-key="activity_hour"],
.activity-list-page [data-col-key="due_date"],
.activity-list-page [data-col-key="done_time"],
.freight-grid .freight-num {
  font-variant-numeric: tabular-nums;
}

.activity-list-page .activity-type-badge {
  background: var(--info) !important;
}

.freight-head {
  min-height: 70px;
  align-items: center !important;
  margin-bottom: 16px !important;
}

.freight-head > h4 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
}

.freight-head > h4 i {
  color: var(--brand);
}

.freight-toolbar #freight-columns-btn {
  color: var(--text-2);
  background: var(--card);
  border-color: var(--border-2);
}

body .freight-wrap {
  overflow-x: auto;
  border-color: var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.freight-grid thead th {
  color: var(--text-2);
  background: var(--card-subtle);
  border-color: var(--border);
}

.freight-grid td,
.freight-grid th {
  border-color: var(--hairline);
}

.freight-grid td[data-col-key="origin_city"],
.freight-grid td[data-col-key="destination_city"],
.freight-grid td[data-col-key="route"],
.freight-grid td[data-col-key="notes"] {
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: normal;
}

.freight-status {
  border-radius: var(--radius-pill);
  color: var(--text-2);
  background: var(--page);
}

.freight-status.usable {
  color: var(--success);
  background: var(--success-bg);
}

/* Phase 5c: Email and Sales Inbox */
.comm-page-head {
  min-height: 70px;
  align-items: center;
  margin-bottom: 16px;
}

.comm-page-sub {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 12px;
}

.mail-tabs,
.list-tabs,
.sales-tabs {
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card-subtle);
}

body .mail-tab,
body .list-tab,
body .sales-tab {
  border: 0;
  border-radius: 8px;
  color: var(--text-2);
  background: transparent;
}

body .mail-tab.active,
body .list-tab.active,
body .sales-tab.active {
  color: var(--brand);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

body .comm-list-card {
  padding: 0;
  overflow-x: auto;
  border-color: var(--border);
  border-radius: var(--radius-lg);
}

.mail-table th,
.pro-list th {
  color: var(--text-2);
  background: var(--card-subtle);
  border-color: var(--border);
}

.mail-table td,
.pro-list td {
  border-color: var(--hairline);
}

.mail-subject,
.subject-link,
.sales-subject {
  color: var(--ink);
  font-weight: 600;
}

.mail-muted,
.preview,
.sales-meta {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-2);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.mail-table td:first-child,
.pro-list .col-date,
.sales-date {
  font-variant-numeric: tabular-nums;
}

.sales-lead,
.email-card {
  border-color: var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.sales-lead-head,
.email-card-head {
  color: var(--ink);
  background: var(--card-subtle);
  border-color: var(--border);
}

.sales-action-box {
  border-color: var(--border);
  border-radius: var(--radius);
}

.email-shell .email-card {
  overflow: hidden;
}

.email-form label {
  color: var(--text-2);
}

.email-form input,
.email-form textarea,
.email-form select,
.list-controls input,
.mail-controls input,
.mail-controls select {
  border-color: var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--card-subtle);
  font-family: var(--font);
}

@media (max-width: 700px) {
  .comm-page-head {
    align-items: stretch;
  }
}

/* Phase 5d: Duplicates */
.duplicate-page-head {
  min-height: 70px;
  align-items: center;
  margin-bottom: 16px;
}

.duplicate-guidance {
  margin-bottom: 12px;
  padding: 14px 16px;
  border-left: 4px solid var(--warning);
  color: var(--text-2);
  background: var(--card);
  font-size: 13px;
  line-height: 1.5;
}

.duplicate-summary {
  margin-bottom: 12px;
  padding: 14px 16px;
  color: var(--text-2);
  font-size: 13px;
}

.dp-section-header {
  padding: 0 2px;
}

.dp-section-header .dp-pill {
  color: var(--warning);
  background: var(--warning-bg);
}

.dp-group {
  border-color: var(--border) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--card) !important;
  box-shadow: var(--shadow-sm);
}

.dp-pair {
  border-color: var(--hairline) !important;
}

.merge-modal-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) !important;
  background: var(--card);
}

.merge-modal-header,
.merge-modal-footer {
  border-color: var(--border) !important;
  background: var(--card-subtle);
}

.merge-table th {
  color: var(--text-2) !important;
  background: var(--card-subtle) !important;
  border-color: var(--border) !important;
}

.merge-table td {
  border-color: var(--hairline) !important;
}

/* Phase 6a: repeated inline layout utilities */
.panel-head-split {
  justify-content: space-between;
}

body .panel-action-compact {
  padding: 2px 10px;
  font-size: 0.75rem;
}

.inline-form {
  display: inline;
}

.action-offset {
  margin-left: 8px;
}

/* Phase 4: Quote & Sample detail panel */
body .qs-panel,
body .qs-panel-body,
body .qs-display-group,
body .quote-card-list {
  overflow: visible;
}

.qs-panel-head {
  justify-content: flex-start;
}

.qs-panel-head .qs-open-modal {
  margin-left: auto;
}

.qs-panel-count {
  color: var(--text-faint);
  font-weight: 500;
}

.qs-panel-body {
  padding: 0;
}

body .qs-display-group {
  padding: 14px;
  border-bottom: 1px solid var(--hairline);
}

body .qs-display-group:last-child {
  border-bottom: 0;
}

body .qs-display-meta {
  display: flex;
  align-items: center;
  gap: 6px 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: var(--text-2);
  font-size: 12px;
}

body .qs-display-meta strong {
  color: var(--ink);
  font-size: 12.5px;
}

.quote-card-list {
  display: grid;
  gap: 10px;
}

.quote-card {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card-subtle);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.quote-card:hover {
  border-color: var(--border-2);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.quote-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.quote-supplier {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.quote-supplier-avatar {
  width: 28px;
  height: 28px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 13px;
  font-weight: 600;
}

.quote-supplier-copy {
  min-width: 0;
}

.quote-supplier-name {
  overflow: hidden;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-supplier-sub,
.quote-product-sub {
  color: var(--text-faint);
  font-size: 11px;
}

.quote-price {
  flex: none;
  text-align: right;
}

.quote-price .amt {
  display: block;
  color: var(--brand);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.quote-price .unit {
  display: block;
  color: var(--text-faint);
  font-size: 11px;
}

.quote-product {
  min-width: 0;
  margin-bottom: 10px;
}

.quote-product-code {
  display: inline-flex;
  margin-bottom: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--brand);
  background: var(--brand-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
}

.quote-product-name {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  word-break: normal;
}

.quote-product-sub {
  margin-top: 2px;
}

.quote-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quote-chips .chip {
  padding: 3px 9px;
  border-radius: 6px;
  color: var(--text-2);
  background: var(--page);
  font-size: 11.5px;
}

.quote-context {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.quote-context span {
  color: var(--text);
  font-size: 12px;
}

.quote-context b {
  display: block;
  margin-bottom: 2px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body .qs-display-notes {
  margin-top: 10px;
  padding: 9px 10px;
  border-left: 3px solid var(--info);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-2);
  background: var(--card-subtle);
  font-size: 12px;
  line-height: 1.45;
}

body .qs-modal-backdrop.open {
  align-items: flex-start;
  overflow-y: auto;
}

body .qs-modal,
body .qs-modal-body {
  overflow: visible;
}

body .qs-line-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

body .qs-modal {
  max-height: none;
  margin: auto 0;
}

/* Visual Enrichment v2 */
body .card,
body .detail-card,
body .stat-card,
body .list-table-card,
body .comm-list-card,
body .product-table-wrap,
body .org-table-wrap,
body .people-table-wrap,
body .deal-table-wrap,
body .qs-table-wrap,
body .supplier-wrap,
body .mail-table-wrap {
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lift) !important;
}

body .crm-grid th,
body .crm-grid thead th,
body .supplier-grid th,
body .supplier-grid thead th,
body .qs-grid th,
body .qs-grid thead th,
body .freight-grid th,
body .freight-grid thead th,
body .mail-table th,
body .mini-table th {
  background: var(--thead-grad) !important;
  color: var(--thead-label) !important;
  border-color: rgba(255,255,255,.12) !important;
  border-bottom: 1px solid rgba(255,255,255,.16) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: .06em !important;
  text-transform: uppercase !important;
}

body .crm-grid thead th:hover,
body .supplier-grid thead th:hover,
body .qs-grid thead th:hover,
body .freight-grid thead th:hover {
  background: linear-gradient(180deg,#3A7DBC,#2263A0) !important;
  color: #fff !important;
}

body .crm-grid th .sort-arrow,
body .supplier-grid th .sort-arrow,
body .qs-grid th .sort-arrow,
body .freight-grid th .sort-arrow,
body .sort-arrow {
  color: rgba(232,242,255,.78) !important;
}

body .crm-grid th.sorted-asc .sort-arrow,
body .crm-grid th.sorted-desc .sort-arrow,
body .supplier-grid th.sorted-asc .sort-arrow,
body .supplier-grid th.sorted-desc .sort-arrow,
body .qs-grid th.sorted-asc .sort-arrow,
body .qs-grid th.sorted-desc .sort-arrow,
body .freight-grid th.sorted-asc .sort-arrow,
body .freight-grid th.sorted-desc .sort-arrow {
  color: #fff !important;
}

body .crm-grid th .col-resizer::after,
body .supplier-grid th .col-resizer::after,
body .qs-grid th .col-resizer::after,
body .freight-grid th .col-resizer::after {
  background: rgba(232,242,255,.55) !important;
}

body .crm-grid th .col-resizer:hover::after,
body .supplier-grid th .col-resizer:hover::after,
body .qs-grid th .col-resizer:hover::after,
body .freight-grid th .col-resizer:hover::after {
  background: #fff !important;
}

body .crm-grid th,
body .crm-grid td,
body .supplier-grid th,
body .supplier-grid td,
body .qs-grid th,
body .qs-grid td,
body .freight-grid th,
body .freight-grid td,
body .mail-table th,
body .mail-table td {
  border-left: 0 !important;
  border-right: 0 !important;
}

body .crm-grid tbody tr:nth-child(odd),
body .supplier-grid tbody tr:nth-child(odd),
body .qs-grid tbody tr:nth-child(odd),
body .freight-grid tbody tr:nth-child(odd),
body .mail-table tbody tr:nth-child(odd) {
  background: #fff !important;
}

body .crm-grid tbody tr:nth-child(even),
body .supplier-grid tbody tr:nth-child(even),
body .qs-grid tbody tr:nth-child(even),
body .freight-grid tbody tr:nth-child(even),
body .mail-table tbody tr:nth-child(even) {
  background: #FBFCFE !important;
}

body .crm-grid tbody tr:hover,
body .supplier-grid tbody tr:hover,
body .qs-grid tbody tr:hover,
body .freight-grid tbody tr:hover,
body .mail-table tbody tr:hover {
  background: #F7FAFD !important;
}

body .qs-code,
body .code-badge,
body .badge-code {
  border-radius: 6px !important;
  background: var(--cat-other-bg) !important;
  color: var(--cat-other) !important;
  font-family: var(--mono) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  padding: 3px 8px !important;
}

body .mail-toolbar {
  align-items: center !important;
  padding: 12px 14px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  background: linear-gradient(180deg,#fff,#F7FAFD) !important;
  box-shadow: var(--shadow-lift) !important;
}

body .mail-tab {
  border-radius: var(--radius-pill) !important;
  border-color: var(--border) !important;
  background: var(--card) !important;
  color: var(--text-2) !important;
  font-weight: 600 !important;
}

body .mail-tab.active {
  border-color: var(--brand) !important;
  background: var(--brand) !important;
  color: #fff !important;
  box-shadow: 0 3px 10px -7px rgba(10,68,136,.55);
}

body .mail-date-main,
body .mail-sender-main,
body .mail-subject {
  color: var(--ink) !important;
  font-weight: 700 !important;
}

body .mail-date-main,
body .mail-date-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body .mail-date-time {
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 2px;
}

body .mail-sender-email,
body .mail-subject-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .mail-subject {
  display: inline-block;
  max-width: 100%;
  font-size: 13px;
}

body .mail-subject-preview {
  color: var(--text-3);
  font-size: 12px;
  margin-top: 4px;
}

body .mail-flag-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

body .mail-flag,
body .mail-deal-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
}

body .mail-flag.inbox {
  background: var(--brand-soft);
  color: var(--brand);
}

body .mail-flag.sent {
  background: var(--success-bg);
  color: var(--success);
}

body .mail-flag.attachment {
  background: #F2F5F9;
  color: var(--text-2);
}

body .mail-deal-pill.linked {
  background: var(--success-bg);
  color: var(--success);
}

body .mail-deal-pill.unlinked {
  background: var(--warning-bg);
  color: var(--warning);
}

body .mail-table tr.is-unread {
  box-shadow: inset 3px 0 0 var(--brand);
}

body .mail-table tr.is-unread td {
  background: #F7FAFE !important;
}

body .mail-table tr.is-unread .mail-subject {
  font-weight: 700 !important;
}

body .record-head,
body .detail-header {
  position: relative;
  overflow: hidden;
  margin-bottom: 18px !important;
  padding: 22px 24px !important;
  border: 0 !important;
  border-radius: var(--radius-lg) !important;
  background: linear-gradient(115deg,#2569AA,#2E78B7 48%,#24A1C8) !important;
  box-shadow: var(--shadow-lift) !important;
}

body .record-head::after,
body .detail-header::after {
  content: '';
  position: absolute;
  top: -90px;
  right: -70px;
  width: 260px;
  height: 220px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(143,219,240,.55), transparent 70%);
}

body .record-head > *,
body .detail-header > * {
  position: relative;
  z-index: 1;
}

body .record-avatar {
  background: rgba(255,255,255,.16) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28);
}

body .record-title-row h1,
body .detail-header h3,
body .deal-detail-heading h3 {
  color: #fff !important;
}

body .record-meta,
body .detail-header div[style*="color:#888"],
body .detail-header div[style*="color: #888"] {
  color: rgba(255,255,255,.82) !important;
}

body .record-head a,
body .detail-header a {
  color: #fff !important;
}

body .record-head .badge,
body .detail-header .badge,
body .detail-header .badge-status {
  background: rgba(255,255,255,.18) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.34);
}

body .btn-glass,
body .record-actions .btn,
body .detail-header .btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 14px !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255,255,255,.35) !important;
  background: rgba(255,255,255,.14) !important;
  color: #fff !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-decoration: none !important;
}

body .btn-glass:hover,
body .record-actions .btn:hover,
body .detail-header .btn:hover {
  background: rgba(255,255,255,.24) !important;
  color: #fff !important;
}

body .btn-glass-primary,
body .record-actions .btn-accent,
body #org-ai-summary-btn {
  border: 1px solid rgba(255,255,255,.75) !important;
  background: #fff !important;
  color: var(--brand) !important;
  font-weight: 700 !important;
  box-shadow: 0 8px 18px -13px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.8) !important;
}

body .detail-header .btn-glass-primary {
  border: 1px solid rgba(255,255,255,.35) !important;
  background: rgba(255,255,255,.14) !important;
  color: #fff !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28) !important;
}

body .detail-header .btn-glass-primary:hover {
  background: rgba(255,255,255,.24) !important;
  color: #fff !important;
}

body .detail-card {
  border: 1px solid var(--border) !important;
  border-top: 3px solid var(--section-accent, var(--brand)) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lift) !important;
}

body .detail-card-head {
  min-height: 44px;
  gap: 9px !important;
  border-bottom: 1px solid var(--hairline) !important;
  background: linear-gradient(180deg,var(--section-bg, #EFF5FC),#fff) !important;
  color: var(--section-accent, var(--brand)) !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  letter-spacing: .06em !important;
  text-transform: uppercase !important;
}

body .detail-card-head i,
body .detail-card-head svg {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  padding: 6px;
  background: var(--section-bg, var(--brand-soft));
  color: var(--section-accent, var(--brand));
}

body .detail-card:has(.head-blue),
body .detail-card:has(.head-purple),
body .detail-card:has(.head-gray) {
  --section-accent: var(--brand);
  --section-bg: #EFF5FC;
}

body .detail-card:has(.head-teal) {
  --section-accent: var(--info);
  --section-bg: var(--info-bg);
}

body .detail-card:has(.head-green) {
  --section-accent: var(--success);
  --section-bg: var(--success-bg);
}

body .detail-card:has(.head-orange) {
  --section-accent: var(--warning);
  --section-bg: var(--warning-bg);
}

body .detail-card:has(.head-red),
body .detail-card:has(.head-pink) {
  --section-accent: var(--danger);
  --section-bg: var(--danger-bg);
}

body .ai-panel {
  border: 0 !important;
  border-radius: var(--radius-lg) !important;
  background: linear-gradient(120deg,#1487AE,#23ACD6) !important;
  color: #fff !important;
  box-shadow: var(--shadow-lift) !important;
}

body .ai-panel-head {
  background: transparent !important;
  color: #fff !important;
  border-bottom: 1px solid rgba(255,255,255,.22);
}

body .ai-panel-body {
  color: #fff !important;
}

body .tag-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin: 1px 4px 1px 0;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--cat-bg, var(--cat-other-bg));
  color: var(--cat, var(--cat-other));
  font-size: 11.5px;
  font-weight: 700;
}

body .qs-modal-body {
  flex: none;
}

body .qs-line-typeahead {
  z-index: 1;
}

body .qs-line-typeahead:focus-within {
  z-index: 2500;
}

body .qs-line-menu {
  z-index: 2600;
}

@media (max-width: 720px) {
  .qs-panel-head {
    align-items: center;
  }

  .qs-panel-head .section-title {
    flex: 1;
  }

  .qs-panel-head .qs-open-modal {
    width: 100%;
    margin-left: 50px;
  }

  .quote-card-top {
    align-items: flex-start;
  }

  .quote-price .amt {
    font-size: 14px;
  }
}

/* Phase 7: login */
.auth-page,
.auth-page * {
  box-sizing: border-box;
}

body.auth-page {
  min-height: 100vh;
  margin: 0;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  background: var(--card);
}

.auth-card {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  background: var(--card);
}

.auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: clamp(56px, 7vw, 112px);
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-strong) 52%, var(--ink) 100%);
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.auth-orb-1 {
  top: -80px;
  right: -70px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle at 32% 32%, rgba(35, 172, 214, 0.45), rgba(35, 172, 214, 0) 70%);
}

.auth-orb-2 {
  bottom: -70px;
  left: -90px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle at 40% 40%, rgba(127, 210, 236, 0.20), rgba(127, 210, 236, 0) 70%);
}

.auth-eyebrow {
  position: relative;
  margin-bottom: 16px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-h1 {
  position: relative;
  margin: 0;
  color: var(--card);
  font-size: clamp(36px, 3.2vw, 54px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.01em;
}

.auth-sub {
  position: relative;
  max-width: 520px;
  margin: 16px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.6;
}

.auth-modules {
  position: relative;
  max-width: 560px;
  margin-top: clamp(36px, 5vh, 64px);
}

.auth-modules-label {
  margin-bottom: 13px;
  color: rgba(127, 210, 236, 0.85);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.auth-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: var(--radius-pill);
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.10);
  font-size: 14px;
  font-weight: 500;
}

.auth-chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.auth-chip-ai {
  border-color: rgba(127, 210, 236, 0.55);
  color: var(--card);
  background: rgba(35, 172, 214, 0.20);
  box-shadow: 0 0 0 1px rgba(127, 210, 236, 0.12), 0 4px 14px -6px rgba(35, 172, 214, 0.60);
  font-weight: 600;
}

.auth-logos {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: auto;
  max-width: 620px;
  padding: 28px 32px;
  border: 1px solid rgba(255, 255, 255, 0.80);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 56px -22px rgba(4, 18, 40, 0.60), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.auth-logo {
  display: block;
  width: auto;
  max-width: 36%;
  object-fit: contain;
}

.auth-logo-lyson {
  height: 42px;
}

.auth-logo-gw {
  height: 31px;
}

.auth-logo-ss {
  height: 58px;
}

.auth-logo-div {
  width: 1px;
  height: 42px;
  flex: none;
  background: linear-gradient(180deg, rgba(11, 42, 78, 0), rgba(11, 42, 78, 0.14), rgba(11, 42, 78, 0));
}

.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: clamp(56px, 8vw, 128px);
}

.auth-form > * {
  width: 100%;
  max-width: 540px;
  align-self: center;
}

.auth-form-title {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 30px;
  font-weight: 600;
}

.auth-form-note {
  margin: 0 0 34px;
  color: var(--text-3);
  font-size: 15px;
}

.auth-page .form-group {
  margin-bottom: 18px;
}

.auth-page .form-group .auth-label {
  margin-bottom: 7px;
}

.auth-page .form-group .auth-input {
  height: 52px;
  min-height: 52px;
  padding: 0 14px;
  margin: 0;
  border-color: var(--border-2);
  background: var(--card-subtle);
  color: var(--ink);
}

.auth-page .form-group .auth-input:focus {
  border-color: var(--brand);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.auth-btn {
  width: 100%;
  height: 52px;
  margin-top: 6px;
  border: none;
  border-radius: var(--radius);
  color: var(--card);
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
}

.auth-btn:hover {
  filter: brightness(1.05);
}

.auth-error {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--danger);
  background: var(--danger-bg);
  font-size: 13px;
}

@media (max-width: 760px) {
  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 560px;
    padding: 32px 28px;
  }

  .auth-h1 {
    font-size: 32px;
  }

  .auth-form {
    min-height: 100vh;
    padding: 48px 28px;
  }
}

@media (max-width: 430px) {
  .auth-brand {
    min-height: 520px;
    padding: 28px 20px;
  }

  .auth-logos {
    gap: 10px;
    padding: 20px 16px;
  }

  .auth-logo-lyson {
    height: 29px;
  }

  .auth-logo-gw {
    height: 22px;
  }

  .auth-logo-ss {
    height: 42px;
  }

  .auth-form {
    padding: 42px 22px;
  }
}
