/* Erebor — palette « trésor du dragon » (bleu nuit + or + gemmes). */
:root {
  --bg:        #0f1320;
  --bg-2:      #141a2b;
  --surface:   #171d2e;
  --surface-2: #1e2740;
  --border:    #2a3452;
  --text:      #eef1f8;
  --muted:     #8b93a7;
  --gold:      #e8c66a;
  --gold-2:    #d4af5f;
  --sapphire:  #4a90d9;
  --ruby:      #d9455f;
  --emerald:   #4caf72;
  --amethyst:  #9b6dc9;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #1a2138 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 700; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--bg-2);
  border-right: 1px solid var(--border); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand .name { font-family: Georgia, serif; font-size: 22px; letter-spacing: 2px; color: var(--gold); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600; border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--gold); border-color: var(--border); }
.nav-item .ico { width: 20px; text-align: center; }
.sidebar .spacer { flex: 1; }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 26px; }

/* Cards & grid */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 16px; color: var(--text); }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 28px; font-weight: 700; font-family: Georgia, serif; }
.value.pos { color: var(--emerald); }
.value.neg { color: var(--ruby); }
.value.gold { color: var(--gold); }

/* Bars */
.bar { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Table / lists */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 12px; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; font-family: Georgia, serif; }
.amount.exp { color: var(--ruby); }
.amount.inc { color: var(--emerald); }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip.perso { color: var(--amethyst); border-color: var(--amethyst); }
.chip.shared { color: var(--gold); border-color: var(--gold-2); }

/* Forms */
label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-2); }
textarea { min-height: 90px; resize: vertical; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: transparent; border: none; color: var(--muted); padding: 8px 14px; cursor: pointer; font-weight: 600; }
.seg button.active { background: var(--surface-2); color: var(--gold); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); padding: 9px 16px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: var(--gold-2); }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #241c07; border-color: var(--gold-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--ruby); border-color: var(--ruby); background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(6,9,16,0.7); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 480px; padding: 22px; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 16px; font-size: 20px; color: var(--gold); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Auth / onboarding */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; text-align: center; }
.auth-card img { width: 96px; height: 96px; border-radius: 22px; margin-bottom: 10px; box-shadow: var(--shadow); }
.auth-card .name { font-family: Georgia, serif; font-size: 30px; letter-spacing: 3px; color: var(--gold); margin-bottom: 4px; }
.auth-card .tagline { color: var(--muted); margin-bottom: 24px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 100; }
.toast.err { border-color: var(--ruby); color: #ffd7dd; }
.empty { color: var(--muted); text-align: center; padding: 30px; }
.mono { font-variant-numeric: tabular-nums; }

/* Responsive : sidebar → barre du haut */
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 10px; }
  .sidebar .brand { display: none; }
  .sidebar .spacer { display: none; }
  .nav-item { white-space: nowrap; }
  .main { padding: 18px 16px 80px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}
