/* ========================================================================
   THOR CRM — Design System
   Cohérent avec thor-technologie.com (navy #0b3d91 + copper #c0703c)
   ======================================================================== */

:root {
  --navy: #0b3d91;
  --navy-deep: #061f4a;
  --navy-light: #1e5fc9;
  --copper: #c0703c;
  --copper-light: #d99965;
  --copper-deep: #8a4a1f;
  --ivory: #faf7f2;
  --ink: #0a0e1a;
  --paper: #ffffff;
  --rule: #e8e2d6;
  --rule-soft: #f0ebe1;
  --muted: #6b6558;
  --muted-light: #9b9588;
  --green: #2d6a4f;
  --green-light: #d4ead9;
  --warn: #d9534f;
  --warn-light: #fbe4e3;
  --amber: #c08a3e;
  --amber-light: #f7ecd6;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --sidebar-w: 240px;
  --header-h: 64px;
  --radius: 4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--ivory);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--copper-deep); }

/* ============ AUTH LAYOUT (centered) ============ */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 800px) { .auth-shell { grid-template-columns: 1fr; } }

.auth-aside {
  background: var(--ink);
  color: var(--ivory);
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-aside::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(192,112,60,0.2) 0%, transparent 70%);
  filter: blur(40px);
}
.auth-aside::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(11,61,145,0.3) 0%, transparent 70%);
  filter: blur(50px);
}
.auth-aside > * { position: relative; z-index: 1; }

.auth-brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth-brand span { color: var(--copper-light); }

.auth-headline {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 3.5vw, 3rem);
  line-height: 1.05;
  font-weight: 300;
  letter-spacing: -0.025em;
  font-variation-settings: 'opsz' 144;
  max-width: 460px;
}
.auth-headline em { font-style: italic; color: var(--copper-light); }

.auth-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: rgba(250, 247, 242, 0.5);
  letter-spacing: 0.1em;
}

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  background: var(--paper);
}
.auth-form {
  width: 100%;
  max-width: 380px;
}
.auth-form h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  font-variation-settings: 'opsz' 96;
}
.auth-form h1 em { font-style: italic; color: var(--copper); font-weight: 300; }
.auth-form .lead { color: var(--muted); margin-bottom: 32px; }
.auth-form .error {
  background: var(--warn-light);
  color: var(--warn);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 16px;
  border-left: 3px solid var(--warn);
  display: none;
}
.auth-form .error.visible { display: block; }

/* ============ APP LAYOUT (sidebar + main) ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: var(--ivory);
  padding: 28px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 0 24px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 20px;
}
.sidebar-brand a {
  font-family: var(--font-display);
  color: var(--ivory);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sidebar-brand a span { color: var(--copper-light); }
.sidebar-brand .tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted-light);
  margin-top: 4px;
  letter-spacing: 0.12em;
}

.sidebar-section {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: rgba(250,247,242,0.4);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0 24px;
  margin: 16px 0 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: rgba(250,247,242,0.75);
  font-size: 0.92rem;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}
.sidebar-link:hover { color: var(--ivory); background: rgba(255,255,255,0.03); }
.sidebar-link.active {
  color: var(--copper-light);
  border-left-color: var(--copper);
  background: rgba(192,112,60,0.06);
}
.sidebar-link-icon {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  width: 16px;
  text-align: center;
  opacity: 0.7;
}

.sidebar-footer {
  margin-top: auto;
  padding: 20px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.85rem;
}
.sidebar-user {
  font-weight: 500;
  margin-bottom: 4px;
}
.sidebar-role {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--copper-light);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}
.sidebar-logout {
  color: rgba(250,247,242,0.5);
  font-size: 0.85rem;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
  padding: 0;
}
.sidebar-logout:hover { color: var(--copper-light); }

/* Main content */
.main {
  background: var(--ivory);
  min-height: 100vh;
}
.topbar {
  height: var(--header-h);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}
