/* ============================================================
   Lative CRM — Design System
   Linear-inspired dark canvas. All colors via CSS variables.
   ============================================================ */

/* --- Google Fonts (dev). For offline production, download
       Inter to static/fonts/inter/ and add @font-face rules. --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Canvas & surfaces — light theme */
  --canvas:            #FFFFFF;
  --surface-1:         #F5F6F8;
  --surface-2:         #EDEEF2;
  --surface-3:         #E3E5EA;
  --surface-4:         #D8DAE1;

  /* Borders */
  --hairline:          #E2E4EA;
  --hairline-strong:   #CBCED6;
  --hairline-tertiary: #ECEDF0;

  /* Text */
  --ink:               #111314;
  --ink-muted:         #343840;
  --ink-subtle:        #5A5F6B;
  --ink-tertiary:      #8B909C;

  /* Brand accent — logo cyan */
  --primary:           #00AEEF;
  --primary-hover:     #0099D6;
  --primary-focus:     #007AB8;

  /* Semantic */
  --success:           #1a8f3c;
  --error:             #d93025;   /* input errors ONLY */

  /* Sidebar — white panel, cyan text */
  --sidebar-bg:          #FFFFFF;
  --sidebar-border:      #E2E4EA;
  --sidebar-ink:         #00AEEF;
  --sidebar-ink-active:  #0086C4;
  --sidebar-hover-bg:    rgba(0, 174, 239, 0.08);
  --sidebar-active-bg:   rgba(0, 174, 239, 0.12);
  --sidebar-section-ink: #8B909C;
  --sidebar-indicator:   #00AEEF;

  /* Radius */
  --r-chip:   4px;
  --r-tag:    6px;
  --r-btn:    8px;
  --r-card:   12px;
  --r-panel:  16px;
  --r-banner: 24px;
  --r-pill:   9999px;

  /* Spacing */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-12: 48px;
  --sp-24: 96px;
}

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

html { height: 100%; }

body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

