/* ─────────────────────────────────────────────
   PRDRWNDN CRM — Design System

   Palette drawn from the Rwandan flag itself rather than a generic
   admin-dashboard blue: deep sky blue field, sun yellow, and the
   green of the land, set against a warm off-black so the accent
   colors carry weight instead of competing with pure white/black.

   Display face: a confident geometric sans for headers (Space Grotesk)
   paired with a clean workhorse sans for body/data (Inter) — distinct
   roles, not the same family doing both jobs.
───────────────────────────────────────────── */

:root {
  --ink: #15171c;
  --ink-soft: #4a4f5a;
  --paper: #faf9f6;
  --paper-raised: #ffffff;
  --line: #e4e2dc;

  --rw-blue: #00A1DE;
  --rw-yellow: #FAD201;
  --rw-green: #20603D;

  --blue-deep: #045a87;
  --green-deep: #143d27;

  --won: #20603D;
  --lost: #9a3b3b;
  --warn: #b8860b;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(21,23,28,0.06), 0 4px 16px rgba(21,23,28,0.04);

  --font-display: 'Space Grotesk', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
  color: var(--ink);
}

a { color: var(--blue-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout shell ── */
.app-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 36px;
  color: #fff;
}

.sidebar .brand .flag-mark {
  width: 22px;
  height: 16px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--rw-blue) 0%, var(--rw-blue) 50%, var(--rw-yellow) 50%, var(--rw-yellow) 78%, var(--rw-green) 78%);
  flex-shrink: 0;
}

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

.sidebar nav a {
  color: rgba(255,255,255,0.65);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--rw-blue); color: #fff; }

.sidebar .user-box {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
}

.sidebar .user-box form { margin-top: 8px; }
.sidebar .user-box button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-body);
}
.sidebar .user-box button:hover { color: #fff; text-decoration: underline; }

.main {
  padding: 32px 40px 60px;
  max-width: 1200px;
}

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

.page-header .eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rw-green);
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
}

.page-header h1 { font-size: 1.6rem; margin: 0; }
.page-header .sub { color: var(--ink-soft); font-size: 0.9rem; margin-top: 4px; }

/* ── Cards / panels ── */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.stat-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-card .label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 6px;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
}

.stat-card .value.accent-blue { color: var(--blue-deep); }
.stat-card .value.accent-green { color: var(--green-deep); }
.stat-card .value.accent-yellow { color: #8a6d00; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--rw-blue); color: #fff; }
.btn-primary:hover { background: var(--blue-deep); }

.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f3f2ee; }

.btn-danger { background: #fff; color: var(--lost); border-color: #e8c8c8; }
.btn-danger:hover { background: #fdf2f2; }

.btn-sm { padding: 5px 11px; font-size: 0.8rem; }

/* ── Forms ── */
label { font-size: 0.83rem; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--rw-blue);
  outline-offset: 1px;
  border-color: var(--rw-blue);
}

.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 0.88rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable-row:hover { background: #f6f5f1; cursor: pointer; }

/* ── Badges (lead stages, order status) ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-new { background: #e8eef5; color: var(--blue-deep); }
.badge-contacted { background: #fdf3d6; color: #8a6d00; }
.badge-negotiating { background: #fde8d6; color: #a05a00; }
.badge-won { background: #e1ede4; color: var(--won); }
.badge-lost { background: #f3e0e0; color: var(--lost); }
.badge-status-completed { background: #e1ede4; color: var(--won); }
.badge-status-processing { background: #e8eef5; color: var(--blue-deep); }
.badge-status-pending { background: #fdf3d6; color: #8a6d00; }
.badge-status-cancelled,
.badge-status-failed,
.badge-status-refunded { background: #f3e0e0; color: var(--lost); }
.badge-status-on-hold { background: #f0ecf5; color: #5a3d8a; }

/* ── Pipeline board ── */
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-top: 8px;
}
.pipeline-col { background: #f3f2ee; border-radius: var(--radius); padding: 12px; min-height: 200px; }
.pipeline-col h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
}
.pipeline-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}
.pipeline-card .name { font-weight: 600; margin-bottom: 2px; }
.pipeline-card .meta { color: var(--ink-soft); font-size: 0.78rem; }

/* ── Misc ── */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-soft);
}
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }

.flash {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.88rem;
  font-weight: 500;
}
.flash-success { background: #e1ede4; color: var(--won); border: 1px solid #c3dac9; }
.flash-error { background: #f3e0e0; color: var(--lost); border: 1px solid #e3bcbc; }
.flash-info { background: #e8eef5; color: var(--blue-deep); border: 1px solid #c5d9ec; }

.tag-pill {
  display: inline-block;
  background: var(--rw-yellow);
  color: #5a4700;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  margin: 2px 3px 2px 0;
}

.activity-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-item .activity-meta { color: var(--ink-soft); font-size: 0.78rem; margin-top: 2px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
