/* Formalactis CRM · Enterprise Design System */
:root {
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --border: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --brand-navy: #0f172a;
  --brand-accent: #2563eb;
  --brand-accent-hover: #1d4ed8;
  --brand-gold: #b45309;

  --primary: #0f172a;
  --primary-hover: #1e293b;
  --primary-text: #ffffff;

  --status-s0-bg: #fffbeb;
  --status-s0-text: #92400e;
  --status-s0-border: #fde68a;
  --status-s0-dot: #f59e0b;

  --status-s1-bg: #eff6ff;
  --status-s1-text: #1d4ed8;
  --status-s1-border: #dbeafe;
  --status-s1-dot: #3b82f6;

  --status-s2-bg: #ecfdf5;
  --status-s2-text: #047857;
  --status-s2-border: #a7f3d0;
  --status-s2-dot: #10b981;

  --status-s3-bg: #f8fafc;
  --status-s3-text: #64748b;
  --status-s3-border: #e2e8f0;
  --status-s3-dot: #94a3b8;

  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-pill: 9999px;

  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-dialog: 0 24px 48px -12px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(15, 23, 42, 0.08);

  --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text-body);
  font-family: var(--font-stack);
  font-size: 13.5px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography Defaults */
h1, h2, h3, h4 {
  color: var(--text-main);
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
}

h3 {
  font-size: 13px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

p {
  margin: 0;
}

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

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

a {
  color: var(--brand-accent);
  text-decoration: none;
  transition: color 0.12s ease;
}

a:hover {
  color: var(--brand-accent-hover);
  text-decoration: underline;
}

/* Buttons & Controls */
button, .button, input, select, textarea {
  font-family: inherit;
  font-size: 13px;
}

button, .button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-300);
  background: #ffffff;
  color: var(--slate-800);
  font-weight: 500;
  line-height: 1;
  text-decoration: none !important;
  box-shadow: var(--shadow-xs);
  transition: all 0.12s ease-in-out;
  white-space: nowrap;
}

button:hover, .button:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
  color: var(--slate-900);
}

button:active, .button:active {
  transform: translateY(1px);
}

button:disabled, .button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Button Variants */
.primary, button.primary, .button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.primary:hover, button.primary:hover, .button.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

.button-secondary {
  background: #ffffff;
  border-color: var(--slate-300);
  color: var(--slate-700);
}

.button-secondary:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
  color: var(--slate-900);
}

.button-subtle {
  background: transparent;
  border-color: transparent;
  color: var(--slate-600);
  box-shadow: none;
}

.button-subtle:hover {
  background: var(--slate-100);
  border-color: transparent;
  color: var(--slate-900);
}

.button-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.danger-button {
  background: #ffffff;
  border-color: #fecaca;
  color: #b91c1c;
}

.danger-button:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

/* Inputs & Form Fields */
input, select, textarea {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-300);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea {
  height: auto;
  min-height: 72px;
  padding: 8px 10px;
  line-height: 1.45;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input::placeholder, textarea::placeholder {
  color: var(--slate-400);
}

select {
  padding-right: 24px;
  cursor: pointer;
  background-image: 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='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  appearance: none;
  -webkit-appearance: none;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--slate-500);
  background: var(--slate-100);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-xs);
  box-shadow: 0 1px 0 var(--slate-300);
}

/* Notifications */
#notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--slate-900);
  color: #ffffff;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: noticeSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#notice.error {
  background: #991b1b;
}

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

/* ==========================================================================
   SIDEBAR & MOBILE DRAWER
   ========================================================================== */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.sidebar-close-btn {
  display: none;
}

.mobile-menu-btn {
  display: none;
}

.sidebar {
  width: 250px;
  position: fixed;
  inset: 0 auto 0 0;
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  z-index: 30;
  overflow-y: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  padding: 0 4px 18px;
  border-bottom: 1px solid var(--slate-100);
  text-decoration: none !important;
}

.brand-title {
  display: flex;
  align-items: baseline;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-formal {
  color: #0e66b0;
}

.brand-a {
  color: #5cb249;
}

.brand-ctis {
  color: #0e66b0;
}

.brand-sub {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate-400);
  margin-top: 5px;
}

