/* ============================================================ iPod Mod — design system
   Mobile-first, épuré. Variables de thème (clair + sombre auto). */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e4e8ef;
  --border-strong: #d3d9e3;
  --ink: #14161a;
  --muted: #687184;
  --faint: #99a2b2;
  --accent: #2f6fed;
  --accent-soft: #e8f0ff;
  --good: #15924b;
  --good-soft: #e3f6ea;
  --bad: #d8362f;
  --bad-soft: #fde8e7;
  --warn: #b9740a;
  --warn-soft: #fdf0db;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(16,24,40,.06);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --r: 14px;
  --r-sm: 10px;
  --nav-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0f;
    --surface: #16181d;
    --surface-2: #1c1f26;
    --border: #272b33;
    --border-strong: #343a44;
    --ink: #eef1f6;
    --muted: #9aa3b2;
    --faint: #6b7383;
    --accent: #5b8cff;
    --accent-soft: #1a2440;
    --good: #34c172;
    --good-soft: #11271b;
    --bad: #ff6a61;
    --bad-soft: #2c1715;
    --warn: #e6a23c;
    --warn-soft: #2c2310;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.boot { padding: 40px; text-align: center; color: var(--muted); }
h1,h2,h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12.5px; }

/* ------------------------------------------------------------ layout */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .logo { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; }
.topbar .ttl { font-size: 16px; font-weight: 680; }
.topbar .sub { color: var(--faint); font-size: 12px; font-weight: 500; }
.topbar .spacer { flex: 1; }

.layout { flex: 1; display: flex; max-width: 1180px; width: 100%; margin: 0 auto; }
.sidebar { display: none; }
.content { flex: 1; min-width: 0; padding: 18px 16px calc(var(--nav-h) + 28px); }
.view { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.view-wide { max-width: 980px; }

/* bottom nav (mobile) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px; color: var(--faint); font-size: 10.5px; font-weight: 600;
  font-family: var(--font);
}
.tabbar button svg { width: 23px; height: 23px; }
.tabbar button.on { color: var(--accent); }

/* ------------------------------------------------------------ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 15.5px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.input, .select, textarea, .inp {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 11px 12px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 64px; }
.input:focus, .select:focus, textarea:focus, .inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23687184' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 36px; }
.input.money { text-align: right; font-variant-numeric: tabular-nums; }
.inline-prefix .input.money { padding-right: 30px; }
/* masque les flèches spin des inputs number pour un rendu propre */
.input[type=number]::-webkit-outer-spin-button,
.input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.inline-prefix { position: relative; }
.inline-prefix .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 13px; pointer-events: none; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 620; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); padding: 10px 15px; border-radius: var(--r-sm);
  transition: transform .05s, background .12s, border-color .12s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--bad); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

