:root {
  --bg: #0f1419;
  --bg-2: #151c24;
  --card: #1a2330;
  --line: #2a3645;
  --text: #e7eef7;
  --muted: #8fa0b3;
  --accent: #2dd4bf;
  --accent-dim: rgba(45, 212, 191, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(45, 212, 191, 0.08), transparent 55%),
    linear-gradient(180deg, #121820, var(--bg));
}

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100%;
}

.rail {
  background: rgba(18, 24, 32, 0.96);
  border-right: 1px solid var(--line);
  padding: 1.1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.brand { display: flex; gap: 0.7rem; align-items: center; margin-bottom: 0.5rem; }
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #2dd4bf, #0d9488);
  color: #042f2e; font-weight: 700; font-size: 0.85rem;
}
.brand-name { font-weight: 700; }
.brand-meta { color: var(--muted); font-size: 0.78rem; }

.rail-label {
  margin: 0.55rem 0 0.15rem;
  padding: 0 0.55rem;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.rail-nav { display: flex; flex-direction: column; gap: 0.3rem; }
.rail-btn {
  appearance: none; border: 1px solid transparent;
  background: transparent; color: var(--muted);
  text-align: left; padding: 0.65rem 0.75rem; border-radius: 10px;
  font: inherit; cursor: pointer; font-weight: 500;
}
.rail-btn:hover { background: var(--bg-2); color: var(--text); }
.rail-btn.active {
  background: var(--accent-dim);
  border-color: rgba(45, 212, 191, 0.35);
  color: var(--text);
}

.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pill {
  text-align: center;
  padding: 0.4rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 600;
}
.pill.idle { color: var(--muted); }
.pill.busy { color: var(--warn); border-color: rgba(251, 191, 36, 0.4); }
.pill.done { color: var(--ok); border-color: rgba(52, 211, 153, 0.4); }

.content {
  padding: 1.1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.kicker {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 600;
}
h1 { margin: 0.15rem 0; font-size: clamp(1.35rem, 2.5vw, 1.7rem); }
.sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.92rem; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
}
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}
.metric .label { color: var(--muted); font-size: 0.74rem; }
.metric .value { font-size: 1.3rem; font-weight: 700; margin-top: 0.15rem; }

.split {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(300px, 1.05fr);
  gap: 0.9rem;
  flex: 1;
  min-height: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 420px;
  overflow: hidden;
}
.card-title {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.row-between { display: flex; justify-content: space-between; align-items: center; }

.action-card { padding-bottom: 0.85rem; }
.view {
  display: none;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem;
}
.view.active { display: flex; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 500;
}
.hint-inline {
  color: #6f8196;
  font-weight: 400;
  font-size: 0.75rem;
}
input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  font: inherit;
}
textarea {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.4;
  resize: vertical;
  min-height: 5.5rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.55);
}

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.note { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary {
  background: linear-gradient(145deg, #2dd4bf, #14b8a6);
  border-color: transparent;
  color: #042f2e;
}
.btn.danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.tiny { padding: 0.28rem 0.5rem; font-size: 0.74rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.result {
  margin: 0 1rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 0.86rem;
}
.result.hidden { display: none; }

.log-card .log {
  margin: 0;
  padding: 0.85rem 1rem;
  flex: 1;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.45;
  color: #c5d0dc;
  white-space: pre-wrap;
  min-height: 280px;
}

/* Login gate */
.gate-body {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.gate-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
}
.gate-card .logo { margin: 0 auto 1rem; }
.gate-card h1 { margin: 0 0 0.35rem; font-size: 1.4rem; }
.gate-form {
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: left;
}
.gate-err { color: var(--danger); font-size: 0.88rem; margin: 0; }
.muted { color: var(--muted); margin: 0; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .rail-nav { flex-direction: row; flex-wrap: wrap; }
  .rail-bottom { flex-direction: row; flex-wrap: wrap; }
  .rail-bottom .btn.block { width: auto; flex: 1; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .card { min-height: 0; }
}

@media (max-width: 560px) {
  .content { padding: 0.85rem; }
  .metrics { grid-template-columns: 1fr 1fr; }
}