.workspace {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  margin: 16px 0 18px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
}

.workspace-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--slate-800);
  color: #ffffff;
  font-weight: 600;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.workspace span {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-800);
  display: block;
  line-height: 1.25;
}

.workspace small {
  font-size: 10.5px;
  color: var(--slate-500);
  display: block;
  line-height: 1.2;
}

.nav-caption {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate-400);
  padding: 0 8px;
  margin: 12px 0 6px;
}

.nav {
  width: 100%;
  height: 34px;
  border: 1px solid transparent;
  box-shadow: none;
  background: transparent;
  color: var(--slate-600);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-md);
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 2px;
}

.nav:hover {
  background: var(--slate-100);
  color: var(--slate-900);
  border-color: transparent;
}

.nav.active {
  background: var(--slate-100);
  color: var(--slate-900);
  font-weight: 600;
  border-color: var(--slate-200);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-500);
}

.nav.active .nav-icon {
  color: var(--brand-accent);
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--slate-200);
  color: var(--slate-700);
}

.nav.active .nav-badge {
  background: var(--slate-800);
  color: #ffffff;
}

.sidebar-shortcuts {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--slate-100);
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--slate-500);
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--slate-100);
  font-size: 11.5px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--slate-600);
  font-weight: 500;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.logout-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--slate-500);
}

.logout-link:hover {
  color: #b91c1c;
  text-decoration: none;
}

/* ==========================================================================
   MAIN AREA & TOPBAR
   ========================================================================== */
main {
  margin-left: 250px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 58px;
  padding: 0 36px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.crumb-root {
  font-size: 13px;
  color: var(--slate-500);
}

.topbar-left strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--slate-900);
}

.filter-indicator {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--status-s0-bg);
  color: var(--status-s0-text);
  border: 1px solid var(--status-s0-border);
}

.content {
  padding: 32px 36px 64px;
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
}

.heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.heading h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-top: 4px;
  margin-bottom: 6px;
  color: var(--slate-900);
}

.heading .muted {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--slate-500);
}

.actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ==========================================================================
   KPI STRIP (Executive Pipeline Overview)
   ========================================================================== */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 26px;
}

.stat, button.stat {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  height: auto !important;
  min-height: 104px !important;
  padding: 14px 16px !important;
  white-space: normal !important;
  line-height: 1.4 !important;
  text-align: left !important;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  position: relative;
  cursor: pointer;
  transition: all 0.12s ease;
  width: auto;
}

.stat:hover {
  border-color: var(--slate-300);
  background: var(--slate-50);
}

.stat.active-stat {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 1px var(--brand-accent), var(--shadow-xs);
  background: #ffffff;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-bottom: 6px;
}

.stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.stat-total .stat-dot { background: var(--slate-600); }
.stat-s0 .stat-dot { background: var(--status-s0-dot); }
.stat-s1 .stat-dot { background: var(--status-s1-dot); }
.stat-s2 .stat-dot { background: var(--status-s2-dot); }
.stat-s3 .stat-dot { background: var(--status-s3-dot); }

.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
  white-space: nowrap;
  min-width: 0;
}

.stat-pct {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--slate-500);
  background: var(--slate-100);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  white-space: nowrap;
}

.stat strong {
  display: block !important;
  font-size: 24px !important;
  font-weight: 750 !important;
  letter-spacing: -0.02em !important;
  color: var(--slate-900) !important;
  font-variant-numeric: tabular-nums !important;
  line-height: 1.15 !important;
  margin: 4px 0 4px !important;
}

.stat small {
  display: block !important;
  font-size: 11.5px !important;
  color: var(--slate-500) !important;
  line-height: 1.35 !important;
  white-space: normal !important;
  margin: 0 !important;
}

/* ==========================================================================
   PANEL, TOOLBAR & FILTERS
   ========================================================================== */
.panel {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.panel-title-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.count {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--slate-500);
  background: var(--slate-100);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  margin-left: 4px;
}

