/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Thème sombre (défaut) ────────────────────────────────────────────────── */
:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #22263a;
  --border:   #2e3250;
  --accent:   #6c63ff;
  --accent2:  #8b83ff;
  --success:  #22c55e;
  --danger:   #ef4444;
  --warning:  #f59e0b;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --shadow:   0 2px 12px rgba(0,0,0,.4);
}

/* ── Thème clair ──────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:       #f0f2f8;
  --surface:  #ffffff;
  --surface2: #eef0f7;
  --border:   #dde1f0;
  --accent:   #6c63ff;
  --accent2:  #5a52ee;
  --success:  #16a34a;
  --danger:   #dc2626;
  --warning:  #d97706;
  --text:     #111827;
  --muted:    #6b7280;
  --shadow:   0 2px 12px rgba(0,0,0,.08);
}

/* Inversions spécifiques au thème clair */
[data-theme="light"] #app-header         { box-shadow: 0 1px 8px rgba(0,0,0,.06); }
[data-theme="light"] #profile-menu       { box-shadow: 0 8px 32px rgba(0,0,0,.12); }
[data-theme="light"] td code             { background: #eef0f7; color: #5a52ee; }
[data-theme="light"] .stat-table-box tr:hover td { background: none; }
[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea {
  background: #f8f9ff; border-color: var(--border);
}
[data-theme="light"] input:focus, [data-theme="light"] select:focus { border-color: var(--accent); }
[data-theme="light"] tr:hover td        { background: #f5f6ff; }
[data-theme="light"] #login-box         { box-shadow: 0 4px 32px rgba(0,0,0,.08); }
[data-theme="light"] #toast             { box-shadow: 0 4px 24px rgba(0,0,0,.12); }
[data-theme="light"] .payout-box        { background: linear-gradient(135deg, rgba(108,99,255,.08), rgba(108,99,255,.03)); }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

/* ── Global layout : header + (sidebar | main) ───────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── App Header ──────────────────────────────────────────────────────────── */
#app-header {
  height: 56px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: relative;
  z-index: 100;
}

#header-logo {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent2);
  letter-spacing: -0.6px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
#header-logo:hover { opacity: .85; text-decoration: none; }

#header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.hn-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}
.hn-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.hn-item.active { color: var(--text); font-weight: 600; }
.hn-item.active::after {
  content: '';
  display: block;
  position: absolute;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  width: calc(100% - 24px);
  left: 12px;
}
.hn-item { position: relative; }

.hn-advertise {
  color: var(--accent2);
  font-weight: 600;
  margin-left: 4px;
}
.hn-advertise:hover { background: rgba(108,99,255,.1); color: var(--accent2); }

/* Theme toggle (header, compact) */
#theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
  margin-left: 8px;
}
#theme-toggle:hover  { background: var(--border); }
#theme-toggle:active { transform: scale(.9); }

/* Header right zone */
#header-right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  flex-shrink: 0;
}

/* Profile chip */
#header-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
  user-select: none;
  border: 1px solid transparent;
}
#header-profile:hover { background: var(--surface2); border-color: var(--border); }

#header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
}

#header-profile-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}
#header-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
#header-balances {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
#header-pts  { color: var(--accent2); font-weight: 600; }
#header-dol  { color: var(--success); font-weight: 600; }
.hb-sep { color: var(--border); }

#header-chevron {
  font-size: 11px;
  color: var(--muted);
  transition: transform .2s;
}
#header-profile.open #header-chevron { transform: rotate(180deg); }

/* Profile dropdown menu */
#profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
  animation: menuSlide .15s ease;
}
@keyframes menuSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pm-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background .12s;
  cursor: pointer;
}
.pm-item:hover { background: var(--surface2); text-decoration: none; }
.pm-divider { height: 1px; background: var(--border); }
.pm-danger { color: var(--danger); }
.pm-danger:hover { background: rgba(239,68,68,.08); }

/* ── Layout : plein écran (plus de sidebar) ──────────────────────────────── */
#app-layout {
  flex: 1;
  overflow: hidden;
  display: flex;
}