/* difficulty dots */
.diff { display: inline-flex; gap: 3px; align-items: center; }
.diff i { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.diff i.on1 { background: var(--good); } .diff i.on2 { background: #9bbf2e; }
.diff i.on3 { background: var(--warn); } .diff i.on4 { background: #e2701c; }
.diff i.on5 { background: var(--bad); }

/* ------------------------------------------------------------ result / KPIs */
.result-card { padding: 18px 18px 16px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.kpi { display: flex; flex-direction: column; gap: 1px; }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 19px; font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .v.big { font-size: 27px; }
.kpi .v.good { color: var(--good); } .kpi .v.bad { color: var(--bad); }
.divider { height: 1px; background: var(--border); margin: 4px 0; border: 0; }

.banner { display: flex; gap: 9px; align-items: flex-start; padding: 10px 13px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.good { background: var(--good-soft); color: var(--good); }
.banner svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }

/* ------------------------------------------------------------ part checklist */
.cat-group { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.cat-group + .cat-group { margin-top: 10px; }
.cat-head { display: flex; align-items: center; gap: 8px; padding: 11px 13px; cursor: pointer; background: var(--surface-2); user-select: none; }
.cat-head .cat-name { font-weight: 650; font-size: 13.5px; }
.cat-head .spacer { flex: 1; }
.cat-head .count { font-size: 12px; color: var(--accent); font-weight: 700; }
.cat-head .caret { color: var(--faint); transition: transform .15s; }
.cat-head.open .caret { transform: rotate(90deg); }
.opt-row { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-top: 1px solid var(--border); }
.opt-row:hover { background: var(--surface-2); }
.opt-main { flex: 1; min-width: 0; }
.opt-name { font-size: 13.5px; font-weight: 550; }
.opt-meta { font-size: 11.5px; color: var(--faint); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.opt-price { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 13.5px; white-space: nowrap; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border-strong); flex: 0 0 auto; display: grid; place-items: center; cursor: pointer; background: var(--surface); transition: all .12s; }
.check.on { background: var(--accent); border-color: var(--accent); }
.check svg { width: 14px; height: 14px; color: #fff; opacity: 0; }
.check.on svg { opacity: 1; }

/* selected lines */
.line { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.line:last-child { border-bottom: 0; }
.line .ln-name { flex: 1; min-width: 0; font-size: 13.5px; }
.line .ln-name small { display: block; color: var(--faint); }
.line .ln-cost { width: 92px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.stepper button { border: 0; background: var(--surface-2); width: 30px; height: 32px; font-size: 17px; cursor: pointer; color: var(--ink); }
.stepper span { width: 28px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; }

/* search results */
.search-results { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; margin-top: 6px; }
.sr-item { padding: 10px 13px; cursor: pointer; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sr-item:first-child { border-top: 0; }
.sr-item:hover, .sr-item.active { background: var(--accent-soft); }
.sr-item .sr-name { font-weight: 600; font-size: 14px; }
.sr-item .sr-sub { font-size: 12px; color: var(--muted); }

/* reverse calc table */
.rev-table { width: 100%; border-collapse: collapse; }
.rev-table th, .rev-table td { padding: 9px 6px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--border); }
.rev-table th { font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.rev-table td:first-child, .rev-table th:first-child { text-align: left; }
.rev-table .maxbuy { font-weight: 720; }

/* list cards (sims) */
.list { display: flex; flex-direction: column; gap: 10px; }
.sim-card { display: flex; align-items: center; gap: 13px; padding: 13px 15px; }
.sim-card .sc-main { flex: 1; min-width: 0; }
.sim-card .sc-name { font-weight: 650; font-size: 15px; }
.sim-card .sc-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.sim-card .sc-margin { text-align: right; font-variant-numeric: tabular-nums; }
.sim-card .sc-margin .m { font-size: 17px; font-weight: 720; }

/* models grid */
.model-card { padding: 14px 15px; cursor: pointer; }
.model-card:hover { border-color: var(--accent); }
.spec-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.spec-row:last-child { border-bottom: 0; }
.spec-row .sk { color: var(--muted); }
.spec-row .sv { font-weight: 550; text-align: right; }
.var-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.var-table th, .var-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.var-table th { font-size: 11.5px; color: var(--muted); text-transform: uppercase; }

/* ------------------------------------------------------------ modal */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(10,14,22,.45); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 640px) { .overlay { align-items: center; padding: 24px; } }
.modal {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  max-height: 92vh; overflow: auto; padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { font-size: 16px; flex: 1; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px); transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; padding: 26px; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.auth-card .logo { width: 56px; height: 56px; border-radius: 15px; margin: 0 auto; }

.empty { text-align: center; padding: 38px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 10px; }
.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }
.hide-sm { display: none; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ------------------------------------------------------------ desktop */
@media (min-width: 900px) {
  .tabbar { display: none; }
  .hide-sm { display: initial; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; width: 210px; flex: 0 0 210px;
    padding: 18px 12px; border-right: 1px solid var(--border); position: sticky; top: 57px;
    height: calc(100vh - 57px);
  }
  .sidebar .nav-item {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-sm);
    color: var(--muted); font-weight: 600; cursor: pointer; border: 0; background: none; font-family: var(--font); font-size: 14px; text-align: left; width: 100%;
  }
  .sidebar .nav-item svg { width: 19px; height: 19px; }
  .sidebar .nav-item:hover { background: var(--surface-2); color: var(--ink); }
  .sidebar .nav-item.on { background: var(--accent-soft); color: var(--accent); }
  .content { padding: 24px 28px calc(var(--nav-h)); }
  :root { --nav-h: 0px; }
}