/* Segmented Control (High-End iOS/Linear Style) */
.quick-chips {
  display: inline-flex;
  align-items: center;
  background: var(--slate-100);
  padding: 2px;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
}

.chip {
  height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--slate-600);
  box-shadow: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.chip:hover {
  color: var(--slate-900);
  background: rgba(255, 255, 255, 0.5);
}

.chip.active {
  background: #ffffff;
  color: var(--slate-900);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.sort-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--slate-500);
}

.sort-label select {
  height: 28px;
  font-size: 12px;
  padding: 0 24px 0 8px;
}

/* Secondary Filter Toolbar */
.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--border);
}

.search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}

.search input {
  width: 100%;
  height: 32px;
  padding-left: 30px;
  padding-right: 30px;
  font-size: 12.5px;
  border-radius: var(--radius-md);
  background: #ffffff;
}

.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  color: var(--slate-400);
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.filters select {
  height: 32px;
  font-size: 12.5px;
  padding: 0 24px 0 8px;
  background-color: #ffffff;
  max-width: 170px;
}

.filters select.has-value {
  border-color: var(--brand-accent);
  background-color: #f0f7ff;
  color: var(--brand-accent-hover);
  font-weight: 500;
}

.reset-button {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--slate-500);
  background: transparent;
  border: 1px dashed var(--slate-300);
  box-shadow: none;
}

.reset-button:hover {
  background: var(--slate-100);
  color: var(--slate-800);
  border-style: solid;
}

/* ==========================================================================
   DATA TABLE (Compact, Enterprise Density, Hairline Borders)
   ========================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

thead th {
  height: 34px;
  padding: 0 14px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--slate-100);
  transition: background-color 0.08s ease;
}

tbody tr:hover {
  background-color: #f8fafc;
}

tbody td {
  padding: 10px 14px;
  vertical-align: middle;
  font-size: 13px;
  color: var(--slate-700);
}

.th-action, .td-action {
  text-align: right;
  width: 90px;
}

/* Entity Cell */
.entity-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.entity-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  color: var(--slate-700);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.entity-avatar.individual {
  background: #fdf4ff;
  border-color: #f5d0fe;
  color: #a21caf;
}

.entity-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.entity-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--slate-900);
  cursor: pointer;
  line-height: 1.3;
}

.entity-title:hover {
  color: var(--brand-accent);
}

.micro-icon {
  display: inline-block;
  vertical-align: -1.5px;
  flex-shrink: 0;
}

.entity-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--slate-600);
}

.entity-sub-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sub-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meta-pill {
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 6px;
  background: var(--slate-100);
  color: var(--slate-600);
  border-radius: var(--radius-xs);
  border: 1px solid var(--slate-200);
}

.note-preview {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--slate-500);
  margin-top: 2px;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Contact Cell */
.contact-cell {
  min-width: 200px;
}

.email-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.email-link {
  font-size: 12.5px;
  color: var(--slate-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.email-link:hover {
  color: var(--brand-accent);
}

.copy-btn {
  height: 20px;
  padding: 0 6px;
  font-size: 10.5px;
  color: var(--slate-500);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  box-shadow: none;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

tbody tr:hover .copy-btn {
  opacity: 1;
  border-color: var(--slate-200);
  background: #ffffff;
}

.copy-btn:hover {
  color: var(--slate-800);
  border-color: var(--slate-300);
}

.phone-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 3px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--slate-600);
}

.phone-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 23px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-200);
  background: #ffffff;
  color: var(--slate-700);
  text-decoration: none !important;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  transition: all 0.1s ease;
}

.action-pill:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
  color: var(--slate-900);
}

.action-pill.wa {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
  font-weight: 600;
}

.action-pill.wa:hover {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.action-pill.call {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
  font-weight: 500;
}

.action-pill.call:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #075985;
}

.action-pill.mail {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #475569;
}

.action-pill.mail:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* Location */
.loc-city {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--slate-900);
}

.prov-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  background: var(--slate-100);
  color: var(--slate-600);
  border: 1px solid var(--slate-200);
}

.loc-country {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--slate-500);
  margin-top: 2px;
}