/* ── Bouton ＋ Créer dans le header ──────────────────────────────────────── */
#header-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: opacity .15s, box-shadow .15s;
  box-shadow: 0 3px 10px rgba(108,99,255,.35);
  white-space: nowrap;
  letter-spacing: .1px;
}
#header-create-btn:hover { opacity: .88; box-shadow: 0 5px 14px rgba(108,99,255,.45); text-decoration: none; }
#header-create-btn.active { background: var(--accent2); }

/* ── Main content ────────────────────────────────────────────────────────── */
#app-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#topbar {
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#topbar-title { font-size: 13px; font-weight: 600; }
#topbar-subtitle { font-size: 12px; color: var(--muted); }

#page-body { padding: 24px; flex: 1; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ── Create success card ──────────────────────────────────────────────────── */
.create-success-card {
  background: var(--surface);
  border: 1px solid rgba(34,197,94,.3);
  border-radius: 14px;
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  animation: fadeSlideUp .3s ease;
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.create-success-icon { font-size: 28px; flex-shrink: 0; margin-top: 2px; }
.create-success-body { flex: 1; min-width: 0; }
.create-success-label { font-size: 13px; font-weight: 700; color: var(--success); margin-bottom: 8px; }
.create-success-url {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 6px;
}
.create-success-url code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent2);
  flex: 1;
  word-break: break-all;
  background: none;
  padding: 0;
}
.create-success-dest { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.create-success-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* ── Shorten card ─────────────────────────────────────────────────────────── */
.shorten-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px 20px;
  margin-bottom: 20px;
  position: relative;
}
.shorten-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.shorten-icon { font-size: 16px; }

/* Fields */
.sh-field { margin-bottom: 14px; }
.sh-field:last-of-type { margin-bottom: 0; }
.sh-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .2px;
}
.sh-required { color: var(--danger); margin-left: 2px; }
.sh-optional {
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
  font-size: 11px;
}
.sh-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 13px;
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.sh-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}
.sh-input::placeholder { color: var(--muted); }
.sh-input-lg { font-size: 14px; padding: 11px 14px; }
.sh-select-wrap { position: relative; }
.sh-select-wrap::after {
  content: '▾';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 12px;
}
.sh-select-wrap .sh-input { appearance: none; padding-right: 30px; cursor: pointer; }

/* Row dossier + tags */
.sh-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 600px) { .sh-row { grid-template-columns: 1fr; } }

/* Tags wrap inline */
.sh-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 42px;
  align-content: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 9px;
  cursor: pointer;
  transition: border-color .2s;
}
.sh-tags-wrap:focus-within { border-color: var(--accent); }
.sh-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  user-select: none;
  opacity: .38;
  border: 2px solid transparent;
}
.sh-tag-pill.on { opacity: 1; }
.sh-tag-pill:hover { opacity: .75; transform: scale(1.05); }
.sh-tag-pill.on:hover { opacity: .85; }
.sh-tag-add {
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
  font-family: inherit;
}
.sh-tag-add:hover { border-color: var(--accent); color: var(--accent2); }
.sh-tags-empty { font-size: 12px; color: var(--muted); line-height: 26px; }

/* Wait slider */
.sh-wait-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.sh-pts-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(108,99,255,.12);
  border: 1px solid rgba(108,99,255,.25);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
}
.sh-pts-secs { font-weight: 700; color: var(--accent2); }
.sh-pts-sep  { color: var(--muted); }
.sh-pts-val  { font-weight: 700; color: var(--success); }
.sh-pts-unit { color: var(--muted); }

.sh-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  /* filled dynamically via JS */
  background: linear-gradient(to right, var(--accent) 0%, var(--surface2) 0%);
  border: none;
}
.sh-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: grab;
  transition: transform .12s;
}
.sh-slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.2); }
.sh-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: grab;
}
.sh-slider-marks {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .2px;
}
.sh-slider-marks span { text-align: center; line-height: 1.4; }
.sh-slider-marks small { display: block; font-size: 9px; color: var(--accent); font-weight: 700; opacity: .8; }

