/* =============================================================================
   Metal America Partner CRM — Stylesheet v2
   Refined, premium, Airbnb-inspired with brand red as a precious accent.
   ============================================================================= */

:root {
  /* Brand */
  --ma-red: #FF2400;
  --ma-red-hover: #D42F4D;
  --ma-red-pressed: #B01C2E;
  --ma-red-light: #FFF5F6;
  --ma-red-soft: #FFE6EA;
  --ma-red-border: #FFBDC9;
  --ma-red-glow: rgba(255, 36, 0, 0.18);

  /* Neutrals — refined for warmth */
  --n-0:   #FFFFFF;
  --n-10:  #FAFAF9;
  --n-20:  #F4F4F2;
  --n-30:  #EBEBE8;
  --n-40:  #DDDDD9;
  --n-50:  #B6B6B0;
  --n-60:  #8A8A85;
  --n-70:  #5F5F5C;
  --n-80:  #3A3A38;
  --n-90:  #1F1F1E;
  --n-100: #0A0A0A;

  /* Surfaces */
  --page-bg: #FAFAF9;
  --card-bg: #FFFFFF;
  --card-hover: #FBFBFA;
  --sidebar-bg: #FFFFFF;
  --input-bg: #FFFFFF;
  --overlay: rgba(15, 15, 15, 0.45);

  /* Semantic */
  --success: #00A699;
  --success-light: #E6FAF7;
  --warning: #FFB400;
  --warning-light: #FFF6E0;
  --info: #428BFF;
  --info-light: #E8F1FF;
  --hot: #FF2400;
  --warm: #FFB400;
  --cold: #6E94E0;

  /* Shadows — layered for depth */
  --s-1: 0 1px 2px rgba(15, 15, 15, 0.04), 0 0 0 1px rgba(15, 15, 15, 0.05);
  --s-2: 0 2px 4px rgba(15, 15, 15, 0.06), 0 1px 2px rgba(15, 15, 15, 0.04), 0 0 0 1px rgba(15, 15, 15, 0.04);
  --s-3: 0 12px 24px rgba(15, 15, 15, 0.08), 0 4px 8px rgba(15, 15, 15, 0.04), 0 0 0 1px rgba(15, 15, 15, 0.04);
  --s-4: 0 24px 48px rgba(15, 15, 15, 0.14), 0 8px 16px rgba(15, 15, 15, 0.06);
  --s-inset: inset 0 1px 2px rgba(15, 15, 15, 0.06);
  --s-glow: 0 0 0 4px var(--ma-red-glow);

  /* Radius */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 9999px;

  /* Type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 140ms;
  --t-base: 200ms;
  --t-slow: 320ms;

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 68px;
}

/* =============================================================================
   RESET
   ============================================================================= */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--n-100);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  overflow-x: hidden;
}

/* Tabular numerals everywhere numbers matter */
.tabular, .stat-value, table.data td, .kanban-card-value, .deal-value, .money {
  font-variant-numeric: tabular-nums;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--ma-red);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--n-100);
}

svg { fill: none; display: inline-block; vertical-align: middle; flex-shrink: 0; }

a { color: var(--n-100); text-decoration: none; border-bottom: 1px solid currentColor; }
a:hover { color: var(--ma-red); }

h1, h2, h3, h4, h5 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--n-100);
}
h1 { font-size: 26px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }

::selection { background: var(--ma-red); color: white; }

/* Custom scrollbar (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 8px; border: 2px solid var(--page-bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* =============================================================================
   AUTH SCREEN
   ============================================================================= */

.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(255, 36, 0, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255, 36, 0, 0.04), transparent 60%),
    var(--page-bg);
  padding: 24px;
  z-index: 100;
  animation: fadeIn 400ms var(--ease);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 540px) {
  .auth-screen {
    align-items: flex-start;
    padding: 32px 16px;
  }
  .auth-card {
    padding: 32px 24px 24px;
    box-shadow: var(--s-2);
  }
}

