:root {
  --bg: #080B0D;
  --bg-elevated: #0D1114;
  --bg-card: #12171B;
  --bg-card-hover: #171D22;
  --bg-input: #0A0E11;
  --border: rgba(226, 240, 238, 0.08);
  --border-strong: rgba(226, 240, 238, 0.16);

  --accent: #2DD4BF;
  --accent-strong: #5EEAD4;
  --accent-dim: #0D9488;
  --accent-glow: rgba(45, 212, 191, 0.18);
  --on-accent: #072320;

  --text: #EAF4F2;
  --text-muted: #8FA3A0;
  --text-faint: #59706C;

  --blue: #7FB3E8;
  --amber: #F2C94C;
  --orange: #F2994A;
  --red: #EB5757;
  --green: #4ADE80;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 180ms;

  color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(900px circle at 12% -15%, rgba(45, 212, 191, 0.14), transparent 60%),
    radial-gradient(700px circle at 105% 0%, rgba(45, 212, 191, 0.08), transparent 55%),
    linear-gradient(180deg, #0a0d0e 0%, #080a0b 45%, #050607 100%);
  background-attachment: fixed;
}

a { color: inherit; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ---------- Layout ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: radial-gradient(320px circle at 0% 0%, rgba(45, 212, 191, 0.08), transparent 60%), var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-4);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-6); }
.brand-logo { width: 38px; height: 38px; flex-shrink: 0; }
.brand-logo svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; overflow-x: hidden; }

.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; min-height: 44px; padding: var(--space-2) var(--space-3);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 14px; text-align: left; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  position: relative;
}
.nav-item:hover {
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.10), rgba(255,255,255,0.03));
  color: var(--text);
  transform: translateX(3px);
}
.nav-item:hover .nav-icon { color: var(--accent-strong); transform: scale(1.08); }
.nav-icon { width: 19px; height: 19px; flex-shrink: 0; transition: color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.nav-item span:nth-of-type(1) { flex: 1; }

.nav-item.active { background: linear-gradient(90deg, var(--accent-glow), transparent); border-color: var(--border); color: var(--accent-strong); }
.nav-item.active::before {
  content: ''; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px;
  background: var(--accent); box-shadow: 0 0 12px var(--accent-glow);
}

.nav-badge {
  font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border-strong); color: var(--text-muted);
  display: none; align-items: center; justify-content: center;
}
.nav-badge.show { display: inline-flex; }

.nav-divider { height: 1px; background: var(--border); margin: var(--space-3) var(--space-2); }
.nav-secondary { flex: 0 0 auto; overflow: visible; }

.sidebar-footer { padding-top: var(--space-4); }

.user-card { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-glow); color: var(--accent-strong);
  font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden; text-transform: uppercase;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; font-weight: 600; }

.main { flex: 1; min-width: 0; padding: var(--space-6) var(--space-8) var(--space-8); }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--space-6); gap: var(--space-4); flex-wrap: wrap; }
.topbar h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.view-sub { margin: 0; color: var(--text-muted); font-size: 14px; }
.topbar-date { color: var(--text-faint); font-size: 13px; padding-top: 6px; text-transform: capitalize; }

.view { display: none; }
.view.active { display: block; animation: fade-in var(--dur) var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Sections / cards ---------- */

.section-block { margin-bottom: var(--space-8); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); gap: var(--space-3); flex-wrap: wrap; }
.section-head h2 { font-size: 17px; margin: 0; font-weight: 700; }
.section-head .hint { font-size: 13px; color: var(--text-muted); }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); }

.grid { display: grid; gap: var(--space-4); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-kanban { grid-template-columns: repeat(4, 1fr); align-items: start; }

.hero-card {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); border: 1px solid var(--border-strong); padding: var(--space-6);
  background: radial-gradient(480px circle at 8% 15%, rgba(94, 234, 212, 0.18), transparent 65%), linear-gradient(115deg, #10201d 0%, #0c1213 45%, #030404 100%);
}
.hero-card::after { content: ''; position: absolute; inset: 0; background: radial-gradient(360px circle at 90% 110%, rgba(45, 212, 191, 0.12), transparent 70%); pointer-events: none; }
.hero-card > * { position: relative; z-index: 1; }

.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); position: relative; overflow: hidden; }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--space-3); }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.stat-value { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: var(--space-3); }
.stat-value small { font-size: 16px; color: var(--text-muted); font-weight: 600; }

.pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { color: var(--green); background: rgba(74, 222, 128, 0.12); }
.pill-amber { color: var(--amber); background: rgba(242, 201, 76, 0.12); }
.pill-red { color: var(--red); background: rgba(235, 87, 87, 0.12); }
.pill-blue { color: var(--blue); background: rgba(127, 179, 232, 0.12); }
.pill-accent { color: var(--accent-strong); background: var(--accent-glow); }
.pill-muted { color: var(--text-muted); background: rgba(255,255,255,0.05); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-card); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--bg-card-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 0 24px var(--accent-glow); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(235, 87, 87, 0.1); border-color: rgba(235, 87, 87, 0.3); }
.btn-icon { width: 40px; height: 40px; padding: 0; flex-shrink: 0; }
.btn-sm { min-height: 32px; height: 32px; padding: 0 var(--space-3); font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Forms ---------- */

.field { margin-bottom: var(--space-4); }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: var(--space-2); }
.field input[type="text"], .field input[type="url"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="date"], .field textarea, .field select {
  width: 100%; min-height: 44px; padding: var(--space-3); background: var(--bg-input); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); transition: border-color var(--dur) var(--ease);
}
.field textarea { min-height: 90px; resize: vertical; font-family: inherit; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent-dim); outline: none; }
.field-row { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 140px; }

.priority-picker { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.priority-opt {
  flex: 1; min-width: 90px; min-height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-input); color: var(--text-muted); font-weight: 600; font-size: 13px; cursor: pointer; transition: all var(--dur) var(--ease);
}
.priority-opt.selected { color: var(--on-accent); border-color: transparent; }
.priority-opt[data-p="low"].selected { background: var(--blue); }
.priority-opt[data-p="medium"].selected { background: var(--amber); }
.priority-opt[data-p="high"].selected { background: var(--orange); }
.priority-opt[data-p="urgent"].selected { background: var(--red); }

.color-input-row { display: flex; align-items: center; gap: var(--space-3); }
.color-input-row input[type="color"] { width: 44px; height: 44px; padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: transparent; cursor: pointer; }
.color-input-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-input-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-swatch-value { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--text-muted); }

/* ---------- List items ---------- */

.item-list { display: flex; flex-direction: column; gap: var(--space-3); }
.item-row {
  display: flex; align-items: flex-start; gap: var(--space-3); background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong); border-radius: var(--radius); padding: var(--space-4);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.item-row:hover { background: var(--bg-card-hover); }
.item-row.prio-low { border-left-color: var(--blue); }
.item-row.prio-medium { border-left-color: var(--amber); }
.item-row.prio-high { border-left-color: var(--orange); }
.item-row.prio-urgent { border-left-color: var(--red); }
.item-row.done { opacity: 0.55; }
.item-row.done .item-title { text-decoration: line-through; }

.item-check {
  width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: transparent;
  flex-shrink: 0; margin-top: 2px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--on-accent); transition: all var(--dur) var(--ease);
}
.item-check svg { width: 14px; height: 14px; opacity: 0; transition: opacity var(--dur) var(--ease); }
.item-check.checked { background: var(--accent); border-color: var(--accent); }
.item-check.checked svg { opacity: 1; }

.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 14.5px; margin-bottom: 2px; word-break: break-word; }
.item-desc { font-size: 13px; color: var(--text-muted); word-break: break-word; white-space: pre-wrap; }
.item-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.item-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }
.item-actions { display: flex; gap: 4px; flex-shrink: 0; }

