:root {
  --bg: #07100e;
  --panel: #0d1714;
  --panel-2: #111e1a;
  --line: #22332e;
  --line-soft: #172722;
  --text: #eef7f3;
  --muted: #82958e;
  --mint: #62f6bc;
  --mint-strong: #22d995;
  --mint-dim: rgba(98, 246, 188, .11);
  --amber: #f6c761;
  --red: #ff726f;
  --blue: #70a9ff;
  --radius: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, .35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { min-width: 320px; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.compact { font-size: 12px; }
.eyebrow { margin: 0 0 6px; color: var(--mint); font-size: 10px; letter-spacing: .18em; font-weight: 800; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 224px; display: flex; flex-direction: column; padding: 24px 16px 18px; border-right: 1px solid var(--line); background: #091310; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 25px; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--mint-strong); border-radius: 10px; color: #04100b; background: var(--mint); font-weight: 950; box-shadow: 0 0 28px rgba(98, 246, 188, .14); }
.brand strong { display: block; font-size: 14px; letter-spacing: .13em; }
.brand span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
nav { display: flex; flex-direction: column; gap: 4px; }
nav p { margin: 22px 10px 7px; color: #52655f; font-size: 9px; letter-spacing: .17em; text-transform: uppercase; font-weight: 800; }
nav a { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 0 12px; border: 1px solid transparent; border-radius: 9px; color: #a3b4ae; text-decoration: none; font-size: 13px; font-weight: 650; }
nav a span { width: 18px; color: #657871; text-align: center; font-size: 15px; }
nav a:hover { color: var(--text); background: #101c18; }
nav a.active { color: var(--mint); border-color: #1b3b31; background: var(--mint-dim); }
nav a.active span { color: var(--mint); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 13px 10px 0; border-top: 1px solid var(--line-soft); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 11px; }
.sidebar-foot small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 5px rgba(98, 246, 188, .08); }

.workspace { grid-column: 2; min-width: 0; }
.topbar { height: 88px; position: sticky; top: 0; z-index: 12; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(7, 16, 14, .91); backdrop-filter: blur(15px); }
.topbar h1 { margin: 0; font-size: 21px; line-height: 1; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--panel); cursor: pointer; }
.icon-button:hover { border-color: #39534a; background: var(--panel-2); }
.mobile-only { display: none; }
main { max-width: 1540px; margin: 0 auto; padding: 28px 34px 60px; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h2 { margin: 0 0 6px; font-size: 19px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--panel-2); cursor: pointer; font-weight: 750; font-size: 12px; }
.button:hover { border-color: #496159; transform: translateY(-1px); }
.button.primary { border-color: var(--mint-strong); color: #042117; background: var(--mint); }
.button.primary:hover { background: #82f9ca; }
.button.danger { border-color: rgba(255, 114, 111, .35); color: var(--red); background: rgba(255, 114, 111, .08); }
.button.ghost { background: transparent; }
.button.small { min-height: 31px; padding: 0 10px; font-size: 11px; }
.button.wide { width: 100%; }
.button:disabled { opacity: .42; cursor: not-allowed; transform: none; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric { min-height: 112px; position: relative; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, #101d19, #0b1512); }
.metric::after { content: ""; position: absolute; right: -32px; bottom: -50px; width: 110px; height: 110px; border: 1px solid rgba(98, 246, 188, .08); border-radius: 50%; }
.metric .label { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 13px; font-size: 27px; letter-spacing: -.04em; }
.metric small { display: block; margin-top: 7px; color: #667a72; font-size: 10px; }
.metric.highlight { border-color: #28503f; background: linear-gradient(145deg, rgba(98,246,188,.12), #0c1814); }
.metric.highlight strong { color: var(--mint); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(290px, .6fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 1px 0 rgba(255,255,255,.015) inset; }
.panel-head { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 17px; border-bottom: 1px solid var(--line-soft); }
.panel-head h3 { margin: 0; font-size: 12px; letter-spacing: .02em; }
.panel-body { padding: 17px; }
.panel + .panel { margin-top: 14px; }
.resource-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.resource-card { min-height: 180px; display: flex; flex-direction: column; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(145deg, var(--panel-2), #0c1613); }
.resource-card:hover { border-color: #365149; }
.resource-card .card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.resource-card h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; font-size: 13px; white-space: nowrap; }
.resource-card .identity { margin-top: 6px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; overflow-wrap: anywhere; }
.resource-card .facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 17px 0; }
.fact span, .detail-pair span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.fact strong, .detail-pair strong { display: block; margin-top: 5px; font-size: 12px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft); }

.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border: 1px solid #33443e; border-radius: 99px; color: #a8b7b2; background: rgba(255,255,255,.025); font-size: 9px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.badge.success, .badge.ready, .badge.connected, .badge.running, .badge.monitoring, .badge.succeeded, .badge.completed { border-color: rgba(98,246,188,.25); color: var(--mint); background: var(--mint-dim); }
.badge.warning, .badge.partial, .badge.stopping, .badge.retry_wait, .badge.invalidating { border-color: rgba(246,199,97,.26); color: var(--amber); background: rgba(246,199,97,.08); }
.badge.danger, .badge.failed, .badge.invalidated, .badge.stopped { border-color: rgba(255,114,111,.27); color: var(--red); background: rgba(255,114,111,.075); }
.badge.info, .badge.queued, .badge.starting { border-color: rgba(112,169,255,.25); color: var(--blue); background: rgba(112,169,255,.08); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 11px 13px; color: #60736c; text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line); }
td { padding: 12px 13px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(98,246,188,.025); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.right { text-align: right; }

.progress { height: 6px; overflow: hidden; border-radius: 99px; background: #17241f; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--mint); transition: width .35s ease; }
.progress.amber span { background: var(--amber); }
.progress.red span { background: var(--red); }
.progress-row { display: grid; grid-template-columns: 130px 1fr 54px; align-items: center; gap: 12px; margin: 13px 0; font-size: 11px; }
.progress-row strong { text-align: right; }

.task-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(270px, .8fr); gap: 14px; margin-bottom: 14px; }
.task-title { padding: 21px; }
.task-title h2 { margin: 7px 0 9px; font-size: 21px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 10px; }
.task-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 20px; }
.stage-track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 17px 0 4px; }
.stage-node { position: relative; padding: 10px 8px; border: 1px solid var(--line); border-radius: 8px; color: #64766f; font-size: 9px; text-align: center; }
.stage-node.done { color: var(--mint); border-color: #295240; background: var(--mint-dim); }
.stage-node.current { color: #06150f; border-color: var(--mint); background: var(--mint); font-weight: 850; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.detail-pair { min-width: 0; padding-bottom: 11px; border-bottom: 1px solid var(--line-soft); }
.detail-pair strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { min-height: 270px; display: grid; place-items: center; padding: 40px; border: 1px dashed #294038; border-radius: var(--radius); text-align: center; }
.empty .symbol { margin: auto; width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; color: var(--mint); background: var(--panel); font-size: 21px; }
.empty h3 { margin: 15px 0 7px; font-size: 14px; }
.empty p { max-width: 450px; margin: 0 auto 18px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.page-loading { min-height: 380px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 12px; }
.page-loading span { width: 15px; height: 15px; border: 2px solid #294139; border-top-color: var(--mint); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(0, 6, 4, .77); backdrop-filter: blur(7px); }
.modal { width: min(620px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; border: 1px solid #2d463d; border-radius: 16px; background: #0d1714; box-shadow: var(--shadow); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); background: #0d1714; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 20px; border-top: 1px solid var(--line); }
label { display: block; margin-bottom: 15px; color: #a9b8b3; font-size: 11px; font-weight: 700; }
input, textarea, select { width: 100%; margin-top: 7px; padding: 10px 11px; border: 1px solid #2a3e37; border-radius: 8px; outline: none; color: var(--text); background: #08110f; font-size: 12px; }
input:focus, textarea:focus, select:focus { border-color: var(--mint-strong); box-shadow: 0 0 0 3px rgba(98,246,188,.07); }
textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.55; }
input[type="file"] { padding: 8px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 12px; }
.form-help { margin: -6px 0 15px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.form-error { min-height: 16px; margin: 8px 0 0; color: var(--red); font-size: 11px; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 50% 0, rgba(98,246,188,.09), transparent 35%), var(--bg); }
.auth-card { width: min(390px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.auth-card .brand-mark { margin-bottom: 25px; }
.auth-card h1 { margin: 0 0 8px; font-size: 23px; }
.auth-card > p.muted { margin: 0 0 24px; font-size: 11px; line-height: 1.7; }

.toast-root { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { max-width: 380px; padding: 12px 14px; border: 1px solid #345047; border-radius: 10px; color: var(--text); background: #10201a; box-shadow: var(--shadow); font-size: 11px; animation: toast-in .2s ease; }
.toast.error { border-color: rgba(255,114,111,.4); background: #241313; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.log-shell { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #050a08; }
.log-toolbar { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); background: #0b1411; }
.log-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.log-view { height: calc(100vh - 230px); min-height: 420px; margin: 0; overflow: auto; padding: 16px; color: #a9e5cb; font: 11px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .grid-2, .task-hero { grid-template-columns: 1fr; }
  .task-controls { justify-content: flex-start; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .workspace { min-width: 0; }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { height: 78px; padding: 0 16px; gap: 10px; }
  .topbar > div:nth-child(2) { flex: 1; }
  .top-actions .compact { display: none; }
  main { padding: 20px 16px 45px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 100px; }
  .resource-grid, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .detail-list { grid-template-columns: 1fr; }
  .stage-track { grid-template-columns: 1fr; }
  .stage-node { text-align: left; }
  .progress-row { grid-template-columns: 100px 1fr 44px; }
}