/* Submit */
.sh-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(108,99,255,.35);
  letter-spacing: .2px;
}
.sh-submit:hover  { opacity: .88; box-shadow: 0 6px 20px rgba(108,99,255,.45); }
.sh-submit:active { transform: scale(.98); }
.sh-submit:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.sh-submit-icon { font-size: 15px; }

/* ── Stat Cards Row ──────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat-card .stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--accent2); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; color: var(--muted); font-weight: 500; }
.form-group.grow { flex: 1; min-width: 200px; }

input[type=text], input[type=url], input[type=email], input[type=password],
select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); }

select { cursor: pointer; }
select option { background: var(--surface2); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-success { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

.btn-copy {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background .15s;
  vertical-align: middle;
}
.btn-copy:hover { background: var(--surface2); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(46,50,80,.5);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

td.num { text-align: right; font-variant-numeric: tabular-nums; }
td code { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 12px; background: var(--surface2); padding: 2px 6px; border-radius: 4px; }

.link-dest { font-size: 12px; color: var(--text-muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-short { display: flex; align-items: center; gap: 4px; }
.link-short code { color: var(--accent2); }
.link-actions { display: flex; align-items: center; gap: 4px; white-space: nowrap; }

/* ── Tabs (login page) ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--surface2); border-radius: 10px; padding: 4px; }
.tab-btn { flex: 1; padding: 8px; border: none; background: none; color: var(--muted); font-size: 13px; font-weight: 600; border-radius: 7px; cursor: pointer; transition: background .15s, color .15s; font-family: inherit; }
.tab-btn.active { background: var(--accent); color: #fff; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Login page ──────────────────────────────────────────────────────────── */
#login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
#login-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}
#login-logo {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 24px;
}

/* ── Period buttons (stats) ──────────────────────────────────────────────── */
.period-btns { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.period-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Chart ───────────────────────────────────────────────────────────────── */
#chart-views { width: 100%; height: 160px; }

/* ── Mini stat tables (stats page) ──────────────────────────────────────── */
.stat-tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.stat-table-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.stat-table-box h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 10px; }
.stat-table-box table { width: 100%; }
.stat-table-box td { padding: 5px 0; font-size: 12px; border: none; }
.stat-table-box td:last-child { text-align: right; color: var(--accent2); font-weight: 600; }
.stat-table-box tr:hover td { background: none; }

/* ── Account ─────────────────────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

.payout-box {
  background: linear-gradient(135deg, rgba(108,99,255,.15), rgba(108,99,255,.05));
  border: 1px solid rgba(108,99,255,.3);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}
.payout-amount { font-size: 36px; font-weight: 700; color: var(--accent2); }
.payout-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: transform .25s, opacity .25s;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.error { border-color: var(--danger); color: var(--danger); }
#toast.success { border-color: var(--success); color: var(--success); }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent2); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 8px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: rgba(34,197,94,.15); color: var(--success); }
.badge-ok      { background: rgba(34,197,94,.15); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-muted   { background: var(--surface2);       color: var(--muted); }

/* ── Filtres historique ──────────────────────────────────────────────────── */
.hist-filter {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; font-family: inherit;
  transition: background .15s, border-color .15s, color .15s;
}
.hist-filter:hover { background: var(--border); color: var(--text); }
.hist-filter.active {
  background: rgba(108,99,255,.15); border-color: rgba(108,99,255,.4);
  color: var(--primary);
}

/* ── Link Manager layout ─────────────────────────────────────────────────── */
#link-manager {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 16px;
  align-items: start;
}