.auth-card {
  background: var(--card-bg);
  border-radius: var(--r-lg);
  box-shadow: var(--s-4);
  padding: 44px 38px 32px;
  width: 100%;
  max-width: 420px;
  animation: liftIn 500ms var(--ease-spring);
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-logo { height: 36px; width: auto; margin-bottom: 10px; }
.auth-tagline {
  font-size: 11px;
  color: var(--n-60);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.auth-tabs {
  display: flex;
  background: var(--n-20);
  border-radius: var(--r-pill);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--n-70);
  border-radius: var(--r-pill);
  transition: all var(--t-fast) var(--ease);
}

.auth-tab:hover { color: var(--n-100); }
.auth-tab.active {
  background: var(--card-bg);
  color: var(--n-100);
  box-shadow: var(--s-1);
}

.auth-form { display: none; flex-direction: column; gap: 14px; }
.auth-form.active { display: flex; }

.auth-help {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--n-70);
  line-height: 1.55;
}

.auth-error {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--ma-red-light);
  border: 1px solid var(--ma-red-border);
  border-radius: var(--r-sm);
  color: var(--ma-red-pressed);
  font-size: 13px;
  text-align: center;
}

/* =============================================================================
   APP SHELL
   ============================================================================= */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ----- SIDEBAR ----- */

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--n-30);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.brand {
  padding: 4px 12px 24px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--n-30);
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 160px;
  height: auto;
  margin: 0 0 8px 0;
  padding: 0;
}
.brand-sub {
  font-size: 10px;
  color: var(--n-60);
  text-transform: uppercase;
  letter-spacing: 1.6px;
  font-weight: 700;
  padding: 0;
  margin: 0;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--n-70);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  transition: all var(--t-fast) var(--ease);
}

.nav-item:hover { background: var(--n-20); color: var(--n-100); }

.nav-item.active {
  color: var(--n-100);
  background: var(--ma-red-light);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  width: 3px;
  height: 22px;
  background: var(--ma-red);
  border-radius: 0 3px 3px 0;
  transform: translateY(-50%);
  animation: indicatorIn 300ms var(--ease-spring);
}

@keyframes indicatorIn {
  from { transform: translateY(-50%) scaleY(0.4); opacity: 0; }
  to { transform: translateY(-50%) scaleY(1); opacity: 1; }
}

.nav-item.active .nav-icon { color: var(--ma-red); }
.nav-icon { width: 18px; height: 18px; color: currentColor; transition: color var(--t-fast) var(--ease); }

.nav-badge {
  margin-left: auto;
  background: var(--ma-red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  min-width: 20px;
  text-align: center;
  display: none;
  font-variant-numeric: tabular-nums;
}
.nav-badge.show { display: inline-block; }

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--n-20);
  margin-top: 12px;
  transition: background var(--t-fast) var(--ease);
}
.user-card:hover { background: var(--n-30); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white;
  background: var(--ma-red);
  flex-shrink: 0;
  letter-spacing: -0.02em;
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.1);
}

.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--n-100); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--n-70); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  color: var(--n-70);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--n-30); color: var(--n-100); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 16px; height: 16px; }

/* ----- MAIN ----- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--page-bg);
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  border-bottom: 1px solid var(--n-30);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(1.6) blur(10px);
  -webkit-backdrop-filter: saturate(1.6) blur(10px);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.topbar-menu { display: none; }

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .filter-bar { gap: 8px; }
  .filter-bar > * { flex: 1 1 calc(50% - 4px); }
  .filter-bar .search-bar { flex-basis: 100%; }
  .filter-bar .segmented { flex: 1 1 100%; }
  .filter-bar .segmented button { flex: 1; }
}

.topbar-context { flex: 1; min-width: 0; }
.topbar-context h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.topbar-context .breadcrumb {
  font-size: 11px;
  color: var(--n-60);
  margin-bottom: 1px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}

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

.cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  background: var(--n-20);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--n-60);
  transition: all var(--t-fast) var(--ease);
}
.cmdk-trigger:hover { background: var(--n-30); color: var(--n-100); }
.cmdk-trigger svg { width: 14px; height: 14px; color: var(--n-60); }
.cmdk-trigger kbd {
  font-family: var(--font);
  background: var(--card-bg);
  border: 1px solid var(--n-30);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--n-70);
}

.view-slot {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 32px 48px;
  width: 100%;
  min-width: 0;
}

.view-slot > * { animation: viewIn 280ms var(--ease); }

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

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--r-pill);
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: -0.005em;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--ma-red);
  color: white;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:hover {
  background: var(--ma-red-hover);
  box-shadow: 0 4px 12px var(--ma-red-glow), inset 0 1px 0 rgba(255,255,255,0.18);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: var(--ma-red-border); cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: var(--card-bg);
  color: var(--n-100);
  border: 1px solid var(--n-40);
  box-shadow: var(--s-1);
}
.btn-secondary:hover {
  background: var(--n-20);
  border-color: var(--n-50);
  box-shadow: var(--s-2);
  transform: translateY(-1px);
}
.btn-secondary:active { transform: translateY(0); }

.btn-ghost { background: transparent; color: var(--n-70); }
.btn-ghost:hover { background: var(--n-20); color: var(--n-100); }

.btn-danger {
  background: transparent;
  color: var(--ma-red);
  border: 1px solid var(--ma-red-border);
}
.btn-danger:hover { background: var(--ma-red-light); border-color: var(--ma-red); }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; gap: 5px; }
.btn-sm svg { width: 13px; height: 13px; }

/* =============================================================================
   FORM FIELDS
   ============================================================================= */

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--n-70);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.field input, .field select, .field textarea, .input {
  background: var(--input-bg);
  border: 1px solid var(--n-30);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--n-100);
  transition: all var(--t-fast) var(--ease);
  width: 100%;
}