img, svg { display: block; }

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ── Layout Utilities ───────────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.flex-1        { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.justify-start   { justify-content: flex-start; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }
.space-y-1 > * + * { margin-top: 4px; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-4 > * + * { margin-top: 16px; }
.space-y-6 > * + * { margin-top: 24px; }
.space-x-2 > * + * { margin-left: 8px; }
.space-x-3 > * + * { margin-left: 12px; }
.space-x-4 > * + * { margin-left: 16px; }
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.col-span-2  { grid-column: span 2; }

/* ── Sizing ─────────────────────────────────────────────────── */
.w-full    { width: 100%; }
.w-64      { width: 240px; }
.w-4       { width: 16px; }
.w-5       { width: 20px; }
.w-6       { width: 24px; }
.w-7       { width: 28px; }
.w-8       { width: 32px; }
.w-10      { width: 40px; }
.h-4       { height: 16px; }
.h-5       { height: 20px; }
.h-6       { height: 24px; }
.h-7       { height: 28px; }
.h-8       { height: 32px; }
.h-10      { height: 40px; }
.h-14      { height: 56px; }
.h-full    { height: 100%; }
.h-screen  { height: 100vh; }
.min-h-screen { min-height: 100vh; }
.max-w-xs  { max-width: 320px; }
.max-w-sm  { max-width: 384px; }
.max-w-md  { max-width: 448px; }
.max-w-lg  { max-width: 512px; }
.max-w-xl  { max-width: 576px; }
.max-w-2xl { max-width: 672px; }
.max-w-4xl { max-width: 896px; }
.max-w-7xl { max-width: 1280px; }
.mx-auto   { margin-left: auto; margin-right: auto; }
.ml-auto   { margin-left: auto; }
.mr-auto   { margin-right: auto; }

/* ── Position ───────────────────────────────────────────────── */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }
.top-0    { top: 0; }
.left-0   { left: 0; }
.right-0  { right: 0; }
.bottom-0 { bottom: 0; }
.inset-0  { top: 0; right: 0; bottom: 0; left: 0; }
.z-10     { z-index: 10; }
.z-20     { z-index: 20; }
.z-50     { z-index: 50; }

/* ── Overflow ───────────────────────────────────────────────── */
.overflow-hidden  { overflow: hidden; }
.overflow-auto    { overflow: auto; }
.overflow-y-auto  { overflow-y: auto; }
.overflow-x-auto  { overflow-x: auto; }

/* ── Spacing ────────────────────────────────────────────────── */
.p-0  { padding: 0; }
.p-1  { padding: 4px; }
.p-2  { padding: 8px; }
.p-3  { padding: 12px; }
.p-4  { padding: 16px; }
.p-5  { padding: 20px; }
.p-6  { padding: 24px; }
.p-8  { padding: 32px; }
.p-12 { padding: 48px; }
.px-2 { padding-left: 8px;  padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.px-6 { padding-left: 24px; padding-right: 24px; }
.py-1 { padding-top: 4px;  padding-bottom: 4px; }
.py-2 { padding-top: 8px;  padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-6 { padding-top: 24px; padding-bottom: 24px; }
.py-8 { padding-top: 32px; padding-bottom: 32px; }
.pt-0 { padding-top: 0; }
.pt-2 { padding-top: 8px; }
.pt-4 { padding-top: 16px; }
.pt-6 { padding-top: 24px; }
.pb-2 { padding-bottom: 8px; }
.pb-4 { padding-bottom: 16px; }
.pb-6 { padding-bottom: 24px; }
.pl-2 { padding-left: 8px; }
.pl-3 { padding-left: 12px; }
.pl-4 { padding-left: 16px; }
.pr-2 { padding-right: 8px; }
.pr-3 { padding-right: 12px; }
.pr-4 { padding-right: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.ml-4 { margin-left: 16px; }
.mr-2 { margin-right: 8px; }
.mr-3 { margin-right: 12px; }

/* ── Typography ─────────────────────────────────────────────── */
.text-xs   { font-size: 12px; line-height: 1.4; }
.text-sm   { font-size: 13px; line-height: 1.5; }
.text-base { font-size: 14px; line-height: 1.5; }
.text-md   { font-size: 16px; line-height: 1.5; }
.text-lg   { font-size: 18px; line-height: 1.5; }
.text-xl   { font-size: 20px; line-height: 1.4; letter-spacing: -0.2px; }
.text-2xl  { font-size: 22px; line-height: 1.25; letter-spacing: -0.4px; }
.text-3xl  { font-size: 28px; line-height: 1.2;  letter-spacing: -0.6px; }
.text-4xl  { font-size: 40px; line-height: 1.15; letter-spacing: -1.0px; }
.text-5xl  { font-size: 56px; line-height: 1.1;  letter-spacing: -1.8px; }
.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.font-mono     { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.tracking-tight  { letter-spacing: -0.025em; }
.tracking-normal { letter-spacing: 0; }
.tracking-wide   { letter-spacing: 0.025em; }
.tracking-wider  { letter-spacing: 0.05em; }  /* eyebrow +0.4px equivalent */
.uppercase    { text-transform: uppercase; }
.capitalize   { text-transform: capitalize; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.text-left    { text-align: left; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.leading-tight  { line-height: 1.25; }
.leading-snug   { line-height: 1.375; }
.leading-normal { line-height: 1.5; }

/* Semantic text token classes */
.text-ink         { color: var(--ink); }
.text-ink-muted   { color: var(--ink-muted); }
.text-ink-subtle  { color: var(--ink-subtle); }
.text-ink-tertiary{ color: var(--ink-tertiary); }
.text-primary     { color: var(--primary); }
.text-success     { color: var(--success); }
.text-error       { color: var(--error); }
.text-white       { color: #ffffff; }

/* ── Backgrounds ────────────────────────────────────────────── */
.bg-canvas  { background-color: var(--canvas); }
.bg-s1      { background-color: var(--surface-1); }
.bg-s2      { background-color: var(--surface-2); }
.bg-s3      { background-color: var(--surface-3); }
.bg-s4      { background-color: var(--surface-4); }
.bg-primary { background-color: var(--primary); }
.bg-success { background-color: var(--success); }

/* ── Borders ────────────────────────────────────────────────── */
.border   { border: 1px solid var(--hairline); }
.border-0 { border: none; }
.border-t { border-top: 1px solid var(--hairline); }
.border-b { border-bottom: 1px solid var(--hairline); }
.border-l { border-left: 1px solid var(--hairline); }
.border-r { border-right: 1px solid var(--hairline); }
.border-2-primary-l { border-left: 2px solid var(--primary); }
.border-error { border-color: var(--error) !important; }
.divide-y > * + * { border-top: 1px solid var(--hairline); }

/* ── Border Radius ──────────────────────────────────────────── */
.rounded      { border-radius: var(--r-chip); }
.rounded-sm   { border-radius: var(--r-tag); }
.rounded-md   { border-radius: var(--r-btn); }
.rounded-lg   { border-radius: var(--r-card); }
.rounded-xl   { border-radius: var(--r-panel); }
.rounded-2xl  { border-radius: var(--r-banner); }
.rounded-full { border-radius: var(--r-pill); }

/* ── Display helpers ────────────────────────────────────────── */
.hidden        { display: none; }
.block         { display: block; }
.inline-block  { display: inline-block; }
.inline-flex   { display: inline-flex; }

/* ── Interactions ───────────────────────────────────────────── */
.cursor-pointer    { cursor: pointer; }
.cursor-not-allowed{ cursor: not-allowed; }
.select-none       { user-select: none; }
.pointer-events-none { pointer-events: none; }
.transition        { transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, opacity 150ms ease; }
.opacity-50 { opacity: 0.5; }

/* ── Hover utilities ────────────────────────────────────────── */
.hover-bg-s1:hover { background-color: var(--surface-1); }
.hover-bg-s2:hover { background-color: var(--surface-2); }
.hover-text-ink:hover { color: var(--ink); }

/* ── Focus ──────────────────────────────────────────────────── */
.focus-ring:focus {
  outline: 2px solid var(--primary-focus);
  outline-offset: 0;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-btn);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:focus-visible {
  outline: 2px solid var(--primary-focus);
  outline-offset: 2px;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}
.btn-primary:active {
  background-color: var(--primary-focus);
}

.btn-secondary {
  background-color: var(--surface-1);
  color: var(--ink);
  border-color: var(--hairline);
}
.btn-secondary:hover {
  background-color: var(--surface-2);
  border-color: var(--hairline-strong);
  color: var(--ink);
}

.btn-tertiary {
  background-color: transparent;
  color: var(--ink-subtle);
  border-color: transparent;
}
.btn-tertiary:hover {
  background-color: var(--surface-1);
  color: var(--ink);
}

.btn-danger {
  background-color: transparent;
  color: var(--error);
  border-color: var(--error);
}
.btn-danger:hover {
  background-color: rgba(255, 92, 92, 0.1);
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background-color: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: var(--sp-6);
}
/* Top border accent for cards */
.card::before {
  content: '';
  display: block;
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.06), transparent);
  border-radius: var(--r-card) var(--r-card) 0 0;
  pointer-events: none;
}
.card { position: relative; }

.card-featured {
  background-color: var(--surface-2);
  border-color: var(--hairline-strong);
}

.data-panel {
  background-color: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-panel);
  padding: var(--sp-6);
  position: relative;
}

/* ── Form Inputs ────────────────────────────────────────────── */
.input {
  background-color: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-btn);
  color: var(--ink);
  padding: 7px 11px;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color 150ms ease;
  appearance: none;
}
.input::placeholder { color: var(--ink-tertiary); }
.input:hover  { border-color: var(--hairline-strong); }
.input:focus  {
  outline: none;
  border-color: var(--primary-focus);
  box-shadow: 0 0 0 2px rgba(0, 122, 184, 0.20);
}
.input.error  { border-color: var(--error); }
select.input  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238a8f98' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; padding-right: 32px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-subtle);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-group { margin-bottom: 16px; }

.form-error {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
}

.form-hint {
  font-size: 12px;
  color: var(--ink-tertiary);
  margin-top: 4px;
}

/* ── Status Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 500;
  background-color: var(--surface-2);
  color: var(--ink-muted);
  border: 1px solid var(--hairline);
  white-space: nowrap;
}
.badge-success {
  background-color: rgba(39, 166, 68, 0.12);
  color: var(--success);
  border-color: rgba(39, 166, 68, 0.25);
}
.badge-primary {
  background-color: rgba(0, 174, 239, 0.12);
  color: #0079a8;
  border-color: rgba(0, 174, 239, 0.30);
}
.badge-warning {
  background-color: rgba(180, 100, 0, 0.10);
  color: #8a4f00;
  border-color: rgba(180, 100, 0, 0.25);
}
.badge-error {
  background-color: rgba(255, 92, 92, 0.12);
  color: var(--error);
  border-color: rgba(255, 92, 92, 0.25);
}

/* ── Sidebar Navigation ─────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-ink-active);
  letter-spacing: -0.2px;
}

.sidebar-brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary);
  margin-right: 8px;
  flex-shrink: 0;
}

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

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-section-ink);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-tag);
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-ink);
  text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease;
  position: relative;
}
.nav-item:hover {
  color: var(--sidebar-ink-active);
  background-color: var(--sidebar-hover-bg);
}
.nav-item.active {
  color: var(--sidebar-ink-active);
  background-color: var(--sidebar-active-bg);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  background-color: var(--sidebar-indicator);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { color: inherit; flex-shrink: 0; }

/* Avatar uses cyan on the white sidebar */
.sidebar .user-avatar {
  background-color: var(--primary);
  color: #ffffff;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--hairline);
  background-color: var(--canvas);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.1px;
}

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

/* User avatar pill */
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Data Table ─────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--hairline);
  background-color: var(--canvas);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 12px;
  color: var(--ink);
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.data-table tbody tr { background-color: var(--canvas); transition: background-color 100ms ease; }
.data-table tbody tr:hover { background-color: var(--surface-1); }
.data-table .td-muted { color: var(--ink-muted); }
.data-table .td-subtle { color: var(--ink-subtle); }

/* ── Kanban Board ───────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.kanban-col {
  min-width: 260px;
  max-width: 300px;
  flex-shrink: 0;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  margin-bottom: 8px;
}
.kanban-col-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kanban-col-count {
  font-size: 11px;
  color: var(--ink-tertiary);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: var(--r-pill);
}
.kanban-card {
  background-color: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.kanban-card:hover {
  border-color: var(--hairline-strong);
  background-color: var(--surface-2);
}
.kanban-card-title { font-size: 13px; font-weight: 500; color: var(--ink); }
.kanban-card-meta  { font-size: 11px; color: var(--ink-subtle); margin-top: 6px; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 8px; bottom: 0;
  width: 1px;
  background: var(--hairline);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--ink-subtle);
  border: 1px solid var(--canvas);
}
.timeline-dot.active { background-color: var(--primary); }
.timeline-date { font-size: 11px; color: var(--ink-tertiary); margin-bottom: 3px; }
.timeline-content { font-size: 13px; color: var(--ink); }
.timeline-meta    { font-size: 11px; color: var(--ink-subtle); margin-top: 2px; }

/* ── Alert / Messages ───────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--r-btn);
  font-size: 13px;
  border: 1px solid;
  margin-bottom: 12px;
}
.alert-success { background-color: rgba(39,166,68,.1); color: var(--success); border-color: rgba(39,166,68,.25); }
.alert-error   { background-color: rgba(255,92,92,.1); color: var(--error); border-color: rgba(255,92,92,.25); }
.alert-info    { background-color: rgba(0,174,239,.10); color: #0079a8; border-color: rgba(0,174,239,.25); }

/* ── Page shell ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Dropdown menu ──────────────────────────────────────────── */
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background-color: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-card);
  padding: 4px;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--ink-muted);
  border-radius: var(--r-tag);
  cursor: pointer;
  text-decoration: none;
  transition: color 100ms ease, background-color 100ms ease;
}
.dropdown-item:hover {
  background-color: var(--surface-3);
  color: var(--ink);
}
.dropdown-divider {
  height: 1px;
  background: var(--hairline);
  margin: 4px 0;
}