/* Sidebar */
#manager-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  position: sticky;
  top: 16px;
}
.ms-section { padding: 8px 0; border-bottom: 1px solid var(--border); }
.ms-section:last-child { border-bottom: none; }
.ms-section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
}
.ms-add-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1;
  padding: 0 2px; border-radius: 4px;
  transition: color .15s, background .15s;
}
.ms-add-btn:hover { color: var(--accent2); background: var(--surface2); }
.ms-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px;
  font-size: 13px; cursor: pointer;
  transition: background .12s, color .12s;
  border-radius: 0;
  gap: 6px;
}
.ms-item:hover { background: var(--surface2); }
.ms-item.active { background: rgba(108,99,255,.12); color: var(--accent2); font-weight: 600; }
.ms-item-left { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
.ms-item-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ms-count { font-size: 11px; color: var(--muted); background: var(--surface2); padding: 1px 6px; border-radius: 20px; flex-shrink: 0; }
.ms-item-actions { display: none; gap: 2px; }
.ms-item:hover .ms-item-actions { display: flex; }
.ms-icon-btn { background: none; border: none; cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 4px; color: var(--muted); }
.ms-icon-btn:hover { background: var(--border); color: var(--text); }

/* Manager main */
#manager-main { min-width: 0; }
.links-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.links-loading  { display: flex; justify-content: center; padding: 40px 0; }

/* Tag pills */
.tag-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}

/* ── Link cards ──────────────────────────────────────────────────────────── */
.link-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color .18s, box-shadow .18s;
}
.link-card:hover {
  border-color: rgba(108,99,255,.45);
  box-shadow: 0 2px 16px rgba(108,99,255,.09);
}

/* Corps */
.lc-body { flex: 1; min-width: 0; }

.lc-slug-row { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.lc-slug {
  font-family: 'JetBrains Mono','Fira Code',monospace;
  font-size: 15px; font-weight: 700;
  color: var(--accent2); text-decoration: none;
  letter-spacing: -.3px;
}
.lc-slug:hover { text-decoration: underline; }
.lc-copy {
  background: none; border: none; cursor: pointer;
  font-size: 15px; color: var(--muted); padding: 1px 4px;
  border-radius: 5px; line-height: 1;
  transition: color .15s, background .15s;
}
.lc-copy:hover { color: var(--accent2); background: var(--surface2); }

.lc-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lc-dest {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 420px;
}
.lc-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 7px; }

/* Stats */
.lc-stats {
  display: flex; gap: 20px; flex-shrink: 0;
  padding: 0 8px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.lc-stat { text-align: center; min-width: 44px; }
.lc-stat-val {
  display: block;
  font-size: 17px; font-weight: 800;
  color: var(--text); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.lc-stat-pts { color: var(--accent2); }
.lc-stat-lbl {
  display: block;
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-top: 1px;
}

/* Actions */
.lc-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; flex-shrink: 0; }

/* Sélecteur attente + badge pts */
.lc-wait-row { display: flex; align-items: center; gap: 6px; }
.lc-wait-sel {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  padding: 5px 8px; font-size: 12px; font-family: inherit;
  cursor: pointer; outline: none;
  transition: border-color .15s;
}
.lc-wait-sel:focus { border-color: var(--accent); }
.lc-pts-badge {
  display: inline-flex; align-items: center;
  background: rgba(108,99,255,.13); border: 1px solid rgba(108,99,255,.25);
  color: var(--accent2); border-radius: 20px;
  padding: 3px 10px; font-size: 11px; font-weight: 700;
  white-space: nowrap; letter-spacing: .2px;
  transition: background .2s, color .2s;
}

/* Boutons */
.lc-btns { display: flex; gap: 4px; align-items: center; }
.lc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 8px;
  font-size: 13px; cursor: pointer; text-decoration: none;
  color: var(--text); line-height: 1; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.lc-btn:hover { background: var(--border); text-decoration: none; }
.lc-btn-copy {
  background: rgba(108,99,255,.12); border-color: rgba(108,99,255,.3);
  color: var(--accent2); font-weight: 600;
}
.lc-btn-copy:hover { background: rgba(108,99,255,.22); border-color: var(--accent); }
.lc-btn-del { border-color: rgba(239,68,68,.25); }
.lc-btn-del:hover { background: rgba(239,68,68,.12); border-color: var(--danger); }

/* ── Modales ─────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%; max-width: 380px;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
}
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 18px; }

/* Color swatches */
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform .12s, border-color .12s;
  flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); transform: scale(1.1); }