.field input::placeholder, .field textarea::placeholder, .input::placeholder { color: var(--n-50); font-style: italic; }
.field select:has(option[value=""]:checked) { color: var(--n-50); font-style: italic; }
.field select option { color: var(--n-100); font-style: normal; }
.field select option[value=""] { color: var(--n-50); font-style: italic; }

.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--n-100);
  outline: none;
  box-shadow: var(--s-inset);
}

.field textarea { min-height: 88px; resize: vertical; line-height: 1.55; font-family: var(--font); }

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--n-10);
  margin-bottom: 6px;
  transition: background var(--t-fast) var(--ease);
}
.member-row:hover { background: var(--n-20); }
.member-row .member-meta { flex: 1; min-width: 0; }
.member-row .member-name { font-weight: 500; font-size: 14px; color: var(--n-100); }
.member-row .member-sub { font-size: 12px; color: var(--n-60); }

.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  color: var(--n-60);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: all var(--t-fast) var(--ease);
}
.password-toggle:hover { background: var(--n-20); color: var(--n-90); }
.password-toggle svg { width: 18px; height: 18px; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.field-grid .field.full { grid-column: 1 / -1; }

.input-prefix {
  position: relative;
}
.input-prefix > span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--n-60);
  font-size: 14px;
  pointer-events: none;
  font-weight: 500;
}
.input-prefix > input { padding-left: 28px; }

/* =============================================================================
   CARDS
   ============================================================================= */

.card {
  background: var(--card-bg);
  border-radius: var(--r-md);
  padding: 22px;
  box-shadow: var(--s-1);
  max-width: 100%;
  min-width: 0;
}
@media (max-width: 600px) {
  .card { padding: 16px; }
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  min-width: 0;
}
.card-header > div:first-child { min-width: 0; flex: 1; }
.card-header > .btn { flex-shrink: 0; }

.card-title { font-size: 16px; font-weight: 600; color: var(--n-100); }
.card-subtitle { font-size: 13px; color: var(--n-70); margin-top: 2px; }

/* =============================================================================
   BADGES
   ============================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: var(--n-20);
  color: var(--n-80);
  white-space: nowrap;
  text-transform: capitalize;
}

.badge-dot { width: 6px; height: 6px; border-radius: var(--r-pill); background: currentColor; }

.filter-trigger { cursor: pointer; transition: filter var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.filter-trigger:hover { filter: brightness(0.92); transform: translateY(-0.5px); }

.badge-hot   { background: var(--ma-red-light); color: var(--ma-red); }
.badge-warm  { background: var(--warning-light); color: #B8860B; }
.badge-cold  { background: var(--info-light); color: var(--info); }
.badge-success { background: var(--success-light); color: #007F76; }
.badge-warning { background: var(--warning-light); color: #B8860B; }
.badge-error   { background: var(--ma-red-light); color: var(--ma-red); }
.badge-info    { background: var(--info-light); color: var(--info); }

.badge-live { position: relative; }
.badge-live::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: var(--r-pill);
  border: 2px solid var(--ma-red);
  opacity: 0;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.5); }
}

/* =============================================================================
   STAT CARDS
   ============================================================================= */

