:root {
  --bg: #f5f6fb; --surface: #fff; --line: #e5e7f1; --ink: #12152b; --muted: #6b7089;
  --brand: #4f46e5; --brand-2: #7c3aed; --brand-soft: #eef0ff;
  --green: #128a5b; --green-soft: #e3f6ec; --red: #c62b45; --red-soft: #fdecef;
  --amber: #a15c00; --amber-soft: #fff3dc; --uat: #0e7490; --uat-soft: #e0f4f8;
  --shadow: 0 1px 2px rgba(18,21,43,.05), 0 10px 30px rgba(18,21,43,.07);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink); -webkit-font-smoothing: antialiased;
  background: radial-gradient(900px 380px at 6% -6%, #e8e9ff 0%, transparent 60%),
              radial-gradient(700px 360px at 98% -4%, #efe7ff 0%, transparent 58%), var(--bg);
  background-attachment: fixed; min-height: 100vh;
}
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
a { color: var(--brand); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---- buttons / inputs ---- */
button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px; padding: 9px 15px;
  color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 1px 2px rgba(79,70,229,.3), 0 4px 12px rgba(79,70,229,.2);
  transition: transform .12s, filter .12s;
}
button:hover { filter: brightness(1.07); transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }
button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
button.ghost:hover { background: #fafbff; border-color: #cfd3f3; }
button.danger { background: linear-gradient(135deg, #e11d48, #be123c); box-shadow: 0 4px 12px rgba(225,29,72,.25); }
button.sm { padding: 6px 11px; font-size: 13px; }
button.link { background: none; box-shadow: none; color: var(--brand); padding: 0; font-weight: 600; font-size: 13px; }
input, select {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid #d9dcec; border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79,70,229,.14); }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; color: #3b4060; }

/* ---- shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 24px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; }
.logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 4px 12px rgba(79,70,229,.35); }
.tabs { display: flex; gap: 4px; padding: 4px; background: #eceefa; border-radius: 12px; }
.tabs button { background: transparent; color: #5a6082; box-shadow: none; padding: 6px 14px; font-size: 14px; }
.tabs button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(18,21,43,.08); }
.chip { font-size: 12px; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: #eef0f5; color: var(--muted); }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
main { max-width: 1240px; margin: 0 auto; padding: 24px 24px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.banner { padding: 12px 16px; border-radius: 12px; background: var(--amber-soft); color: var(--amber); margin-bottom: 18px; font-size: 14px; }

/* ---- app cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; }
.card h2 { font-size: 18px; }
.card .repo { font-size: 13px; }
.envs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.env { border: 1px solid var(--line); border-radius: 14px; padding: 13px; display: flex; flex-direction: column; gap: 8px; background: #fcfcff; }
.env .tag { font-size: 11px; font-weight: 750; letter-spacing: .08em; padding: 2px 8px; border-radius: 6px; }
.env.uat .tag { background: var(--uat-soft); color: var(--uat); }
.env.prod .tag { background: #ede9fe; color: #5b21b6; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #bbb; }
.dot.ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.dot.bad { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.ver code { background: #eef0f5; padding: 2px 7px; border-radius: 6px; font-size: 13px; }
.badge { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.run { background: var(--brand-soft); color: var(--brand); }
.badge.idle { background: #eef0f5; color: var(--muted); }
.env .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.pending { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--amber-soft); color: var(--amber); font-size: 13px; }
.pending.clean { background: var(--green-soft); color: var(--green); }
.pending ul { margin: 6px 0 0; padding-left: 18px; color: #5c4400; }
@keyframes pulse { 50% { opacity: .45; } }
.badge.run { animation: pulse 1.4s infinite; }

/* ---- tables ---- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f8f9fe; padding: 11px 14px; }
.table td { padding: 11px 14px; border-top: 1px solid #eef0f8; font-size: 14px; vertical-align: middle; }
.table tr:hover td { background: #fafbff; }
.scroll { overflow-x: auto; }

/* ---- modal + drawer ---- */
.back { position: fixed; inset: 0; background: rgba(14,16,38,.55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(18,21,43,.25); animation: pop .16s ease-out; }
.modal.wide { max-width: 720px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.warn-box { background: var(--red-soft); color: var(--red); padding: 12px 14px; border-radius: 12px; font-size: 14px; margin: 12px 0; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: #fff; z-index: 60; box-shadow: -20px 0 60px rgba(18,21,43,.2); display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer header { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer .body { padding: 18px 22px; overflow: auto; flex: 1; }
pre.log { background: #0f1226; color: #d7dbff; padding: 14px; border-radius: 12px; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; margin: 12px 0 0; }
.steps { display: flex; gap: 6px; margin: 12px 0 0; flex-wrap: wrap; }
.err { color: var(--red); font-size: 14px; margin-top: 10px; }

/* ---- sign-in ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 30px; }
.login h1 { font-size: 24px; margin: 14px 0 4px; }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .envs { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  main { padding: 16px 14px 60px; }
}
