:root{
  --bg:#0b1020;
  --panel:#0f1730;
  --panel2:#0c1328;
  --border:rgba(255,255,255,.08);
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.62);
  --muted2:rgba(255,255,255,.45);
  --shadow: 0 12px 36px rgba(0,0,0,.35);

  --green:#30d158;
  --amber:#ff9f0a;
  --red:#ff453a;
  --blue:#64d2ff;
  --gray:#8e8e93;

  --radius:16px;
  --radiusSm:12px;
  --gap:14px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color:var(--text);
  background:
    radial-gradient(1200px 700px at 18% 0%, rgba(100,210,255,.20), transparent 55%),
    radial-gradient(900px 650px at 90% 20%, rgba(48,209,88,.12), transparent 55%),
    radial-gradient(800px 600px at 60% 95%, rgba(255,69,58,.10), transparent 60%),
    var(--bg);
  font-family:var(--sans);
}

.app{ min-height:100%; display:flex; flex-direction:column; }

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  padding:18px 22px;
  display:flex;
  align-items:flex-start;
  gap:20px;
  border-bottom:1px solid var(--border);
  background: linear-gradient(to bottom, rgba(11,16,32,.92), rgba(11,16,32,.65));
  backdrop-filter: blur(10px);
}

.brand{ display:flex; align-items:center; gap:12px; min-width:260px; }
.logo{
  width:42px; height:42px;
  border-radius:14px;
  background: linear-gradient(135deg, rgba(100,210,255,.95), rgba(48,209,88,.85));
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.brand-title{ font-weight:750; letter-spacing:.2px; font-size:18px; }
.brand-sub{ color:var(--muted); font-size:12px; margin-top:2px; }

.controls{
  flex:1;
  display:grid;
  grid-template-columns: 1.6fr .9fr .9fr .9fr;
  gap: var(--gap);
}

.quicklinks{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.ql{
  text-decoration:none;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.82);
}
.ql:hover{ background: rgba(255,255,255,.07); }

.overview{ margin: 10px 0 14px; }

.embeds{ margin: 10px 0 18px; }
.embeds-head{ display:flex; align-items:center; justify-content:space-between; gap: 10px; margin-bottom: 10px; }
.embeds-title{ font-weight: 700; letter-spacing: .2px; }
.embeds-grid{
  --left: 50%;
  display:grid;
  grid-template-columns: var(--left) 10px 1fr;
  gap: 12px;
  align-items: stretch;
}
@media (max-width: 980px){
  .embeds-grid{ grid-template-columns: 1fr; }
  .splitter{ display:none; }
}
.embed-card{ border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.03); box-shadow: var(--shadow); overflow:hidden; }
.embed-top{ display:flex; align-items:center; justify-content:space-between; padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.embed-name{ font-weight: 650; font-size: 13px; }
.embed-link{ color: rgba(120,200,255,.92); text-decoration:none; font-size: 12px; }
.embed-frame{ width: 100%; height: min(62vh, 800px); min-height: 480px; border: 0; background: rgba(0,0,0,.15); }

/* Ultra-wide tuning (e.g. 3440x1440): keep embeds usable but leave room for worker cards */
@media (min-width: 1400px) and (min-height: 900px){
  .embed-frame{ height: min(55vh, 750px); min-height: 440px; }
}

.splitter{
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  cursor: col-resize;
}
.splitter:hover{ background: rgba(255,255,255,.07); }

.hidden{ display:none !important; }
.overview-card{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.overview-head{ display:flex; align-items:baseline; justify-content:space-between; gap: 10px; flex-wrap:wrap; }
.overview-title{ font-weight: 700; letter-spacing: .2px; }
.overview-sub{ color: rgba(255,255,255,.55); font-size: 12px; }
.overview-grid{
  margin-top: 10px;
  display:grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 980px){
  .overview-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px){
  .overview-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.ov-item{ padding: 10px 10px; border-radius: 14px; border: 1px solid rgba(255,255,255,.06); background: rgba(0,0,0,.18); }
.ov-k{ color: rgba(255,255,255,.55); font-size: 11px; margin-bottom: 4px; }
.ov-v{ font-family: var(--mono); font-size: 12px; color: rgba(255,255,255,.86); }

@media (max-width: 980px){
  .topbar{ align-items:stretch; flex-direction:column; }
  .brand{ min-width:0; }
  .controls{ grid-template-columns: 1fr 1fr; }
  .quicklinks{ justify-content:flex-start; }
}
@media (max-width: 560px){
  .controls{ grid-template-columns: 1fr; }
}

.control{ display:flex; flex-direction:column; gap:7px; }
.control-label{ color:var(--muted2); font-size:12px; letter-spacing:.2px; }

input[type="search"], select{
  width:100%;
  border-radius: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  outline:none;
}
select{ padding-right: 34px; }
input[type="search"]::placeholder{ color: rgba(255,255,255,.40); }

.control-field{ position:relative; }
.icon-btn{
  position:absolute;
  right:6px; top:50%; transform: translateY(-50%);
  width:32px; height:32px;
  border-radius: 10px;
  border:1px solid transparent;
  background: transparent;
  color: rgba(255,255,255,.65);
  font-size:18px;
  cursor:pointer;
}
.icon-btn:hover{ background: rgba(255,255,255,.06); border-color: var(--border); }

.bulk-actions{ display:flex; gap:10px; }
.btn{
  padding: 10px 12px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor:pointer;
  font-weight:650;
}
.btn:disabled{ opacity:.45; cursor:not-allowed; }
.btn:hover:not(:disabled){ background: rgba(255,255,255,.10); }
.btn-ghost{ background: rgba(255,255,255,.02); }

.main{ padding: 18px 22px 28px; flex:1; }

.summary{
  display:flex;
  flex-wrap:wrap;
  gap: 10px;
  margin: 2px 0 16px;
}
.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  font-size: 12px;
}
.pill b{ color: var(--text); font-weight:750; }
.dot{ width:8px; height:8px; border-radius:999px; background: var(--gray); }
.dot.running{ background: var(--green); }
.dot.idle{ background: var(--blue); }
.dot.starting{ background: var(--amber); }
.dot.error{ background: var(--red); }
.dot.offline{ background: var(--gray); }

.grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: var(--gap);
}
@media (max-width: 1200px){ .grid{ grid-template-columns: repeat(3, minmax(220px, 1fr)); } }
@media (max-width: 860px){ .grid{ grid-template-columns: repeat(2, minmax(220px, 1fr)); } }
@media (max-width: 520px){ .grid{ grid-template-columns: 1fr; } }

.card{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  box-shadow: var(--shadow);
  overflow:hidden;
  min-height: 168px;
  display:flex;
  flex-direction:column;
}
.card-top{
  padding: 14px 14px 10px;
  display:flex;
  gap: 12px;
  align-items:flex-start;
}
.check{
  width:18px; height:18px;
  border-radius:6px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  display:grid; place-items:center;
  margin-top:2px;
}
.check input{ width:14px; height:14px; }

.card-title{ flex:1; min-width:0; }
.name-row{ display:flex; align-items:center; gap:10px; }
.worker-name{
  font-weight:780;
  letter-spacing:.2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.tag{
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.75);
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .25px;
}
.badge .dot{ width:9px; height:9px; }
.badge.running{ background: rgba(48,209,88,.12); color: rgba(48,209,88,.95); border-color: rgba(48,209,88,.26); }
.badge.idle{ background: rgba(100,210,255,.12); color: rgba(100,210,255,.95); border-color: rgba(100,210,255,.26); }
.badge.starting{ background: rgba(255,159,10,.14); color: rgba(255,159,10,.95); border-color: rgba(255,159,10,.26); }
.badge.error{ background: rgba(255,69,58,.14); color: rgba(255,69,58,.95); border-color: rgba(255,69,58,.26); }
.badge.offline{ background: rgba(142,142,147,.12); color: rgba(255,255,255,.75); border-color: rgba(142,142,147,.26); }

.meta{
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.meta-item{ display:flex; gap:8px; align-items:center; min-width:0; }
.meta-k{ color: rgba(255,255,255,.45); width:44px; font-family: var(--mono); font-size: 11px; }
.meta-v{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.metrics{
  padding: 0 14px 12px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metric{
  border:1px solid var(--border);
  border-radius: var(--radiusSm);
  background: rgba(0,0,0,.12);
  padding: 10px;
}
.metric .h{ display:flex; justify-content:space-between; gap:10px; font-size:12px; color: rgba(255,255,255,.65); }
.metric .v{ font-weight:850; font-size:16px; margin-top:6px; }
.bar{
  height:8px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  margin-top: 8px;
  overflow:hidden;
}
.fill{ height:100%; border-radius:999px; width:0%; background: linear-gradient(90deg, rgba(100,210,255,.9), rgba(48,209,88,.9)); }
.fill.hot{ background: linear-gradient(90deg, rgba(255,159,10,.95), rgba(255,69,58,.95)); }

.card-actions{
  display:flex;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,.10);
}
.action{
  flex:1;
  padding: 10px 10px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor:pointer;
  font-weight: 750;
  font-size: 12px;
}
.action.secondary{ background: rgba(255,255,255,.02); color: rgba(255,255,255,.80); }
.action.danger{ background: rgba(255,69,58,.10); border-color: rgba(255,69,58,.22); color: rgba(255,69,58,.92); }
.action:hover{ background: rgba(255,255,255,.08); }

.footer{
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display:flex;
  justify-content:space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.kbd-hint{ color: rgba(255,255,255,.50); }
.kbd{
  display:inline-block;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.72);
}

.toast{
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15,23,48,.92);
  box-shadow: var(--shadow);
  color: rgba(255,255,255,.90);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events:none;
  transition: opacity .18s ease, transform .18s ease;
  max-width: 420px;
}
.toast.show{ opacity: 1; transform: translateY(0); }

/* Logs dialog */
.dialog{
  width: min(980px, calc(100vw - 24px));
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(9, 12, 18, .98);
  color: rgba(255,255,255,.92);
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.dialog::backdrop{ background: rgba(0,0,0,.65); }
.dialog-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.dialog-title{ font-weight: 650; font-size: 13px; letter-spacing: .2px; }
.dialog-body{
  margin: 0;
  padding: 14px;
  max-height: 70vh;
  overflow:auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  color: rgba(255,255,255,.86);
}