.dashboard-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.dashboard-search { cursor: pointer; min-width: 240px; flex: 1 1 240px; max-width: 360px; }
.dashboard-search > span { padding-left: 10px; font-size: 14px; }
.dashboard-type-toggle { margin-left: auto; }

@media (max-width: 720px) {
  .dashboard-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .dashboard-actions > [data-action="add-contact"] { grid-column: 1; }
  .dashboard-actions > [data-action="add-task"]    { grid-column: 2; }
  .dashboard-actions > .dashboard-search           { grid-column: 1 / -1; max-width: none; }
  .dashboard-actions > .dashboard-type-toggle      { grid-column: 1 / -1; margin-left: 0; }
  .dashboard-actions .btn { width: 100%; justify-content: center; padding: 14px 16px; font-size: 15px; }
  .dashboard-search { width: 100%; height: 48px; }
  .dashboard-search > span { font-size: 15px; }
  .dashboard-type-toggle button { flex: 1; padding: 10px 12px; }
}

.closed-deals-card {
  margin-bottom: 24px;
}
.closed-deals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 14px;
}
.closed-period-label { font-size: 11px; font-weight: 600; color: var(--n-60); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 4px; }
.closed-period-value { font-size: 22px; font-weight: 700; color: var(--n-100); letter-spacing: -0.02em; }
@media (max-width: 540px) {
  .closed-deals-grid { grid-template-columns: 1fr; }
  .closed-period-value { font-size: 20px; }
}

.dashboard-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .dashboard-split { grid-template-columns: 1fr; }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--s-1);
  transition: all var(--t-fast) var(--ease);
  overflow: hidden;
}

.stat-card:hover {
  box-shadow: var(--s-2);
  transform: translateY(-2px);
}

.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.stat-card-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--n-20);
  color: var(--n-80);
}
.stat-card-icon svg { width: 16px; height: 16px; }
.stat-card-icon.accent { background: var(--ma-red-light); color: var(--ma-red); }
.stat-card-icon.success { background: var(--success-light); color: #007F76; }
.stat-card-icon.warning { background: var(--warning-light); color: #B8860B; }

.stat-trend {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--n-20);
  color: var(--n-70);
}
.stat-trend.up { background: var(--success-light); color: #007F76; }
.stat-trend.down { background: var(--ma-red-light); color: var(--ma-red); }

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--n-70);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--n-100);
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.stat-sub {
  font-size: 12px;
  color: var(--n-60);
  margin-top: 5px;
}

/* =============================================================================
   SEGMENTED CONTROL
   ============================================================================= */

.segmented {
  display: inline-flex;
  background: var(--n-20);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--n-70);
  transition: all var(--t-fast) var(--ease);
}
.segmented button:hover { color: var(--n-100); }
.segmented button.active { background: var(--card-bg); color: var(--n-100); box-shadow: var(--s-1); }
.segmented svg { width: 14px; height: 14px; }

/* =============================================================================
   SEARCH BAR
   ============================================================================= */

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--n-30);
  border-radius: var(--r-pill);
  padding: 0 16px 0 14px;
  height: 40px;
  flex: 1;
  max-width: 360px;
  transition: all var(--t-fast) var(--ease);
}
.search-bar:focus-within {
  border-color: var(--n-100);
  box-shadow: var(--s-1);
}
.search-bar svg { width: 15px; height: 15px; color: var(--n-60); }
.search-bar input {
  border: none; outline: none; background: transparent;
  padding: 0 0 0 10px; flex: 1; font-size: 14px;
}

/* =============================================================================
   TABLE
   ============================================================================= */

.table-wrap {
  background: var(--card-bg);
  border-radius: var(--r-md);
  box-shadow: var(--s-1);
  overflow-x: auto;
  overflow-y: hidden;
}

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

table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--n-60);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 13px 18px;
  background: var(--n-10);
  border-bottom: 1px solid var(--n-30);
}

table.data td {
  padding: 14px 18px;
  font-size: 14px;
  color: var(--n-100);
  border-bottom: 1px solid var(--n-20);
}

table.data tr:last-child td { border-bottom: none; }

