/* Final Check — Apple-inspired design. No external resources (strict CSP). */
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-2: #fbfbfd;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --sep: rgba(0, 0, 0, .08);
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .2);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --gray: #8e8e93;
  --yellow: #ffcc00;
  --warn-ink: #946c00;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.06), 0 18px 48px rgba(0,0,0,.10);
  --radius: 18px;
  --radius-sm: 10px;
  --topbar: rgba(251, 251, 253, .72);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
/* Theme: light by default; dark when chosen, or when "auto" and the OS is dark.
   The choice is stored per browser (static/theme.js sets <html data-theme>). */
:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #232325;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #8e8e93;
  --sep: rgba(255, 255, 255, .1);
  --fill: rgba(118, 118, 128, .24);
  --fill-2: rgba(118, 118, 128, .36);
  --blue: #0a84ff;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --gray: #98989d;
  --yellow: #ffd60a;
  --warn-ink: #ffd60a;
  --shadow: 0 0 0 1px rgba(255,255,255,.05);
  --shadow-lg: 0 0 0 1px rgba(255,255,255,.08), 0 18px 48px rgba(0,0,0,.6);
  --topbar: rgba(22, 22, 23, .72);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #232325;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #8e8e93;
    --sep: rgba(255, 255, 255, .1);
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .36);
    --blue: #0a84ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --gray: #98989d;
    --yellow: #ffd60a;
    --warn-ink: #ffd60a;
    --shadow: 0 0 0 1px rgba(255,255,255,.05);
    --shadow-lg: 0 0 0 1px rgba(255,255,255,.08), 0 18px 48px rgba(0,0,0,.6);
    --topbar: rgba(22, 22, 23, .72);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.47 var(--font);
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { letter-spacing: -.025em; margin: 0; }
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 700; line-height: 1.1; }
h2 { font-size: 21px; font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 55%, transparent); outline-offset: 2px; }

/* ---------- Top bar (frosted glass) */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--topbar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--sep);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 52px;
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-mark, .login-mark { width: 22px; height: 22px; }
.brand-mark circle, .login-mark circle { fill: var(--green); }
.brand-mark path, .login-mark path { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--text-2); padding: 6px 12px; border-radius: 999px; font-size: 14px; transition: background .2s, color .2s; }
.nav a:hover { color: var(--text); background: var(--fill); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--fill); font-weight: 500; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user form { margin: 0; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #5ac8fa, var(--blue)); color: #fff; font-weight: 600; font-size: 13px;
}

/* ---------- Theme switch */
.theme-switch { display: inline-flex; background: var(--fill); border-radius: 999px; padding: 2px; gap: 2px; }
.theme-switch button {
  width: 28px; height: 24px; border: 0; border-radius: 999px; background: transparent; color: var(--text-2);
  display: grid; place-items: center; cursor: pointer; transition: background .2s, color .2s;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.theme-switch svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login-theme { position: fixed; top: 16px; right: 16px; }

/* ---------- Layout */
.container { max-width: 1180px; margin: 0 auto; padding: 36px 24px 80px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.hero p { margin: 6px 0 0; font-size: 17px; }
.back { display: inline-block; margin-bottom: 14px; font-size: 15px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; margin-bottom: 20px;
}
.section-title { font-size: 17px; margin-bottom: 12px; }
.mono-title { font-family: var(--mono); font-weight: 600; letter-spacing: -.03em; word-break: break-all; }

/* ---------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 9px 20px; font: inherit; font-weight: 500; font-size: 15px;
  cursor: pointer; transition: transform .12s ease, background .2s, opacity .2s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--blue) 88%, #000); }
.btn-secondary { background: var(--fill); color: var(--blue); }
.btn-secondary:hover { background: var(--fill-2); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger-soft { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

/* ---------- Inputs */
input[type=text], input[type=search], input[type=date], select {
  font: inherit; color: var(--text); background: var(--fill); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 8px 12px; transition: border-color .2s, background .2s, box-shadow .2s;
}
input:focus, select:focus { outline: none; background: var(--card); border-color: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 20%, transparent); }
input:disabled { opacity: .6; }

/* ---------- Stats */
.stats { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--card); border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; font: inherit; color: inherit; cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
button.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
button.stat.active { box-shadow: 0 0 0 2px var(--blue), var(--shadow); }
.stat-hero { cursor: default; background: linear-gradient(160deg, var(--card), var(--card-2)); }
.stat-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 40px; font-weight: 700; letter-spacing: -.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 20px; color: var(--text-3); font-weight: 600; }
.stat-hero .stat-value { color: var(--green); }
.stat-foot { font-size: 13px; color: var(--text-2); }
.stat-dot { width: 10px; height: 10px; border-radius: 50%; margin-bottom: 6px; }
.stat-ready .stat-dot { background: var(--blue); }
.stat-in_progress .stat-dot { background: var(--orange); }
.stat-blocked .stat-dot { background: var(--red); }
.stat-todo .stat-dot { background: var(--gray); }