.empty-state { text-align: center; padding: var(--space-8) var(--space-4); color: var(--text-faint); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-state svg { width: 32px; height: 32px; margin-bottom: var(--space-3); opacity: 0.6; }
.empty-state p { margin: 0; font-size: 14px; }

.chip-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip {
  min-height: 32px; padding: 0 var(--space-3); border-radius: 999px; border: 1px solid var(--border-strong);
  background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--dur) var(--ease);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Client / Project cards ---------- */

.client-card, .invoice-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.client-card-top, .invoice-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.client-name { font-weight: 700; font-size: 15.5px; }
.client-contact { font-size: 13px; color: var(--text-muted); }
.client-notes { font-size: 13px; color: var(--text-muted); white-space: pre-wrap; }
.client-card-footer { display: flex; justify-content: flex-end; gap: 4px; margin-top: auto; }

.kanban-col-head { font-size: 12.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: var(--space-3); font-weight: 700; }
.project-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); margin-bottom: var(--space-3); }
.project-card h3 { font-size: 14.5px; margin: 0 0 4px; }
.project-client { font-size: 12.5px; color: var(--accent-strong); margin-bottom: 6px; }
.project-meta { font-size: 12px; color: var(--text-faint); margin-top: var(--space-2); }
.project-links { display: flex; gap: 6px; margin-top: var(--space-3); flex-wrap: wrap; }
.project-actions { display: flex; gap: 4px; margin-top: var(--space-3); justify-content: flex-end; }

.invoice-total { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 18px; color: var(--accent-strong); }
.invoice-items-table { width: 100%; border-collapse: collapse; margin: var(--space-3) 0; font-size: 13.5px; }
.invoice-items-table th { text-align: left; color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.invoice-items-table td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.invoice-items-table td.num { text-align: right; font-family: 'JetBrains Mono', monospace; }
.item-line-row { display: flex; gap: var(--space-2); margin-bottom: var(--space-2); align-items: center; }
.item-line-row input { flex: 1; }
.item-line-row input.qty, .item-line-row input.price { flex: 0 0 90px; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(4, 6, 6, 0.65); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: var(--space-4); z-index: 100;
}
.modal-overlay.open { display: flex; animation: fade-in var(--dur) var(--ease); }
.modal {
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: var(--space-6);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal h3 { margin: 0 0 var(--space-4); font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-5); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--bg-elevated);
  border: 1px solid var(--border-strong); color: var(--text); padding: var(--space-3) var(--space-5); border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,0.4); opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Auth screens ---------- */

.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); }
.auth-card { width: 100%; max-width: 380px; text-align: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-8) var(--space-6); }
.auth-logo { margin-bottom: var(--space-4); }
.auth-logo svg { width: 64px; height: 64px; }
.auth-title { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.auth-sub { margin: 0 0 var(--space-6); color: var(--text-muted); font-size: 13.5px; }
.auth-card form { text-align: left; }
.auth-error { color: var(--red); font-size: 13px; margin: -6px 0 var(--space-3); min-height: 0; }
.auth-error:empty { display: none; }
.auth-hint { margin: var(--space-5) 0 0; font-size: 12.5px; color: var(--text-faint); }

/* ---------- Member rows (equipe) ---------- */

.member-row { display: flex; align-items: center; gap: var(--space-3); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
.member-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-glow); color: var(--accent-strong); font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; text-transform: uppercase; }
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-info { flex: 1; min-width: 0; }
.member-name-row { display: flex; align-items: center; gap: 8px; }
.member-name { font-weight: 700; font-size: 14px; }
.member-tag { font-size: 12px; color: var(--text-faint); }
.role-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,0.06); }
.role-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); display: inline-block; flex-shrink: 0; }
.online-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }

.avatar-upload-row { display: flex; align-items: center; gap: var(--space-4); }
.avatar-preview { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-glow); color: var(--accent-strong); font-weight: 700; font-size: 24px; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; text-transform: uppercase; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .sidebar { width: 84px; align-items: center; padding: var(--space-4) var(--space-2); }
  .brand { padding: var(--space-2); justify-content: center; }
  .brand-text, .nav-item span, .user-info { display: none; }
  .nav-item { justify-content: center; padding: var(--space-2); }
  .nav-item.active::before { left: -8px; }
  .user-card { justify-content: center; }
  .main { padding: var(--space-5); }
  .grid-kanban { grid-template-columns: 1fr; }
}
@media (max-width: 600px) { .topbar-date { display: none; } .modal { padding: var(--space-5); } }