table.data tbody tr {
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
table.data tbody tr:hover { background: var(--card-hover); }

table.data .cell-name { font-weight: 600; }
table.data .cell-sub { font-size: 12px; color: var(--n-60); margin-top: 2px; }

/* =============================================================================
   KANBAN
   ============================================================================= */

.kanban {
  display: flex;
  gap: 12px;
  align-items: stretch;
  overflow: hidden;
  /* Fill available vertical space (topbar + slot padding + filter bar) */
  height: calc(100vh - var(--topbar-h) - 140px);
  min-height: 440px;
}

.kanban-col {
  flex: 1 1 0;
  min-width: 0;
  background: var(--n-20);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  transition: background var(--t-fast) var(--ease);
}

/* Mobile kanban: scroll horizontally rather than crush columns to nothing */
@media (max-width: 768px) {
  .kanban {
    overflow-x: auto;
    overflow-y: hidden;
    height: calc(100vh - var(--topbar-h) - 180px);
    min-height: 360px;
  }
  .kanban-col {
    flex: 0 0 260px;
    min-width: 260px;
  }
}

.kanban-col.drag-over { background: var(--ma-red-light); outline: 2px dashed var(--ma-red); outline-offset: -2px; }

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}

.kanban-col-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--n-90);
}

.kanban-col-dot { width: 7px; height: 7px; border-radius: var(--r-pill); }

.kanban-col-count {
  font-size: 11px;
  color: var(--n-70);
  background: var(--card-bg);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
  flex: 1 1 0;
  overflow-y: auto;
  /* Prevent inner content from forcing min size */
  min-height: 0;
}

.kanban-card {
  background: var(--card-bg);
  border-radius: var(--r-sm);
  padding: 12px 13px;
  cursor: grab;
  box-shadow: var(--s-1);
  transition: all var(--t-fast) var(--ease);
}

.kanban-card:hover {
  box-shadow: var(--s-2);
  transform: translateY(-1px);
}
.kanban-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.kanban-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.kanban-card-name { font-size: 14px; font-weight: 600; color: var(--n-100); line-height: 1.3; min-width: 0; word-wrap: break-word; }
.kanban-card-value { font-size: 13px; font-weight: 700; color: var(--n-90); font-variant-numeric: tabular-nums; }
.kanban-card-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--n-60); flex-wrap: wrap; margin-top: 6px;
}
.kanban-card-meta svg { width: 12px; height: 12px; }
.kanban-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--n-20);
}

/* =============================================================================
   MODAL
   ============================================================================= */

.modal-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px) saturate(1.2);
  -webkit-backdrop-filter: blur(4px) saturate(1.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 24px;
  animation: overlayFade var(--t-base) var(--ease);
}

@keyframes overlayFade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card-bg);
  border-radius: var(--r-lg);
  box-shadow: var(--s-4);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 360ms var(--ease-spring);
}

.modal.modal-lg { max-width: 760px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
}

.modal-title { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }

.modal-body {
  padding: 0 24px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--n-20);
  background: var(--n-10);
}

/* =============================================================================
   DRAWER (slide-in detail)
   ============================================================================= */

.drawer-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 70;
  animation: overlayFade var(--t-base) var(--ease);
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 680px;
  background: var(--card-bg);
  z-index: 71;
  display: flex;
  flex-direction: column;
  box-shadow: var(--s-4);
  animation: drawerIn 340ms var(--ease-spring);
}

@keyframes drawerIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 18px;
  gap: 16px;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 2;
}
.drawer-actions { flex-shrink: 0; }
.drawer-close-btn { background: var(--n-20); }
.drawer-close-btn:hover { background: var(--n-30); }

.drawer-title { font-size: 22px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; }
.drawer-subtitle { font-size: 13px; color: var(--n-70); margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.drawer-avatar {
  width: 52px; height: 52px;
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 18px;
  flex-shrink: 0;
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.1);
  letter-spacing: -0.02em;
}

.drawer-tabs {
  display: flex;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid var(--n-30);
}

.drawer-tab {
  padding: 12px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--n-70);
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast) var(--ease);
  margin-bottom: -1px;
}

.drawer-tab:hover { color: var(--n-100); }
.drawer-tab.active { color: var(--n-100); font-weight: 600; border-bottom-color: var(--ma-red); }

.drawer-body { flex: 1; overflow-y: auto; padding: 24px 28px 32px; }