/* ── HTMX loading indicator ─────────────────────────────────── */
#htmx-indicator {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
  z-index: 9999;
  opacity: 0;
  transition: opacity 200ms ease;
}
#htmx-indicator.htmx-request { opacity: 1; }

/* ── Misc helpers ───────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Tab navigation ─────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 24px;
}
.tab-item {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-subtle);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
.tab-item:hover { color: var(--ink); }
.tab-item.active {
  color: var(--ink);
  border-bottom-color: var(--primary);
}

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .input {
  font-size: 13px;
  padding: 6px 10px;
}
.filter-bar .input-search {
  min-width: 200px;
  flex: 1;
}

/* ── Page header row ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header-title { font-size: 28px; font-weight: 600; color: var(--ink); }
.page-header-meta  { font-size: 13px; color: var(--ink-subtle); margin-top: 2px; }

/* ── Detail hero ────────────────────────────────────────────── */
.detail-hero {
  background-color: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-panel);
  padding: 24px 28px;
  margin-bottom: 24px;
}
.detail-hero-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin-bottom: 6px;
}
.detail-hero-title {
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
}

/* ── Two-column form layout ─────────────────────────────────── */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
.form-grid-2 .form-group-full { grid-column: 1 / -1; }

/* ── Importer stage badge (applied via model property) ──────── */
.badge-error {
  background-color: rgba(255, 92, 92, 0.12);
  color: var(--error);
  border-color: rgba(255, 92, 92, 0.25);
}

