/* ASTRA PANEL — noir étoilé, texte blanc lumineux (DA ASTRA HUB) */
:root {
  --bg: #050506;
  --card: rgba(255, 255, 255, 0.035);
  --card-strong: rgba(18, 18, 22, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ececf1;
  --muted: #8e8e9a;
  --white: #ffffff;
  --glow: 0 0 8px rgba(255, 255, 255, 0.55), 0 0 22px rgba(255, 255, 255, 0.22);
  --glow-soft: 0 0 10px rgba(255, 255, 255, 0.18);
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #ff5d5d;
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Ciel étoilé */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1.4px 1.4px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 140px, rgba(255,255,255,.8), transparent),
    radial-gradient(1px 1px at 160px 60px, rgba(255,255,255,.6), transparent),
    radial-gradient(1.6px 1.6px at 230px 200px, #fff, transparent),
    radial-gradient(1px 1px at 280px 25px, rgba(255,255,255,.55), transparent),
    radial-gradient(1.2px 1.2px at 340px 150px, rgba(255,255,255,.75), transparent),
    radial-gradient(1px 1px at 390px 240px, rgba(255,255,255,.5), transparent);
  background-size: 420px 270px;
  animation: twinkle 6s ease-in-out infinite alternate;
}
.sky::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% -10%, rgba(255,255,255,.07), transparent 55%),
              radial-gradient(ellipse at 100% 100%, rgba(255,255,255,.035), transparent 50%);
}
@keyframes twinkle { from { opacity: .75; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sky { animation: none; } }

a { color: var(--white); }
h1, h2, h3 { color: var(--white); margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 30px; text-shadow: var(--glow); }
h2 { font-size: 17px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.glow { text-shadow: var(--glow); }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 38px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  font: 600 14px Inter, system-ui, sans-serif; white-space: nowrap;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); color: var(--text);
  transition: background .15s, box-shadow .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.28); }