.drawer-section { margin-bottom: 28px; }
.drawer-section h4 {
  font-size: 11px; font-weight: 600; color: var(--n-60);
  text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 4px 16px;
  font-size: 14px;
  align-items: center;
}
.detail-grid .label { color: var(--n-70); font-size: 13px; padding-left: 2px; }
.detail-grid .value { color: var(--n-100); min-height: 30px; display: flex; align-items: center; }
.detail-grid .value.muted, .detail-grid .value .muted { color: var(--n-60); font-style: italic; }

/* ----- Inline editable cells ----- */

.editable {
  position: relative;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  width: 100%;
  padding: 5px 10px;
  margin: 0 -10px;
  min-height: 30px;
}
.editable:hover:not(.editing) { background: var(--n-20); }
.editable.editing { background: var(--card-bg); cursor: default; }

.editable-display { width: 100%; }

.editable-input {
  display: none;
  width: 100%;
  border: 1.5px solid var(--ma-red);
  border-radius: var(--r-sm);
  padding: 5px 9px;
  margin: -7px -11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--n-100);
  background: var(--card-bg);
  outline: none;
  box-shadow: 0 0 0 3px var(--ma-red-glow);
  font-variant-numeric: tabular-nums;
}

textarea.editable-input { resize: vertical; min-height: 80px; line-height: 1.5; }

.editable.editing .editable-display { display: none; }
.editable.editing .editable-input { display: block; }

.editable-feedback {
  position: absolute;
  right: 8px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Saving: small spinner */
.editable.saving .editable-feedback::before {
  content: '';
  width: 13px;
  height: 13px;
  border: 2px solid var(--n-30);
  border-top-color: var(--ma-red);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

/* Saved: green pill with white check */
.editable.saved .editable-feedback::before {
  content: '✓';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  display: block;
  animation: savedPop 1500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: center;
}

@keyframes savedPop {
  0%   { opacity: 0; transform: scale(0.2); }
  25%  { opacity: 1; transform: scale(1.12); }
  40%  { transform: scale(1); }
  80%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.92); }
}

/* ----- FILES TAB ----- */

.files-drop {
  border: 2px dashed var(--n-30);
  border-radius: var(--r-md);
  padding: 28px 20px;
  text-align: center;
  background: var(--n-10);
  transition: all var(--t-fast) var(--ease);
  cursor: pointer;
  margin-bottom: 18px;
}
.files-drop:hover, .files-drop.drag-active {
  border-color: var(--ma-red);
  background: var(--ma-red-light);
}
.files-drop svg { width: 24px; height: 24px; color: var(--n-60); margin-bottom: 8px; }
.files-drop.drag-active svg { color: var(--ma-red); }
.files-drop-title { font-size: 14px; font-weight: 600; color: var(--n-90); }
.files-drop-sub { font-size: 13px; color: var(--n-70); margin-top: 4px; }
.files-drop-pick { color: var(--ma-red); font-weight: 600; cursor: pointer; }
.files-drop-pick:hover { text-decoration: underline; }

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.file-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--s-1);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  display: flex;
  flex-direction: column;
}
.file-card:hover { box-shadow: var(--s-2); transform: translateY(-1px); }

.file-card-thumb {
  height: 110px;
  background: var(--n-20);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.file-thumb-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.file-thumb-icon { width: 36px; height: 36px; color: var(--n-60); }

.file-card-meta {
  padding: 10px 12px;
  flex: 1;
}
.file-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--n-100);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-sub {
  font-size: 11px;
  color: var(--n-60);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card-delete {
  position: absolute;
  top: 6px; right: 6px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
  cursor: pointer;
}
.file-card:hover .file-card-delete { opacity: 1; }
.file-card-delete:hover { background: var(--ma-red); }
.file-card-delete svg { width: 13px; height: 13px; }

.file-card.uploading .file-card-thumb { background: var(--n-20); }
.file-card.uploading .file-card-thumb .spinner { margin: 0; }

/* Notes textarea variant */
.editable.editable-multiline {
  margin: 0;
  padding: 10px 12px;
  background: var(--n-10);
  border-radius: var(--r-sm);
  min-height: 60px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.editable.editable-multiline:hover:not(.editing) { background: var(--n-20); }
.editable.editable-multiline.editing { padding: 0; background: transparent; }
.editable.editable-multiline .editable-input { margin: 0; }

/* =============================================================================
   NOTES / ACTIVITY
   ============================================================================= */

.notes-list { display: flex; flex-direction: column; gap: 10px; }

.note-item {
  position: relative;
  background: var(--n-10);
  border-radius: var(--r-sm);
  padding: 12px 14px 14px;
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--n-60);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}

.note-author { font-weight: 700; color: var(--n-90); text-transform: none; letter-spacing: 0; }
.note-body { font-size: 14px; line-height: 1.55; color: var(--n-100); white-space: pre-wrap; }

.note-compose { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.note-compose textarea {
  border: 1px solid var(--n-30);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 72px;
  background: var(--card-bg);
  transition: all var(--t-fast) var(--ease);
}
.note-compose textarea:focus { border-color: var(--n-100); outline: none; box-shadow: var(--s-inset); }
.note-compose-actions { display: flex; justify-content: flex-end; }

/* =============================================================================
   TASK LIST
   ============================================================================= */

.task-bucket { margin-bottom: 24px; }

.task-bucket h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--n-80);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 10px;
}