/* ---------- Progress bars (native <progress>, CSP friendly) */
progress.bar { appearance: none; -webkit-appearance: none; width: 100%; height: 6px; border: 0; border-radius: 999px; background: var(--fill); overflow: hidden; }
progress.bar::-webkit-progress-bar { background: var(--fill); border-radius: 999px; }
progress.bar::-webkit-progress-value { border-radius: 999px; transition: width .5s ease; background: var(--bar, var(--gray)); }
progress.bar::-moz-progress-bar { border-radius: 999px; background: var(--bar, var(--gray)); }
.stat-hero progress.bar { height: 8px; margin: 8px 0 2px; }
.bar-in_prod { --bar: var(--green); }
.bar-ready { --bar: var(--blue); }
.bar-in_progress { --bar: var(--orange); }
.bar-blocked { --bar: var(--red); }
.bar-todo { --bar: var(--gray); }

/* ---------- Badges & pills */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-in_prod { --c: var(--green); }
.badge-ready { --c: var(--blue); }
.badge-in_progress { --c: var(--orange); }
.badge-blocked { --c: var(--red); }
.badge-todo { --c: var(--gray); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--c, var(--gray)); background: color-mix(in srgb, var(--c, var(--gray)) 14%, transparent); }
.pill-ok { --c: var(--green); } .pill-warn { --c: var(--warn-ink); } .pill-ko { --c: var(--red); } .pill-na { --c: var(--blue); }
.quote { color: var(--text-2); font-style: italic; }
.tag { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--fill); white-space: nowrap; }
.tag-server_prod { color: var(--green); } .tag-server_add { color: var(--blue); } .tag-server_unprod { color: var(--red); } .tag-upload { color: var(--blue); }