.topbar-title em { font-style: italic; color: var(--copper); font-weight: 300; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 32px; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: -100%; width: 80%; transition: left 0.3s; z-index: 100; }
  .sidebar.open { left: 0; }
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--navy); color: var(--paper); }
.btn-primary:hover { background: var(--navy-deep); color: var(--paper); }
.btn-copper { background: var(--copper); color: var(--paper); }
.btn-copper:hover { background: var(--copper-deep); color: var(--paper); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: var(--warn); color: var(--paper); }
.btn-danger:hover { background: #b8413d; color: var(--paper); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; padding: 14px; }
.btn-icon { padding: 8px; }

/* ============ FORMS ============ */
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 0.94rem;
  color: var(--ink);
  border-radius: var(--radius);
  transition: border 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11,61,145,0.08);
}
textarea { resize: vertical; min-height: 90px; font-family: var(--font-body); }

/* ============ CARDS & PANELS ============ */
.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.panel-body { padding: 24px; }
.panel-body.flush { padding: 0; }

/* Stat cards (dashboard) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--paper);
  padding: 22px 24px;
  position: relative;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 24px;
  width: 32px; height: 2px;
  background: var(--copper);
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
  margin-top: 8px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 96;
  line-height: 1;
}
.stat-value em { color: var(--copper); font-style: italic; font-weight: 300; }
.stat-trend {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
}
.stat-trend.positive { color: var(--green); }
.stat-trend.negative { color: var(--warn); }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
  text-align: left;
  padding: 13px 16px;
  white-space: nowrap;
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9rem;
}
tbody tr:hover { background: var(--rule-soft); }
tbody tr:last-child td { border-bottom: none; }

.cell-primary {
  font-weight: 500;
  font-family: var(--font-display);
  font-size: 1rem;
}
.cell-muted { color: var(--muted); font-size: 0.85rem; }
.cell-mono { font-family: var(--font-mono); font-size: 0.85rem; }

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  white-space: nowrap;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-red { background: var(--warn-light); color: var(--warn); }
.badge-navy { background: rgba(11,61,145,0.1); color: var(--navy); }
.badge-copper { background: rgba(192,112,60,0.15); color: var(--copper-deep); }
.badge-muted { background: var(--rule-soft); color: var(--muted); }

/* ============ EMPTY STATES ============ */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 2.5rem; opacity: 0.4; margin-bottom: 12px; }
.empty-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--ink);
  margin-bottom: 6px;
}

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 14, 26, 0.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--paper);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-header {
  padding: 22px 28px;
  border-bottom: 1px solid var(--rule);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 500; letter-spacing: -0.015em; }
.modal-close {
  background: none; border: none;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 28px; }
.modal-footer {
  padding: 18px 28px;
  border-top: 1px solid var(--rule);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ============ TOAST ============ */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--ink);
  color: var(--ivory);
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  max-width: 380px;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,0.3);
  border-left: 3px solid var(--copper);
  animation: slideIn 0.3s ease-out;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--warn); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ KANBAN ============ */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
.kanban-col {
  background: var(--rule-soft);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 200px;
}
.kanban-col-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.kanban-col-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
}
.kanban-col-count {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--navy);
  background: var(--paper);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.kanban-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  cursor: grab;
  transition: all 0.15s;
  border-left: 3px solid var(--copper);
}
.kanban-card:hover {
  box-shadow: 0 4px 12px -4px rgba(11,61,145,0.15);
  transform: translateY(-1px);
}
.kanban-card.dragging { opacity: 0.5; cursor: grabbing; }
.kanban-card-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.98rem;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.kanban-card-company { color: var(--muted); font-size: 0.82rem; margin-bottom: 8px; }
.kanban-card-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.kanban-card-value {
  font-family: var(--font-display);
  color: var(--copper-deep);
  font-weight: 500;
  font-size: 0.9rem;
}

/* ============ TIMELINE (activities) ============ */
.timeline { padding-left: 20px; border-left: 2px solid var(--rule); }
.timeline-item { padding-bottom: 24px; position: relative; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -27px;
  top: 6px;
  width: 12px; height: 12px;
  background: var(--copper);
  border-radius: 50%;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 2px var(--rule);
}
.timeline-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.timeline-content {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* ============ UTILS ============ */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; } .mb-32 { margin-bottom: 32px; }
.text-muted { color: var(--muted); }
.text-mono { font-family: var(--font-mono); }
.text-display { font-family: var(--font-display); }
.text-sm { font-size: 0.85rem; }
.text-lg { font-size: 1.1rem; }
.text-right { text-align: right; }
.w-full { width: 100%; }

.fcfa::after {
  content: ' FCFA';
  font-family: var(--font-mono);
  font-size: 0.78em;
  color: var(--muted);
  font-weight: 400;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