/* Status Badge Select */
.status-select {
  height: 26px;
  padding: 0 20px 0 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  cursor: pointer;
  border-width: 1px;
  border-style: solid;
}

.status-select.s0 {
  background-color: var(--status-s0-bg);
  color: var(--status-s0-text);
  border-color: var(--status-s0-border);
}

.status-select.s1 {
  background-color: var(--status-s1-bg);
  color: var(--status-s1-text);
  border-color: var(--status-s1-border);
}

.status-select.s2 {
  background-color: var(--status-s2-bg);
  color: var(--status-s2-text);
  border-color: var(--status-s2-border);
}

.status-select.s3 {
  background-color: var(--status-s3-bg);
  color: var(--status-s3-text);
  border-color: var(--status-s3-border);
}

/* Origin & Category tags */
.fair-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--slate-800);
}

.cat-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--slate-500);
  margin-top: 1px;
}

.open-card-btn {
  height: 26px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--slate-200);
  color: var(--slate-600);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.open-card-btn:hover {
  background: var(--slate-100);
  color: var(--slate-900);
  border-color: var(--slate-300);
}

/* Loading & Empty state */
.loading-cell {
  text-align: center;
  padding: 48px 16px !important;
  color: var(--slate-500);
  font-size: 13.5px;
}

/* Pagination Bar */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--slate-500);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pagination-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-controls select {
  height: 28px;
  padding: 0 20px 0 6px;
  font-size: 12px;
}

.page-buttons {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.page-buttons button {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  background: #ffffff;
}

.footnote {
  font-size: 11.5px;
  color: var(--slate-400);
  margin-top: 12px;
  text-align: right;
}

/* ==========================================================================
   CONTACT MODAL (Enterprise Modal Dialog)
   ========================================================================== */
dialog {
  border: none;
  background: transparent;
  padding: 0;
  margin: auto;
  max-width: 720px;
  width: 92%;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

#contact-form {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-dialog);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  border: 1px solid var(--slate-200);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dialog-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--slate-800);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-title-wrap h2 {
  font-size: 17px;
  font-weight: 650;
  color: var(--slate-900);
}

.close-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--slate-400);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.close-btn:hover {
  background: var(--slate-100);
  color: var(--slate-800);
}

.quick-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--border);
}

.dialog-sections {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-section {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.form-section-title {
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-700);
}

.form-grid label.wide {
  grid-column: 1 / -1;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--slate-50);
  border-top: 1px solid var(--border);
}

.dialog-footer-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

#form-error {
  margin: 0 20px 8px;
  font-size: 12px;
  color: #b91c1c;
}

/* ==========================================================================
   IMPORT CSV VIEW & WIZARD
   ========================================================================== */
.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.steps span {
  flex: 1;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-500);
}

.steps span strong {
  color: var(--slate-700);
  margin-right: 4px;
}

.steps span.current {
  border-color: var(--brand-accent);
  background: #f0f7ff;
  color: var(--brand-accent-hover);
  font-weight: 600;
}

.import-panel {
  padding: 20px 24px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-lg);
  background: var(--slate-50);
  cursor: pointer;
  margin: 16px 0;
  transition: all 0.15s ease;
  text-align: center;
}

.dropzone:hover {
  border-color: var(--brand-accent);
  background: #f8fafc;
}

.dropzone-icon {
  margin-bottom: 8px;
  color: var(--slate-400);
}

.dropzone input {
  display: none;
}

.highlight-summary {
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-800);
  background: var(--slate-100);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin: 10px 0;
}

/* ==========================================================================
   LOGIN SCREEN (Executive B2B Login)
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f1f5f9;
  background-image: radial-gradient(circle at 50% 0%, #ffffff 0%, #f1f5f9 75%);
}

.login-shell {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--slate-100);
}

.login-header .brand {
  padding: 0;
  border: none;
  background: transparent;
}

.security-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-600);
  background: var(--slate-100);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--slate-200);
}

.login-card h1 {
  font-size: 19px;
  margin-bottom: 6px;
}

.login-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form label {
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-700);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-form input {
  height: 36px;
  font-size: 13.5px;
}

.login-submit {
  height: 36px;
  font-size: 13px;
  margin-top: 4px;
}

.login-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--slate-100);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--slate-400);
  text-align: center;
}

/* ==========================================================================
   RESPONSIVE DESIGN (Full Mobile Optimization)
   ========================================================================== */