.task-bucket-count {
  font-size: 11px; background: var(--n-20); color: var(--n-70);
  padding: 2px 8px; border-radius: var(--r-pill); font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.task-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  box-shadow: var(--s-1);
  transition: all var(--t-fast) var(--ease);
  cursor: pointer;
}

.task-item:hover { box-shadow: var(--s-2); transform: translateX(2px); }
.task-item.done { opacity: 0.55; }
.task-item.done .task-title { text-decoration: line-through; color: var(--n-70); }
.task-item.overdue { box-shadow: var(--s-1), inset 3px 0 0 var(--ma-red); }

.task-checkbox {
  width: 20px; height: 20px;
  border: 2px solid var(--n-40);
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-bounce);
  flex-shrink: 0;
  background: var(--card-bg);
}

.task-checkbox:hover { border-color: var(--ma-red); transform: scale(1.08); }
.task-checkbox.checked { background: var(--ma-red); border-color: var(--ma-red); color: white; }
.task-checkbox.checked svg { width: 11px; height: 11px; }
.task-checkbox svg { display: none; }
.task-checkbox.checked svg { display: block; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; color: var(--n-100); }
.task-meta { display: flex; gap: 10px; font-size: 12px; color: var(--n-60); margin-top: 2px; }

/* New task list item layout: prospect-prominent */
.task-prospect { font-size: 15px; font-weight: 600; color: var(--n-100); line-height: 1.25; letter-spacing: -0.01em; }
.task-zip { font-size: 12px; font-weight: 500; color: var(--n-60); margin-left: 6px; letter-spacing: 0; }
.task-line { display: flex; align-items: center; gap: 10px; margin-top: 3px; font-size: 13px; color: var(--n-70); flex-wrap: wrap; }
.task-title-sub { color: var(--n-80); }
.task-due { color: var(--n-60); font-variant-numeric: tabular-nums; margin-left: auto; font-size: 12px; }
.task-item.done .task-prospect { text-decoration: line-through; color: var(--n-70); }

/* =============================================================================
   ACTIVITY FEED
   ============================================================================= */

.activity-feed { display: flex; flex-direction: column; gap: 4px; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 8px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease);
  cursor: pointer;
  align-items: center;
  min-width: 0;
}
.activity-item:hover { background: var(--n-10); }

@media (max-width: 600px) {
  .activity-item { gap: 10px; padding: 10px 6px; }
  .activity-item > .text-xs.text-muted { display: none; }
  .activity-item .badge { font-size: 10px; padding: 2px 7px; flex-shrink: 0; }
  .activity-item .activity-avatar { width: 30px; height: 30px; font-size: 11px; }
}

.activity-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 14px; color: var(--n-100); font-weight: 500; }
.activity-title strong { font-weight: 600; }
.activity-meta {
  display: flex; gap: 8px; font-size: 12px; color: var(--n-60); margin-top: 2px;
  align-items: center;
}

/* =============================================================================
   TOAST
   ============================================================================= */

.toast-root {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--n-100);
  color: white;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--s-3);
  pointer-events: auto;
  animation: toastIn 280ms var(--ease-spring);
  max-width: 360px;
}

.toast.toast-error { background: var(--ma-red); }
.toast.toast-success { background: #00574F; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* =============================================================================
   EMPTY STATES
   ============================================================================= */

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--n-70);
}