/* ---------- Segmented control */
.segmented { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.segmented button {
  border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 500;
  padding: 5px 12px; border-radius: 7px; cursor: pointer; transition: background .2s, color .2s, box-shadow .2s;
}
.segmented button:hover:not(:disabled):not(.active) { background: var(--fill); }
.segmented button.active { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); }
.segmented button:disabled { cursor: not-allowed; opacity: .55; }
.segmented-state button.active.seg-ok { background: var(--green); color: #fff; }
.segmented-state button.active.seg-warn { background: var(--yellow); color: #1d1d1f; }
.segmented-state button.active.seg-ko { background: var(--red); color: #fff; }
.segmented-state button.active.seg-na { background: var(--blue); color: #fff; }
.segmented-state button { min-width: 54px; }

/* ---------- Server list */
.list-card { padding: 0; overflow: hidden; }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--sep); }
.search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--text-3); stroke-width: 2; stroke-linecap: round; }
.search input { width: 100%; padding-left: 34px; }
.server-list { list-style: none; margin: 0; padding: 0; }
.server-list li + li .server-row { border-top: 1px solid var(--sep); }
.server-row {
  display: grid; grid-template-columns: minmax(160px, 1.4fr) 230px minmax(120px, 1fr) 150px 16px;
  align-items: center; gap: 16px; padding: 14px 20px; color: var(--text); transition: background .15s;
}
.server-row:hover { background: var(--fill); text-decoration: none; }
.server-name { font-family: var(--mono); font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-progress { display: flex; align-items: center; gap: 10px; }
.server-progress .small { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.server-updated { text-align: right; }
.chevron { width: 14px; height: 14px; fill: none; stroke: var(--text-3); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.flash-row { animation: flash 1.2s ease; }
@keyframes flash { from { background: color-mix(in srgb, var(--blue) 14%, transparent); } to { background: transparent; } }
.empty-inline { padding: 24px; text-align: center; color: var(--text-2); margin: 0; }
.empty { text-align: center; padding: 48px 20px; display: grid; justify-items: center; gap: 12px; }
.empty-code { font-size: 64px; font-weight: 700; color: var(--text-3); margin: 0; letter-spacing: -.05em; }

/* ---------- Server detail */
.prod-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.prod-card form { margin: 0; }
.prod-info { display: flex; align-items: center; gap: 14px; }
.prod-info p { margin: 2px 0 0; }
.prod-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: var(--fill); color: var(--text-2); }
.prod-icon.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.prod-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.check-list { list-style: none; margin: 0; padding: 0; }
.check { padding: 14px 0; transition: background .3s; }
.check + .check { border-top: 1px solid var(--sep); }
.check-main { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.check-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.check-label { font-weight: 500; }
.check-sub { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.check-sub .comment { flex: 1; font-size: 14px; padding: 6px 10px; }
.check-meta { white-space: nowrap; min-width: 150px; text-align: right; }
.check.saving { opacity: .6; }
.check.saved .check-meta { color: var(--green); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; }
.timeline li + li { border-top: 1px solid var(--sep); }
.timeline-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 8px; background: var(--gray); }
.dot-server_prod { background: var(--green); } .dot-server_unprod { background: var(--red); } .dot-check_update { background: var(--blue); } .dot-server_add { background: var(--gray); }

/* ---------- Réserves (warn) */
.warn-chip {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--warn-ink); background: color-mix(in srgb, var(--yellow) 22%, transparent);
  white-space: nowrap;
}
.warn-chip[hidden], .warn-link[hidden] { display: none; }
.warn-chip-lg { font-size: 13px; padding: 4px 10px; }
.warn-text { color: var(--warn-ink); font-weight: 500; }
.warn-link { border: 0; background: none; padding: 0; font: inherit; color: var(--warn-ink); font-weight: 500; cursor: pointer; }
.warn-link:hover { text-decoration: underline; }
.segmented .seg-warn-filter.active { color: var(--warn-ink); }
.server-state { display: flex; align-items: center; gap: 6px; }
.hero-badges { display: flex; align-items: center; gap: 8px; }
.check[data-state="warn"] .comment { background: color-mix(in srgb, var(--yellow) 14%, transparent); }
.check[data-state="warn"] .comment::placeholder { color: var(--warn-ink); }
.check.need-comment .comment { border-color: var(--yellow); box-shadow: 0 0 0 4px color-mix(in srgb, var(--yellow) 30%, transparent); }

/* ---------- Manual add */
.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.add-form { display: flex; gap: 8px; margin: 0; }
.add-form input { width: 240px; font-family: var(--mono); font-size: 14px; }
.add-form input::placeholder { font-family: var(--font); }

/* ---------- Toasts */
.toast { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; background: var(--card); box-shadow: var(--shadow); border-left: 4px solid var(--blue); }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-floating {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; margin: 0;
  border-left: 0; border-radius: 999px; padding: 10px 20px; box-shadow: var(--shadow-lg);
  background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.toast-floating.error { color: var(--red); }
.form-error { color: var(--red); font-size: 14px; margin: 12px 0 0; }

/* ---------- Upload */
.upload-form { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.dropzone {
  position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 36px 20px; border: 2px dashed var(--fill-2); border-radius: var(--radius); cursor: pointer; transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 5%, transparent); }
.dropzone svg { width: 34px; height: 34px; fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dropzone-title { font-weight: 600; color: var(--blue); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.result { background: var(--fill); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; }
.result .stat-value { font-size: 30px; }
.result-added .stat-value { color: var(--green); }
.result-invalid .stat-value { color: var(--red); }
.details { margin: 12px 0; }
.details summary { cursor: pointer; font-weight: 500; }
.mono-list { font-family: var(--mono); font-size: 13px; columns: 3 200px; padding-left: 18px; }
.code { background: var(--fill); border-radius: 12px; padding: 14px 16px; font-family: var(--mono); font-size: 13px; margin: 0; overflow-x: auto; }

/* ---------- Audit */
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.filters-actions { display: flex; align-items: center; gap: 14px; }
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 12px 16px; border-bottom: 1px solid var(--sep); background: var(--card-2); }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--sep); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 16px; }

/* ---------- Login */
.login-page .container { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; text-align: center; background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 44px 32px 32px; }
.login-mark { width: 56px; height: 56px; margin-bottom: 14px; }
.login-card h1 { font-size: 30px; }
.login-card > .muted { margin: 6px 0 28px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input { padding: 12px 14px; font-size: 17px; text-align: center; border-radius: 12px; }
.login-form .btn { padding: 12px; font-size: 17px; border-radius: 12px; }
.fineprint { font-size: 12px; color: var(--text-3); margin: 22px 0 0; }

/* ---------- Responsive */
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-hero { grid-column: 1 / -1; }
  .server-row { grid-template-columns: 1fr auto 16px; }
  .add-form input { width: 100%; }
  .add-form { flex: 1; }
  .server-progress, .server-updated { display: none; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .user-name, .nav a { font-size: 13px; }
}
@media (max-width: 640px) {
  .topbar-inner { gap: 12px; padding: 0 14px; }
  .brand { font-size: 0; }
  .user-name { display: none; }
  .container { padding: 24px 14px 60px; }
  .check-sub { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