body.no-scroll {
  overflow: hidden !important;
}

/* Tablet (max-width: 1024px) */
@media (max-width: 1024px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

/* Mobile & Small Tablets (max-width: 768px) */
@media (max-width: 768px) {
  /* Mobile Sidebar Drawer */
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    color: var(--slate-700);
    cursor: pointer;
    flex-shrink: 0;
  }

  .mobile-menu-btn:hover {
    background: var(--slate-100);
    color: var(--slate-900);
  }

  .sidebar-backdrop {
    display: block;
    pointer-events: none;
  }

  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--slate-500);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
  }

  .sidebar-close-btn:hover {
    background: var(--slate-100);
    color: var(--slate-900);
  }

  main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Topbar */
  .topbar {
    height: 54px;
    padding: 0 14px;
  }

  .crumb-root, .topbar-left .muted {
    display: none;
  }

  .topbar-left {
    gap: 8px;
  }

  .topbar-left strong {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  .topbar-right .btn-text {
    display: none;
  }

  .topbar-right button {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Content area */
  .content {
    padding: 16px 12px 48px;
  }

  /* Heading */
  .heading {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 18px;
  }

  .heading h1 {
    font-size: 21px;
    line-height: 1.25;
  }

  .heading .muted {
    font-size: 12.5px;
  }

  .actions {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .actions button, .actions a {
    flex: 1;
    height: 36px;
    padding: 0 8px;
    font-size: 12px;
    justify-content: center;
    text-align: center;
  }

  /* Swipeable KPI Strip (Touch-friendly horizontal scroll) */
  .stats {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 10px;
    padding-bottom: 8px;
    margin-bottom: 18px;
  }

  .stats::-webkit-scrollbar {
    height: 4px;
  }

  .stats::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 4px;
  }

  .stat, button.stat {
    min-width: 155px;
    flex: 0 0 155px;
    scroll-snap-align: start;
    padding: 12px 14px !important;
    min-height: 94px !important;
    height: auto !important;
    white-space: normal !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .stat strong {
    font-size: 21px !important;
    margin: 4px 0 2px !important;
  }

  .stat small {
    font-size: 11px !important;
    line-height: 1.3 !important;
    white-space: normal !important;
  }

  /* Panel & Filters */
  .panel {
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
  }

  .panel-title {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .panel-title-left {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .panel-title-left h2 {
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .quick-chips {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    white-space: nowrap;
    padding: 2px;
  }

  .chip {
    flex: 1;
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
    justify-content: center;
  }

  .panel-title-right {
    width: 100%;
  }

  .sort-label {
    width: 100%;
    justify-content: space-between;
  }

  .sort-label select {
    flex: 1;
    height: 30px;
  }

  .filters {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .search input {
    height: 38px;
    font-size: 14px;
    padding-left: 32px;
  }

  .search-kbd {
    display: none;
  }

  .filters label {
    width: 100%;
  }

  .filters select {
    width: 100%;
    max-width: 100%;
    height: 36px;
    font-size: 13px;
  }

  .reset-button {
    width: 100%;
    height: 36px;
    justify-content: center;
  }

  /* Responsive Touch Card Layout (Transforming Table into Mobile Cards) */
  .table-wrap {
    background: transparent;
    border: none;
    overflow-x: visible;
  }

  table, thead, tbody, th, td, tr {
    display: block;
    width: 100%;
  }

  thead {
    display: none !important;
  }

  tbody {
    padding: 10px;
    background: var(--slate-100);
  }

  tbody tr {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid var(--border);
  }

  tbody tr:last-child {
    margin-bottom: 0;
  }

  tbody tr:hover {
    background: #ffffff;
  }

  tbody td {
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
  }

  .entity-cell {
    gap: 10px;
  }

  .entity-title {
    font-size: 15px;
    line-height: 1.3;
  }

  .entity-sub {
    font-size: 12px;
    margin-top: 2px;
  }

  .note-preview {
    max-width: 100%;
    white-space: normal;
    font-size: 11.5px;
    margin-top: 4px;
    line-height: 1.35;
  }

  /* Contact cell & Touch actions on mobile */
  .contact-cell {
    min-width: 0;
    width: 100%;
    padding: 8px 0 !important;
    border-top: 1px dashed var(--slate-200) !important;
    border-bottom: 1px dashed var(--slate-200) !important;
  }

  .email-row {
    justify-content: space-between;
    margin-bottom: 6px;
  }

  .email-link {
    max-width: 220px;
    font-size: 12.5px;
  }

  .copy-btn {
    height: 24px;
    padding: 0 8px;
    opacity: 1;
    border-color: var(--slate-200);
    background: var(--slate-50);
  }

  .phone-list {
    margin-top: 4px;
    gap: 4px;
  }

  .row-actions {
    margin-top: 8px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .action-pill {
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
    justify-content: center;
    border-radius: var(--radius-sm);
  }

  .action-pill span {
    font-size: 12px;
  }

  /* Location */
  .loc-city {
    font-size: 13px;
  }

  .loc-country {
    font-size: 11.5px;
  }

  /* Status selector full width on card */
  .status-select {
    width: 100%;
    height: 34px;
    font-size: 12.5px;
    text-align: center;
    border-radius: var(--radius-md);
  }

  /* Origin & Category */
  .fair-badge {
    font-size: 12px;
  }

  .cat-tag {
    font-size: 11.5px;
  }

  /* Action Scheda */
  .th-action, .td-action {
    width: 100% !important;
    text-align: left;
    margin-top: 2px;
  }

  .open-card-btn {
    width: 100%;
    height: 38px;
    justify-content: center;
    background: var(--slate-900);
    border-color: var(--slate-900);
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: var(--radius-md);
  }

  .open-card-btn:hover {
    background: var(--slate-800);
    color: #ffffff;
  }

  /* Pagination Mobile */
  .pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }

  #page-info {
    text-align: center;
    font-size: 12px;
  }

  .pagination-controls {
    width: 100%;
    flex-direction: column;
    gap: 10px;
  }

  .pagination-controls label {
    width: 100%;
    justify-content: space-between;
  }

  .page-buttons {
    width: 100%;
    display: flex;
    gap: 6px;
  }

  .page-buttons button {
    flex: 1;
    height: 36px;
    font-size: 12px;
    justify-content: center;
  }

  /* Modal Fullscreen on Mobile */
  dialog {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  #contact-form {
    border-radius: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border: none !important;
  }

  .dialog-head {
    padding: 14px 16px;
  }

  .dialog-title-wrap h2 {
    font-size: 16px;
  }

  .quick-actions-bar {
    padding: 10px 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .quick-actions-bar .action-pill {
    width: 100%;
    height: 36px;
    justify-content: center;
  }

  .dialog-sections {
    padding: 14px 16px;
    gap: 12px;
  }

  .form-section {
    padding: 12px 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .dialog-footer {
    padding: 12px 16px;
    flex-direction: column-reverse;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }

  .dialog-footer-right {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .dialog-footer-right button {
    flex: 1;
    height: 42px;
    font-size: 13.5px;
  }

  .danger-button {
    width: 100%;
    height: 38px;
    justify-content: center;
  }

  /* CSV Import Mobile */
  .steps {
    flex-direction: column;
    gap: 4px;
    padding: 6px;
  }

  .steps span {
    width: 100%;
    justify-content: flex-start;
  }

  .import-panel {
    padding: 16px 14px;
  }
}

/* Extra Small Phones (max-width: 480px) */
@media (max-width: 480px) {
  .login-shell {
    padding: 12px;
  }

  .login-card {
    padding: 24px 18px;
    border-radius: 16px;
  }

  .login-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .login-submit {
    height: 40px;
    font-size: 14px;
  }

  .row-actions {
    grid-template-columns: 1fr;
  }
}