.empty img.mascot { width: 96px; height: auto; margin-bottom: 16px; opacity: 0.96; }
.empty h3 { font-size: 18px; color: var(--n-90); margin-bottom: 4px; }
.empty p { font-size: 14px; max-width: 380px; margin: 0 auto 18px; color: var(--n-70); }

/* =============================================================================
   COMMAND PALETTE
   ============================================================================= */

.cmdk-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px) saturate(1.2);
  -webkit-backdrop-filter: blur(6px) saturate(1.2);
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 96px;
  animation: overlayFade var(--t-base) var(--ease);
}

.cmdk {
  width: 560px; max-width: calc(100% - 32px);
  background: var(--card-bg);
  border-radius: var(--r-md);
  box-shadow: var(--s-4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  animation: modalIn 320ms var(--ease-spring);
}

.cmdk-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--n-30);
}
.cmdk-input-wrap svg { width: 18px; height: 18px; color: var(--n-60); }
.cmdk-input {
  flex: 1;
  border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--n-100);
}

.cmdk-list { overflow-y: auto; padding: 6px; }

.cmdk-section-title {
  font-size: 11px; font-weight: 600; color: var(--n-60);
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 12px 12px 6px;
}

.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
}
.cmdk-item:hover, .cmdk-item.active { background: var(--n-20); }
.cmdk-item-icon {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: var(--n-20);
  display: flex; align-items: center; justify-content: center;
  color: var(--n-70); flex-shrink: 0;
}
.cmdk-item.active .cmdk-item-icon { background: var(--ma-red-light); color: var(--ma-red); }
.cmdk-item-icon svg { width: 14px; height: 14px; }
.cmdk-item-body { flex: 1; min-width: 0; }
.cmdk-item-title { font-weight: 500; color: var(--n-100); }
.cmdk-item-sub { font-size: 12px; color: var(--n-60); }

.cmdk-empty { padding: 32px; text-align: center; color: var(--n-60); font-size: 14px; }

.cmdk-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--n-30);
  font-size: 11px; color: var(--n-60);
  background: var(--n-10);
}
.cmdk-foot kbd {
  font-family: var(--font);
  background: var(--card-bg);
  border: 1px solid var(--n-30);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin: 0 3px;
}

/* =============================================================================
   SKELETON
   ============================================================================= */

.skeleton {
  background: linear-gradient(90deg, var(--n-20) 0%, var(--n-30) 50%, var(--n-20) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skel-stat-card { height: 112px; border-radius: var(--r-md); }
.skel-row { height: 56px; margin-bottom: 1px; }
.skel-text { height: 12px; border-radius: 4px; }

/* =============================================================================
   MISC UTILITIES
   ============================================================================= */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-muted { color: var(--n-70); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.w-full { width: 100%; }

.admin-only { display: none; }
body.is-admin .admin-only { display: flex; }

.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 48px; color: var(--n-60); font-size: 14px;
}

.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--n-30);
  border-top-color: var(--ma-red);
  animation: spin 800ms linear infinite;
  margin-right: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform var(--t-base) var(--ease);
    z-index: 90;
    box-shadow: var(--s-3);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-menu { display: flex; }
  .view-slot { padding: 18px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search-bar { max-width: none; }
  .field-grid { grid-template-columns: 1fr; }
  .drawer { max-width: 100%; }
}

/* Compact cmdk trigger on small screens — just an icon */
@media (max-width: 720px) {
  .cmdk-trigger > span { display: none; }
  .cmdk-trigger kbd     { display: none; }
  .cmdk-trigger { padding: 7px 9px; }
}

@media (max-width: 540px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 24px; }
  .cmdk-trigger kbd { display: none; }
}

/* Stack the drawer detail-grid into one column on small phones */
@media (max-width: 600px) {
  .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-grid .label {
    font-weight: 600; font-size: 10.5px; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--n-60); margin-top: 8px;
  }
  .detail-grid .value { min-height: 28px; margin-bottom: 4px; }
  .editable { padding: 6px 10px; }
  .drawer-header { padding: 18px 20px 14px; }
  .drawer-body   { padding: 18px 20px 28px; }
  .drawer-title  { font-size: 18px; }
  .drawer-tabs   { padding: 0 20px; gap: 16px; overflow-x: auto; }
}

/* iOS momentum scrolling for any overflow region */
.table-wrap, .kanban, .drawer-body, .view-slot { -webkit-overflow-scrolling: touch; }
