/* ============================================================
   Desert Sky Digital — CRM Design Tokens
   Palette: dusk navy header, sand background, clay + horizon-gold accents
   Type: Fraunces (display) / Inter (body) / IBM Plex Mono (data/labels)
   Signature: horizon-gradient bar in the nav — dusk navy fading to
   horizon gold, echoing a desert skyline at dusk.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --dusk: #1B2430;
  --dusk-soft: #2A3646;
  --sand: #F4EFE4;
  --sand-card: #FFFFFF;
  --clay: #C1652F;
  --horizon-gold: #E8A33D;
  --ink: #2C2F33;
  --stone: #8A8578;
  --line: #E4DDCB;
  --danger: #B3453A;

  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--sand);
  color: var(--ink);
  min-height: 100vh;
}

/* --- Signature horizon bar --- */
.horizon-bar {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--dusk) 0%, var(--clay) 55%, var(--horizon-gold) 100%);
}

/* --- App shell --- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--dusk);
  color: var(--sand);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  padding: 22px 20px 18px;
  letter-spacing: 0.01em;
}

.sidebar-brand span { color: var(--horizon-gold); }

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
}

.sidebar nav a {
  color: var(--sand);
  opacity: 0.75;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 500;
}

.sidebar nav a:hover { opacity: 1; background: var(--dusk-soft); }
.sidebar nav a.active { opacity: 1; background: var(--dusk-soft); color: var(--horizon-gold); }

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--dusk-soft);
}

.sidebar-footer button {
  background: none;
  border: none;
  color: var(--sand);
  opacity: 0.6;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}
.sidebar-footer button:hover { opacity: 1; }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1100px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  margin: 0;
}

/* --- Buttons --- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: 6px;
  padding: 9px 16px;
  border: none;
  cursor: pointer;
}

.btn-primary { background: var(--clay); color: #fff; }
.btn-primary:hover { background: #A9541F; }

.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--sand-card); }

.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: #FBEAE8; }
.row-actions { display: flex; gap: 6px; }

/* --- Toolbar / search --- */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.toolbar input[type="search"] {
  flex: 1;
  max-width: 320px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--sand-card);
}

/* --- Table / list --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--sand-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.data-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--stone);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr.row-link { cursor: pointer; }
.data-table tr.row-link:hover { background: #FAF7EF; }

.cell-name { font-weight: 600; }
.cell-muted { color: var(--stone); font-size: 0.85rem; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--stone);
  font-size: 0.92rem;
}

/* --- Status badges --- */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 20px;
}
.badge-lead { background: #EFE3F4; color: #6B3F8C; }
.badge-active { background: #E1F0E5; color: #2C7A43; }
.badge-completed { background: #E4E7EC; color: #4A5568; }
.badge-archived { background: #F1EAE0; color: var(--stone); }
.badge-call, .badge-email, .badge-meeting { background: #E8EEF4; color: #2E5B7C; }
.badge-contract { background: #EFE3F4; color: #6B3F8C; }
.badge-invoice { background: #E1F0E5; color: #2C7A43; }
.badge-other { background: #F1EAE0; color: var(--stone); }
.badge-paid { background: #E1F0E5; color: #2C7A43; }
.badge-sent { background: #E8EEF4; color: #2E5B7C; }
.badge-overdue { background: #FBEAE8; color: var(--danger); }
.badge-draft { background: #F1EAE0; color: var(--stone); }

/* --- Task rows --- */
.task-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.task-row .task-actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.task-row:last-child { border-bottom: none; }
.task-row input[type="checkbox"] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--clay); cursor: pointer; }
.task-row .task-title { font-weight: 600; font-size: 0.92rem; }
.task-row.is-complete .task-title { text-decoration: line-through; color: var(--stone); }
.task-row .task-meta { font-size: 0.8rem; color: var(--stone); margin-top: 2px; }

/* --- Contract file box --- */
.file-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--sand-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  max-width: 520px;
}
.file-box .file-name { font-size: 0.9rem; font-weight: 500; }
.file-input-hidden { display: none; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 36, 48, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--sand-card);
  border-radius: 10px;
  padding: 28px;
  width: 420px;
  max-width: 90vw;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 18px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--stone);
}
.field input, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.field input:focus, .field textarea:focus, .toolbar input:focus {
  outline: 2px solid var(--horizon-gold);
  outline-offset: 1px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* --- Login page --- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dusk);
}

.login-card {
  background: var(--sand-card);
  border-radius: 12px;
  padding: 36px 34px;
  width: 360px;
  max-width: 90vw;
}

.login-card h1, .login-card .subtitle {
  text-align: center;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.login-logo {
  display: block;
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
}

.login-card .subtitle {
  color: var(--stone);
  font-size: 0.88rem;
  margin: 0 0 22px;
}

.login-error {
  background: #FBEAE8;
  color: var(--danger);
  font-size: 0.85rem;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  display: none;
}

.login-error.visible { display: block; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; }
  .sidebar nav { flex-direction: row; }
  .sidebar-footer { margin-top: 0; border-top: none; padding: 0 16px; }
  .main { padding: 20px; }
}

/* --- Sidebar global search --- */
.sidebar-search { padding: 0 12px 10px; position: relative; }
.sidebar-search input[type="search"] {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--dusk-soft);
  background: var(--dusk-soft);
  color: var(--sand);
  font-size: 0.82rem;
  font-family: var(--font-body);
}
.sidebar-search input::placeholder { color: rgba(244,239,228,0.5); }
.sidebar-search input:focus { outline: 1px solid var(--horizon-gold); }
.search-results {
  position: absolute;
  top: 100%; left: 12px; right: 12px;
  background: var(--sand-card);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 100;
  display: none;
}
.search-results.visible { display: block; }
.search-result-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 0.85rem; }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--sand); }
.search-result-type {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--stone);
  display: block;
  margin-top: 2px;
}
.search-empty { padding: 12px; font-size: 0.82rem; color: var(--stone); }

/* --- Overdue tasks --- */
.task-row.is-overdue .task-title { color: var(--danger); }
.task-row.is-overdue .task-meta { color: var(--danger); opacity: 0.85; }
.overdue-flag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--danger);
  margin-left: 6px;
}

/* --- Pipeline summary (dashboard) --- */
.pipeline-list { display: flex; flex-direction: column; gap: 10px; max-width: 520px; margin-bottom: 36px; }
.pipeline-row { display: flex; align-items: center; gap: 12px; }
.pipeline-label { width: 90px; font-size: 0.82rem; text-transform: capitalize; color: var(--stone); flex-shrink: 0; }
.pipeline-bar-track { flex: 1; background: var(--line); border-radius: 6px; height: 10px; overflow: hidden; }
.pipeline-bar-fill { height: 100%; background: var(--clay); border-radius: 6px; }
.pipeline-value { width: 90px; text-align: right; font-family: var(--font-mono); font-size: 0.8rem; flex-shrink: 0; }

/* --- Activity feed --- */
.activity-row { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 0.88rem; align-items: baseline; }
.activity-row:last-child { border-bottom: none; }
.activity-time { font-family: var(--font-mono); font-size: 0.75rem; color: var(--stone); white-space: nowrap; }
.activity-action-created { color: #2C7A43; font-weight: 600; }
.activity-action-deleted { color: var(--danger); font-weight: 600; }