/* ── Contact card ───────────────────────────────────────────── */
.contact-card {
  background-color: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.contact-card + .contact-card { margin-top: 8px; }
.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  background-color: var(--surface-3);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-size: 14px; font-weight: 500; color: var(--ink); }
.contact-meta { font-size: 12px; color: var(--ink-subtle); margin-top: 2px; }
.contact-actions { display: flex; gap: 6px; align-items: center; }

/* ── Form section header ────────────────────────────────────── */
.form-section-header {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-subtle);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 16px;
  margin-top: 24px;
}
.form-section-header:first-child { margin-top: 0; }

/* ── Info list (key-value pairs in detail views) ────────────── */
.info-list { display: flex; flex-direction: column; gap: 10px; }
.info-row  { display: flex; gap: 12px; font-size: 13px; }
.info-label { width: 160px; flex-shrink: 0; color: var(--ink-subtle); font-weight: 500; }
.info-value { color: var(--ink); flex: 1; }

/* ── Stub tab content ───────────────────────────────────────── */
.tab-stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  color: var(--ink-subtle);
  text-align: center;
  border: 1px dashed var(--hairline);
  border-radius: var(--r-card);
}
.tab-stub-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }
.tab-stub-label { font-size: 14px; font-weight: 500; color: var(--ink-subtle); }
.tab-stub-hint { font-size: 13px; color: var(--ink-tertiary); margin-top: 4px; }