/* Tags checkbox list */
.tags-checkbox-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-check {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; user-select: none;
  opacity: .5; transition: opacity .15s;
  border: 2px solid transparent;
}
.tag-check.selected { opacity: 1; border-color: rgba(255,255,255,.3); }

/* ── Responsive manager ──────────────────────────────────────────────────── */
@media (max-width: 750px) {
  #link-manager { grid-template-columns: 1fr; }
  #manager-sidebar { position: static; }
  .link-card { flex-wrap: wrap; gap: 10px; }
  .lc-stats { border: none; padding: 0; flex-direction: row; gap: 16px; }
  .lc-actions { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; }
  .lc-dest { max-width: 100%; }
}

/* ── Theme toggle button ─────────────────────────────────────────────────── */
#theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
#theme-toggle:hover  { background: var(--border); }
#theme-toggle:active { transform: scale(.9); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  /* Overview grid passe en colonne */
  #page-body > div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
}
/* ── Hamburger ───────────────────────────────────────────────────────────── */
#mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  padding: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
#mobile-menu-btn span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
#mobile-menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
#mobile-menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Overlay ─────────────────────────────────────────────────────────────── */
#mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  backdrop-filter: blur(2px);
}
#mobile-overlay.show { display: block; }

/* ── Drawer ──────────────────────────────────────────────────────────────── */
#mobile-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  max-height: 80vh;
  overflow-y: auto;
}
#mobile-drawer.open { transform: translateY(0); }

/* Poignée visuelle */
#mobile-drawer::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 12px;
}

.mn-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background .13s;
}
.mn-item:hover, .mn-item:active { background: var(--surface2); text-decoration: none; }
.mn-item.active { background: rgba(108,99,255,.12); color: var(--accent2); font-weight: 700; }
.mn-icon { font-size: 20px; width: 26px; text-align: center; flex-shrink: 0; }
.mn-divider { height: 1px; background: var(--border); margin: 6px 4px; }
.mn-logout { color: var(--danger); }
.mn-logout:hover { background: rgba(239,68,68,.08); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  #header-nav { display: none; }
  #header-create-btn { display: none; }
  #mobile-menu-btn { display: flex; }
}

@media (max-width: 600px) {
  #header-profile-info, #header-chevron { display: none; }
  #header-profile { padding: 4px; border-radius: 50%; }
  #page-body { padding: 16px; }
  .form-row { flex-direction: column; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .create-success-card { flex-direction: column; }
  .create-success-actions { flex-direction: row; }
}

/* ── Upload drag & drop ──────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s;
  position: relative;
  background: var(--surface2);
}
.upload-zone:hover,
.upload-zone.drag-over { border-color: var(--primary); background: rgba(108,99,255,.07); }
.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-zone-icon { font-size: 32px; margin-bottom: 8px; line-height: 1; pointer-events: none; }
.upload-zone-text { font-size: 13px; color: var(--text-muted); pointer-events: none; }
.upload-zone-text strong { color: var(--primary); }
.upload-zone-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; pointer-events: none; }

.upload-preview {
  display: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  background: var(--surface2);
}
.upload-preview img {
  width: 100%; display: block;
  max-height: 200px; object-fit: contain;
}
.upload-preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: rgba(0,0,0,.35); position: absolute; bottom: 0; left: 0; right: 0;
}
.upload-preview-name { font-size: 11px; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-preview-del {
  font-size: 16px; line-height: 1; cursor: pointer; color: #fff; opacity: .8;
  background: none; border: none; padding: 0; flex-shrink: 0;
}
.upload-preview-del:hover { opacity: 1; }

.upload-progress {
  display: none; height: 4px; border-radius: 2px;
  background: var(--border); margin-top: 8px; overflow: hidden;
}
.upload-progress-bar {
  height: 100%; width: 0%; background: var(--primary);
  transition: width .2s; border-radius: 2px;
}
