/* VPS Panel : interface iPhone. Sombre par défaut, clair si l'iPhone est en mode clair. */
:root {
  --bg: #0c1320; --surface: #141d2c; --raised: #1b2739; --line: #253248; --text: #e7edf6; --muted: #8b9ab0; --faint: #5d6b80;
  --accent: #ffb547; --accent-ink: #1b1200; --ok: #3ad29a; --bad: #ff6b6b; --warn: #ffb547; --info: #7cc8f8;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --r: 14px; --tab-h: 58px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #eef1f5; --surface: #ffffff; --raised: #f5f7fa; --line: #dde3eb; --text: #0e1624; --muted: #5d6a7d; --faint: #93a0b2;
    --accent: #c77700; --accent-ink: #ffffff; --ok: #12925f; --bad: #d63a3a; --warn: #b86e00; --info: #1673b8; color-scheme: light; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 var(--sans); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- structure ---------- */
#app { min-height: 100%; padding: calc(var(--safe-t) + 8px) 0 calc(var(--tab-h) + var(--safe-b) + 16px); }
.view { padding: 0 16px; max-width: 720px; margin: 0 auto; }
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 10px 0 14px; }
h1 { font-size: 32px; line-height: 1.1; margin: 0; letter-spacing: -0.02em; font-weight: 750; }
h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 22px 4px 8px; letter-spacing: 0.01em; }
.back { background: none; border: 0; color: var(--accent); padding: 6px 0; font-size: 17px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

.group { background: var(--surface); border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 50px; border-top: 1px solid var(--line); background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; }
.row:first-child { border-top: 0; }
button.row { cursor: pointer; }
button.row:active { background: var(--raised); }
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { color: var(--muted); font-size: 14px; flex: none; text-align: right; }
.chev::after { content: "›"; color: var(--faint); font-size: 22px; line-height: 1; margin-left: 4px; }

.dot { display: inline-block; vertical-align: middle; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.dot.warn { background: var(--warn); }

/* ---------- boutons ---------- */
.btn { border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 600; background: var(--raised); color: var(--text); cursor: pointer; min-height: 44px; border: 1px solid var(--line); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { background: color-mix(in srgb, var(--bad) 16%, var(--surface)); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: 0.45; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns.full .btn { flex: 1 1 0; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

input[type=text], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; background: var(--raised); border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; min-height: 44px; font-size: 16px; }
textarea { font-family: var(--mono); font-size: 13px; line-height: 1.45; min-height: 50vh; resize: vertical; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
label.field { display: block; margin: 10px 0; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin: 0 2px 6px; }
.code-input { font-family: var(--mono); font-size: 26px !important; letter-spacing: 0.3em; text-align: center; }

/* ---------- tableau de bord ---------- */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.metric .label { font-size: 13px; color: var(--muted); }
.metric .value { font-family: var(--mono); font-size: 34px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric .value small { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.metric .note { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.spark { grid-column: 1 / -1; width: 100%; height: 64px; display: block; }
.spark .cpu { stroke: var(--accent); fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark .cpu-fill { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: none; }
.spark .ram { stroke: var(--info); fill: none; stroke-width: 1.5; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.legend { grid-column: 1 / -1; display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: -8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.meter { height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; margin-top: 6px; border: 1px solid var(--line); }
.meter > b { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.meter > b.warn { background: var(--warn); } .meter > b.bad { background: var(--bad); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); margin-bottom: 8px; font-size: 15px; border: 1px solid; cursor: pointer; width: 100%; text-align: left; }
.alert.danger { background: color-mix(in srgb, var(--bad) 13%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.alert.warn { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.alert.info { background: color-mix(in srgb, var(--info) 12%, var(--surface)); border-color: color-mix(in srgb, var(--info) 35%, transparent); }

/* ---------- consoles, logs, terminal ---------- */
.console { background: #070b12; color: #d9e2ee; font: 12.5px/1.45 var(--mono); border-radius: var(--r); padding: 10px 12px; overflow: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--line); }
@media (prefers-color-scheme: light) { .console { background: #0e1624; } }
.console.tall { height: calc(100dvh - 300px - var(--safe-t) - var(--safe-b)); min-height: 260px; }
.console mark { background: #ffb54755; color: inherit; border-radius: 2px; }
.console .err { color: #ff9b9b; } .console .warnl { color: #ffd38a; } .console .dim { color: #7f8da3; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input { flex: 1; }
#term-wrap { position: fixed; inset: calc(var(--safe-t) + 52px) 0 calc(var(--tab-h) + var(--safe-b) + 46px) 0; background: #070b12; }
#term { position: absolute; inset: 4px 6px; }
#term-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; }
#term-fallback .console { flex: 1; border-radius: 0; border: 0; }
.keybar { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); display: flex; gap: 6px; padding: 6px 8px; background: var(--surface); border-top: 1px solid var(--line); overflow-x: auto; }
.keybar button { flex: none; min-width: 44px; min-height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--raised); font: 600 14px var(--mono); }
.keybar button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- barre d'onglets ---------- */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); z-index: 20; }
nav.tabs button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); cursor: pointer; }
nav.tabs button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav.tabs button[aria-current="page"] { color: var(--accent); }

/* ---------- feuilles (modales) ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 10px 16px calc(16px + var(--safe-b)); max-height: 92dvh; overflow: auto; border: 1px solid var(--line); border-bottom: 0; animation: up .2s ease-out; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 4px 0 6px; font-size: 20px; }
.sheet p { margin: 6px 0 12px; color: var(--muted); }
.sheet .console { max-height: 50dvh; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-back { animation: none; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 14px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- connexion ---------- */
.login { max-width: 400px; margin: 0 auto; padding: calc(var(--safe-t) + 40px) 20px 40px; }
.login .mark { width: 64px; height: 64px; border-radius: 16px; display: block; margin-bottom: 18px; }
.login h1 { margin-bottom: 6px; }
.login .or { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 4px; }
.login .error { color: var(--bad); min-height: 22px; margin: 8px 2px; font-size: 15px; }

/* ---------- fichiers ---------- */
.crumbs { display: flex; gap: 2px; overflow-x: auto; font: 13px var(--mono); padding: 4px 0 8px; scrollbar-width: none; }
.crumbs button { background: none; border: 0; color: var(--accent); padding: 4px 3px; white-space: nowrap; cursor: pointer; }
.ficon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--raised); font-size: 15px; }
.ficon.dir { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; cursor: pointer; text-align: left; min-height: 92px; }
.tile:active { background: var(--raised); }
.tile .ic { font-size: 22px; }
.tile b { font-size: 16px; } .tile span { font-size: 13px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