/* ── Detail grid (two-column detail layout) ─────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

/* ── Kanban board ────────────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}
.kanban-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}
.kanban-col-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
}
.kanban-cards { display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  text-decoration: none;
  color: inherit;
  transition: background 120ms ease;
}
.kanban-card:hover { background: var(--surface-2); }
.kanban-card-ref  { font-size: 10px; color: var(--ink-tertiary); font-family: monospace; }
.kanban-card-title { font-size: 13px; font-weight: 500; color: var(--ink); line-height: 1.4; }
.kanban-card-meta  { font-size: 11px; color: var(--ink-subtle); }
.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}
.kanban-empty {
  padding: 20px 12px;
  font-size: 12px;
  color: var(--ink-tertiary);
  text-align: center;
  border: 1px dashed var(--hairline);
  border-radius: var(--r-card);
}

/* ── Communication timeline ──────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 20px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--hairline);
}
.timeline-item {
  position: relative;
  padding-bottom: 20px;
}
.timeline-dot {
  position: absolute;
  left: -17px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-subtle);
  border: 1px solid var(--surface-3);
  flex-shrink: 0;
}
.timeline-dot.badge-primary  { background: var(--primary); }
.timeline-dot.badge-success  { background: var(--success); }
.timeline-dot.badge-warning  { background: #e5a827; }
.timeline-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.timeline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.timeline-body {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.6;
}
.timeline-next-action {
  font-size: 12px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 6px;
}
.timeline-footer {
  font-size: 11px;
  color: var(--ink-tertiary);
  padding-top: 4px;
  border-top: 1px solid var(--hairline-tertiary);
}

/* ── File attachment cards ───────────────────────────────────── */
.file-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
}
.file-card-icon { font-size: 20px; flex-shrink: 0; }
.file-card-body { flex: 1; min-width: 0; }
.file-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-delete {
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 120ms;
}
.file-card:hover .file-card-delete { opacity: 1; }

