/* ============================================================
   LINEA GROUP CRM — Linea Dark Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Mona+Sans:ital,wght@0,200..900;1,200..900&family=Montserrat:ital,wght@0,100..900;1,100..900&family=DM+Mono:wght@300;400;500&display=swap');

:root {
  /* Surfaces */
  --bg: #0a0a0a;
  --surface: #141414;
  --raised: #1a1a1a;
  --hover: #1f1f1f;
  --divider: #262626;
  --divider-strong: #333333;

  /* Text */
  --text: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-dim: #646464;

  /* Accent */
  --accent: #22c55e;
  --accent-dim: #166534;
  --accent-bg: rgba(34, 197, 94, 0.1);

  /* Status */
  --red: #ef4444;
  --orange: #f97316;
  --blue: #3b82f6;
  --yellow: #eab308;
  --purple: #a855f7;

  /* Temperature */
  --temp-cold: #6b7280;
  --temp-warm: #3b82f6;
  --temp-hot: #f97316;
  --temp-engaged: #22c55e;

  /* Type */
  --font-display: "Mona Sans", "Mona Sans Narrow", system-ui, sans-serif;
  --font-body: "Montserrat", system-ui, sans-serif;
  --font-mono: "DM Mono", "JetBrains Mono", monospace;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 52px;
}

/* ============================================================
   LIGHT THEME — toggled via [data-theme="light"] on <html>
   ============================================================ */
html[data-theme="light"] {
  --bg: #fafaf9;
  --surface: #ffffff;
  --raised: #f4f4f3;
  --hover: #ececea;
  --divider: #e5e5e3;
  --divider-strong: #d4d4d2;

  --text: #0a0a0a;
  --text-secondary: #525252;
  --text-dim: #8a8a87;

  --accent: #16a34a;
  --accent-dim: #15803d;
  --accent-bg: rgba(22, 163, 74, 0.08);
}
html[data-theme="light"] .btn-primary { color: #ffffff; }
html[data-theme="light"] .workspace-mark { background: var(--accent); color: #ffffff; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d4d4d2; border-color: var(--bg); }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #b8b8b5; }

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 400;
  letter-spacing: -0.005em;
  overflow: hidden;
  height: 100vh;
}

#root {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

input, textarea, select {
  font-family: inherit;
  background: none;
  border: none;
  color: inherit;
  outline: none;
}

a { color: inherit; text-decoration: none; }

/* ============================================================
   TYPOGRAPHY HELPERS
   ============================================================ */

.display {
  font-family: var(--font-display);
  font-stretch: 75%; /* Narrow */
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}

.kpi-num {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ============================================================
   SCROLLBARS
   ============================================================ */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

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

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

.topbar {
  grid-area: topbar;
  background: var(--bg);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}

.main {
  grid-area: main;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.workspace {
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-mark {
  width: 24px;
  height: 24px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-weight: 900;
  color: #0a0a0a;
  font-size: 14px;
}

.workspace-name {
  font-family: var(--font-display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.01em;
  flex: 1;
}

.workspace-chev {
  color: var(--text-dim);
}

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

.nav-section-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 14px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  user-select: none;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--raised);
  color: var(--text);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--accent);
}

.nav-item .nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.nav-item.active .nav-count {
  color: var(--accent);
}

.nav-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--divider);
  padding: 10px 8px;
}

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar-search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--divider);
  padding: 6px 12px;
  cursor: text;
  user-select: none;
}

.topbar-search:hover { border-color: var(--divider-strong); }

.topbar-search-text { color: var(--text-dim); flex: 1; font-size: 12px; }

.topbar-search-kbd {
  display: flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--raised);
  border: 1px solid var(--divider);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

.topbar-spacer { flex: 1; }

.topbar-icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  position: relative;
}
.topbar-icon-btn:hover { background: var(--surface); color: var(--text); }

.topbar-bell-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border: 1.5px solid var(--bg);
  border-radius: 50%;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--raised);
  border: 1px solid var(--divider);
  font-family: var(--font-display);
  font-stretch: 75%;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 72px; height: 72px; font-size: 22px; }

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-header-left { min-width: 0; }

.page-eyebrow {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.page-title {
  font-family: var(--font-display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 6px;
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  border: 1px solid var(--divider);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  white-space: nowrap;
}

.btn:hover { background: var(--raised); border-color: var(--divider-strong); }

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
  border-color: var(--accent);
}
.btn-primary:hover { background: #16a34a; border-color: #16a34a; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: transparent; }

.btn-icon {
  padding: 6px;
  width: 30px;
  height: 30px;
  justify-content: center;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

/* ============================================================
   CHIPS
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--raised);
  color: var(--text-secondary);
  border: 1px solid var(--divider);
  white-space: nowrap;
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================================
   CARD
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--divider);
}

.card-raised { background: var(--raised); }

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin: 0;
}

.card-body { padding: 16px; }

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

.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: 2px; } .gap-4 { gap: 4px; } .gap-6 { gap: 6px; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.flex-1 { flex: 1; min-width: 0; }
.text-secondary { color: var(--text-secondary); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-red { color: var(--red); }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none; }

/* ============================================================
   STATUS DOTS
   ============================================================ */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.dot-green { background: var(--accent); box-shadow: 0 0 0 2px rgba(34,197,94,0.15); }
.dot-red { background: var(--red); box-shadow: 0 0 0 2px rgba(239,68,68,0.15); }
.dot-orange { background: var(--orange); box-shadow: 0 0 0 2px rgba(249,115,22,0.15); }
.dot-blue { background: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.dot-gray { background: var(--text-dim); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 0 2px rgba(234,179,8,0.15); }

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

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  background: var(--surface);
  border-left: 1px solid var(--divider);
  z-index: 91;
  display: flex;
  flex-direction: column;
  animation: drawerSlide 0.18s ease-out;
}

@keyframes drawerSlide {
  from { transform: translateX(20px); opacity: 0.7; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */

.input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--divider);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-body);
}

.input:focus { border-color: var(--accent); }

.textarea {
  width: 100%;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--divider);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-body);
  resize: vertical;
  min-height: 80px;
}

/* ============================================================
   SELECTABLE ROWS / LIST
   ============================================================ */

.list-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}
.list-row:hover { background: var(--surface); }
.list-row.active { background: var(--raised); }
.list-row.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
}

/* ============================================================
   TABS
   ============================================================ */

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

.tab {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .tab-count {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* ============================================================
   GRID
   ============================================================ */

.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.fade-in { animation: fadeIn 0.15s ease-out; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* ============================================================
   TOASTS / NOTICES
   ============================================================ */

.notice {
  padding: 10px 14px;
  background: var(--raised);
  border: 1px solid var(--divider);
  border-left: 2px solid var(--accent);
  font-size: 12px;
  color: var(--text-secondary);
}