.btn:focus-visible, .input:focus-visible, .icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn.primary { background: #fff; color: #000; border-color: #fff; box-shadow: 0 0 14px rgba(255,255,255,.28); }
.btn.primary:hover { background: #e9e9e9; }
.btn.danger { color: var(--bad); border-color: rgba(255, 93, 93, .45); background: rgba(255,93,93,.06); }
.btn.danger:hover { background: rgba(255,93,93,.14); }
.btn.solid-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; display: inline-grid; place-items: center;
}
.icon-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.icon-btn.danger:hover { color: var(--bad); background: rgba(255,93,93,.1); }
svg.i { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Champs */
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px;
  background: rgba(0,0,0,.45); border: 1px solid var(--line-strong); color: var(--text);
  font: 14px Inter, system-ui, sans-serif;
}
textarea.input { height: auto; padding: 10px 12px; font-family: var(--mono); font-size: 13px; resize: vertical; }
.input:focus { border-color: rgba(255,255,255,.45); box-shadow: 0 0 0 3px rgba(255,255,255,.07); outline: none; }
label.field { display: grid; gap: 6px; }
label.field > span { font-weight: 600; color: var(--white); font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; }
.prefix-input { display: flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: rgba(0,0,0,.45); }
.prefix-input .prefix { padding: 0 12px; display: grid; place-items: center; color: var(--muted); border-right: 1px solid var(--line); font-family: var(--mono); font-size: 13px; }
.prefix-input .input { border: 0; border-radius: 0; background: transparent; }

/* Interrupteur */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: rgba(255,255,255,.12); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #9a9aa6; transition: transform .15s, background .15s; }
.switch input:checked + .track { background: rgba(255,255,255,.85); box-shadow: 0 0 12px rgba(255,255,255,.3); }
.switch input:checked + .track::after { transform: translateX(18px); background: #000; }
.switch input:focus-visible + .track { outline: 2px solid #fff; outline-offset: 2px; }

/* Cartes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(2px); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-body { padding: 20px; }
.stack { display: grid; gap: 18px; }

/* Connexion */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(400px, 100%); padding: 34px 30px; text-align: center; }
.brand-big { font-size: 34px; font-weight: 800; letter-spacing: .04em; color: #fff; text-shadow: var(--glow); margin: 10px 0 4px; }
.login form { display: grid; gap: 14px; margin-top: 24px; text-align: left; }
.star { display: inline-block; filter: drop-shadow(0 0 8px rgba(255,255,255,.75)); }

/* Mise en page avec barre latérale */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line); background: rgba(5,5,6,.72); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; font-weight: 800; letter-spacing: .06em; color: #fff; text-shadow: var(--glow); font-size: 18px; text-decoration: none; }
.bot-switch { margin: 4px 0 14px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav a.active { color: #fff; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); text-shadow: var(--glow-soft); }
.nav a.active svg { filter: drop-shadow(0 0 6px rgba(255,255,255,.6)); }
.sidebar .bottom { margin-top: auto; display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 12px; }
.main { padding: 30px 34px 50px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.power { display: flex; gap: 8px; flex-wrap: wrap; }

/* Statut */
.dot { width: 9px; height: 9px; border-radius: 50%; background: #6b7280; display: inline-block; flex: none; }
.dot.running { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.starting, .dot.stopping { background: var(--warn); box-shadow: 0 0 10px var(--warn); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .4; } }
.status-text { display: inline-flex; align-items: center; gap: 8px; text-transform: capitalize; }

/* Cartes de stats */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 14px 16px; display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.stat .k { color: var(--muted); white-space: nowrap; }
.stat .v { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Console */
.console { display: flex; flex-direction: column; height: min(62vh, 620px); min-height: 320px; overflow: hidden; }
.console-out {
  flex: 1; overflow: auto; padding: 14px 16px; font: 12.5px/1.55 var(--mono); color: #d9d9e1;
  background: rgba(0,0,0,.55); white-space: pre-wrap; word-break: break-word;
}
.console-out .panel-line { color: #fff; text-shadow: var(--glow-soft); }
.console-out .cmd-line { color: var(--muted); }
.console-out .err-line { color: #ff9b9b; }
.console-in { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 0 14px; background: rgba(0,0,0,.4); }
.console-in .input { border: 0; background: transparent; font-family: var(--mono); font-size: 13px; padding: 0; }
.console-in .input:focus { box-shadow: none; }
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.chart canvas { width: 100%; height: 150px; display: block; }
.chart .card-head { padding: 12px 16px; }
.chart .card-body { padding: 10px 12px 12px; }

/* Liste des bots */
.grid-bots { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.bot-card { padding: 18px; display: grid; gap: 14px; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.bot-card:hover { border-color: rgba(255,255,255,.28); box-shadow: 0 0 20px rgba(255,255,255,.07); transform: translateY(-1px); }
.bot-card .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.bot-card .name { font-weight: 700; color: #fff; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-card .top .name { min-width: 0; }
.bot-card .top .status-text { flex-shrink: 0; }
.grid-bots > .card { min-width: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--muted); }
.meters { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.meter .k { font-size: 11.5px; color: var(--muted); }
.meter .v { color: #fff; font-weight: 600; font-size: 13px; }
.host { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.host-stat { display: grid; gap: 6px; align-items: start; }
.host-stat .v { font-variant-numeric: tabular-nums; }
.mini-bar { height: 4px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.mini-bar > div { height: 100%; width: 0; background: #fff; box-shadow: 0 0 8px rgba(255,255,255,.7); transition: width .6s ease; }
.mini-bar.warn > div { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.mini-bar.crit > div { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.empty { padding: 50px 20px; text-align: center; display: grid; gap: 14px; justify-items: center; }

/* Fichiers */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .group { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.crumbs button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 6px; font: inherit; }
.crumbs button:hover { color: #fff; background: rgba(255,255,255,.06); }
.crumbs .sep { color: #4a4a55; }
.files { width: 100%; border-collapse: collapse; }
.files th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.files td { padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
.files tr:hover td { background: rgba(255,255,255,.025); }
.files tr.selected td { background: rgba(255,255,255,.06); }
.files .fname { display: flex; align-items: center; gap: 10px; color: #fff; cursor: pointer; min-width: 0; }
.files .fname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .fname:hover span { text-decoration: underline; }
.files .ficon { color: var(--muted); }
.files .ficon.dir { color: #fff; filter: drop-shadow(0 0 5px rgba(255,255,255,.45)); }
.files .actions { text-align: right; white-space: nowrap; }
.files input[type=checkbox] { accent-color: #fff; width: 15px; height: 15px; }
.col-size, .col-date { color: var(--muted); white-space: nowrap; font-size: 13px; }
.drop-host { position: relative; }
.dropzone {
  position: absolute; inset: 0; z-index: 5; border: 2px dashed rgba(255,255,255,.6); border-radius: var(--radius);
  background: rgba(5,5,6,.85); display: none; place-items: center; text-align: center; gap: 8px;
  box-shadow: inset 0 0 40px rgba(255,255,255,.08);
}
.drop-host.dragging .dropzone { display: grid; }
.dropzone .big { font-size: 20px; font-weight: 700; color: #fff; text-shadow: var(--glow); }
.upload-bar { padding: 10px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.progress { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.7); transition: width .2s; }
.editor { width: 100%; min-height: 62vh; border: 0; border-radius: 0 0 var(--radius) var(--radius); background: rgba(0,0,0,.55); color: #e6e6ee; font: 13px/1.6 var(--mono); padding: 16px; resize: vertical; tab-size: 2; }
.editor:focus { outline: none; }

/* Variables */
.env-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: 8px; align-items: center; }
.limits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.danger-zone { border-color: rgba(255, 93, 93, .3); }

/* Fenêtres, notifications */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(3px); }
.modal { width: min(460px, 100%); background: var(--card-strong); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 30px rgba(255,255,255,.05); }
.modal .card-body { display: grid; gap: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--card-strong); border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); display: flex; gap: 10px; align-items: flex-start; animation: in .2s ease-out; }
.toast.error { border-color: rgba(255,93,93,.5); }
.toast.error svg { color: var(--bad); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.banner { padding: 12px 16px; border-radius: 10px; border: 1px solid rgba(251,191,36,.4); background: rgba(251,191,36,.07); color: #fde68a; margin-bottom: 18px; }

/* Téléphone / petite fenêtre */
@media (max-width: 1100px) {
  .charts { grid-template-columns: 1fr; }
  .host { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; position: static; height: auto; flex-direction: column; padding: 14px 16px; }
  .sidebar .nav { display: flex; gap: 4px; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .sidebar .bottom { flex-direction: row; display: flex; border-top: 0; padding-top: 0; margin-top: 8px; }
  .brand { padding-bottom: 8px; }
  .main { padding: 20px 16px 40px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .limits, .two { grid-template-columns: 1fr; }
  .col-date { display: none; }
  h1 { font-size: 24px; }
}
@media (max-width: 520px) {
  .stats, .host { grid-template-columns: 1fr; }
  .env-row { grid-template-columns: 1fr auto auto; }
  .env-row .input:first-child { grid-column: 1 / -1; }
  .col-size { display: none; }
  .toolbar .group .label { display: none; }
}

.port-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; color: var(--text); }
.port-chip .icon-btn { width: 26px; height: 26px; }