/* ── Utility buttons ─────────────────────────────────────────── */
.btn-ghost {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 120ms, color 120ms;
  text-decoration: none;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-ghost.text-error { color: var(--error); }
.btn-ghost.text-error:hover { background: rgba(255,92,92,.08); }
.btn-xs { font-size: 11px; padding: 2px 6px; }
.btn-sm { font-size: 12px; padding: 5px 12px; }

/* ── Link utility ────────────────────────────────────────────── */
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ── Back link ───────────────────────────────────────────────── */
.back-link {
  font-size: 12px;
  color: var(--ink-subtle);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 120ms;
}
.back-link:hover { color: var(--ink); }

/* ── Alert / error banner ────────────────────────────────────── */
.alert-error {
  padding: 10px 14px;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: rgba(255,92,92,.06);
  font-size: 13px;
  color: var(--error);
  margin-bottom: 12px;
}

/* ── Data table ──────────────────────────────────────────────── */
.data-table { border-collapse: collapse; width: 100%; }
.data-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}
.data-table td {
  font-size: 13px;
  color: var(--ink-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline-tertiary);
  vertical-align: middle;
}
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table td.text-right { text-align: right; }

/* ── Grid span ───────────────────────────────────────────────── */
.col-span-2 { grid-column: span 2; }

/* ── Due-date urgency ────────────────────────────────────────── */
.due-date          { font-size: 13px; color: var(--ink-muted); }
.due-overdue       { color: var(--error); font-weight: 500; }
.due-warning       { color: #e5a827; font-weight: 500; }

/* ── Badge size variant ──────────────────────────────────────── */
.badge-sm { font-size: 10px; padding: 1px 6px; }

/* ── Grid utilities ──────────────────────────────────────────── */
.grid           { display: grid; }
.grid-cols-3    { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4    { grid-template-columns: repeat(4, 1fr); }
.col-span-2     { grid-column: span 2; }
.gap-4          { gap: 16px; }
.mb-4           { margin-bottom: 16px; }
.mb-6           { margin-bottom: 24px; }
.ml-1           { margin-left: 4px; }
.mt-1           { margin-top: 4px; }
.mt-2           { margin-top: 8px; }
.mt-3           { margin-top: 12px; }
.mt-4           { margin-top: 16px; }
.mt-6           { margin-top: 24px; }
.pt-4           { padding-top: 16px; }
.px-6           { padding-left: 24px; padding-right: 24px; }
.py-4           { padding-top: 16px; padding-bottom: 16px; }
.w-full         { width: 100%; }
.flex-1         { flex: 1 1 0%; }
.flex-wrap      { flex-wrap: wrap; }
.flex-shrink-0  { flex-shrink: 0; }
.min-width-0    { min-width: 0; }
.items-start    { align-items: flex-start; }
.items-end      { align-items: flex-end; }
.items-center   { align-items: center; }
.justify-center { justify-content: center; }
.justify-between{ justify-content: space-between; }
.text-right     { text-align: right; }
.text-center    { text-align: center; }
.overflow-hidden{ overflow: hidden; }
.font-medium    { font-weight: 500; }
.font-semibold  { font-weight: 600; }
.text-sm        { font-size: 13px; }
.text-xs        { font-size: 11px; }
.text-3xl       { font-size: 28px; line-height: 1.2; }
.text-muted     { color: var(--ink-muted); }
.text-subtle    { color: var(--ink-subtle); }
.text-error     { color: var(--error); }
.text-ink       { color: var(--ink); }
.text-ink-subtle{ color: var(--ink-subtle); }
.text-ink-tertiary { color: var(--ink-tertiary); }
.text-primary   { color: var(--primary); }
.tracking-wider { letter-spacing: 0.06em; }
.uppercase      { text-transform: uppercase; }
.border-b       { border-bottom: 1px solid var(--hairline); }
.max-height-360 { max-height: 360px; }
.overflow-x-auto{ overflow-x: auto; }
.overflow-y-auto{ overflow-y: auto; }
.gap-2          { gap: 8px; }
.gap-3          { gap: 12px; }
.flex-direction-column { flex-direction: column; }

/* ── Hamburger button (hidden on desktop) ─────────────────────────────── */
.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  padding: 6px;
  border-radius: 6px;
  margin-right: 4px;
  flex-shrink: 0;
}
.topbar-hamburger:hover { background: var(--surface-2); }

/* Sidebar overlay (mobile only) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
}
.sidebar-overlay.active { display: block; }

/* ── Mobile — everything below 768px ─────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar becomes a fixed slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    height: 100vh;
    z-index: 200;
    transition: left 0.22s ease;
    width: 240px;
    display: flex;
  }
  .sidebar.mobile-open { left: 0; }

  /* App shell fills full width */
  .app-shell { flex-direction: row; }
  .app-main  { width: 100%; min-width: 0; }

  /* Show hamburger, tighten topbar padding */
  .topbar { padding: 0 12px; }
  .topbar-hamburger { display: flex; align-items: center; justify-content: center; }

  /* Forms — single column */
  .form-grid-2 { grid-template-columns: 1fr; }

  /* Tables — scroll inside their container, never the page */
  .data-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 560px; }

  /* Kanban — horizontal scroll with fixed-width columns */
  .kanban-board {
    display: flex;
    flex-direction: row;
    gap: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    grid-template-columns: unset;
  }
  .kanban-col { min-width: 220px; flex-shrink: 0; }

  /* Page header — stack, let buttons wrap */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Filter bar — wrap inputs */
  .filter-bar { flex-wrap: wrap; }
  .filter-bar .input-search { min-width: 0; flex: 1 1 160px; }

  /* Tab bar — scroll, never wrap */
  .tab-bar { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab-item { white-space: nowrap; }

  /* Detail grids — single column */
  .detail-grid { grid-template-columns: 1fr !important; }

  /* Importer / tender detail hero */
  .detail-hero { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* Overview 2×2 grid → single column */
  .overview-grid { grid-template-columns: 1fr !important; }

  /* Communications 2-col layout → single column */
  .comms-grid { grid-template-columns: 1fr !important; }

  /* Requirement card grid → single column */
  .req-card-grid { grid-template-columns: 1fr !important; }

  /* Notepad widget — full width at bottom on mobile */
  .notepad { right: 0; left: 0; width: 100%; border-radius: 10px 10px 0 0; }

  /* Button groups — wrap */
  .btn-group { flex-wrap: wrap; }

  /* Cards — reduce padding on mobile */
  .card { padding: 16px; }

  /* Hide sidebar footer sign-out text on very small screens */
  .app-content { padding: 16px; }
}

/* ── Personal Notes Widget ────────────────────────────────────────────── */
.notepad {
  position: fixed;
  bottom: 0;
  right: 28px;
  width: 300px;
  z-index: 900;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -4px 32px rgba(0,0,0,.45);
}
.notepad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  border-radius: 10px 10px 0 0;
}
.notepad-header:hover { background: var(--surface-3); }
.notepad-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
}
.notepad-header-icon {
  width: 16px;
  height: 16px;
  color: var(--primary);
}
.notepad-toggle {
  font-size: 10px;
  color: var(--ink-tertiary);
  transition: transform .2s;
}
.notepad--open .notepad-toggle { transform: rotate(180deg); }
.notepad-body {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--hairline);
}
.notepad--open .notepad-body { display: flex; }
.notepad-body textarea {
  width: 100%;
  height: 220px;
  background: var(--surface-1);
  border: none;
  color: var(--ink);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  font-family: inherit;
  outline: none;
  display: block;
}
.notepad-body textarea::placeholder { color: var(--ink-tertiary); }
.notepad-body textarea:focus { background: var(--surface-2); }
.notepad-footer {
  padding: 6px 14px 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 28px;
  border-top: 1px solid var(--hairline-tertiary);
}
