:root {
  --bg: #0c0d10;
  --bg2: #12141a;
  --card: #16181f;
  --line: #242833;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --success: #2fbf71;
  --danger: #e5484d;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- login ---------- */

.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.brand-mark {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  background: linear-gradient(145deg, #4f8cff, #2fbf71);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 30px; color: #06121f;
}
.login h1 { font-size: 22px; margin: 0 0 6px; }
.login p { margin: 0 0 22px; font-size: 14px; }
.login input {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}
.login .btn { width: 100%; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }

/* ---------- layout ---------- */

.app { min-height: 100dvh; padding-bottom: calc(96px + var(--safe-b)); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  background: rgba(12, 13, 16, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(47,191,113,.15);
}
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  border-radius: 12px;
}
.icon-btn:active { background: var(--card); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 61px;
  background: var(--bg);
  z-index: 15;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.tab.active {
  background: var(--text);
  color: #0c0d10;
  border-color: var(--text);
}

.list { padding: 6px 12px 12px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- card ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  flex: 1;
}
.card-budget {
  font-size: 12px;
  color: #f0c674;
  background: rgba(240, 198, 116, .1);
  border-radius: 8px;
  padding: 4px 8px;
  white-space: nowrap;
}
.card-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.card-text { margin-bottom: 10px; }
.card-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 12px;
  font-size: 15px;
  line-height: 1.5;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
}
.card-input:focus { outline: none; border-color: var(--accent); }

.card-foot { display: flex; flex-direction: column; gap: 10px; }

.card-amount {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.card-amount input {
  width: 72px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 10px;
  font-size: 15px;
  text-align: center;
}
.card-amount input:focus { outline: none; border-color: var(--accent); }
.days-label { margin-left: 6px; }

.card-actions { display: flex; gap: 8px; }
.card-actions .btn { flex: 1; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  transition: transform .06s ease, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #05210f; }
.btn.ghost { background: transparent; }
.btn.link { color: var(--muted); }
.btn.reject:active { color: var(--danger); border-color: var(--danger); }
.btn[disabled] { opacity: .5; }

/* ---------- action bar ---------- */

.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px calc(12px + var(--safe-b));
  background: rgba(18, 20, 26, .94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.actionbar-info { font-size: 13px; color: var(--muted); flex: 1; }
.actionbar .btn { flex: 0 0 auto; padding: 14px 18px; }

/* ---------- sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
}
.sheet-inner {
  width: 100%;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  padding: 10px 10px calc(20px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet-item {
  width: 100%;
  padding: 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  text-align: left;
  border-radius: 12px;
}
.sheet-item:active { background: var(--card); }
.sheet-item.danger { color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

.install-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px 0;
  padding: 12px 14px;
  background: rgba(79, 140, 255, .12);
  border: 1px solid rgba(79, 140, 255, .3);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #cfe0ff;
}
.install-hint b { color: #fff; }
.hint-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #cfe0ff;
  font-size: 16px;
  padding: 4px 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-b));
  transform: translate(-50%, 20px);
  background: #242833;
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .2s ease;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.busy {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12,13,16,.6);
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* statuts */
.status-pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.status-queued { background: rgba(79,140,255,.15); color: #7aa8ff; }
.status-published { background: rgba(47,191,113,.15); color: #4fd693; }
.status-failed { background: rgba(229,72,77,.15); color: #ff7b7f; }
.status-rejected { background: rgba(139,147,167,.15); color: var(--muted); }

/* desktop : un peu plus large */
@media (min-width: 720px) {
  .list { max-width: 720px; margin: 0 auto; }
  .topbar, .tabs { max-width: 720px; margin: 0 auto; }
  .actionbar { justify-content: center; }
}
