:root{
  --bg: linear-gradient(180deg,#f4fbf6,#eaf6ef);
  --card:#ffffff;
  --text:#1f2a24;
  --muted:#4b5b52;
  --border:#d6e6dd;
  --green:#2C6E49;
  --green-light:#8ACF57;
  --shadow:0 12px 30px rgba(0,0,0,.08);
  --radius:18px;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
}

/* HEADER */
header{
  background:#ffffff;
  border-bottom:3px solid var(--green-light);
  box-shadow:var(--shadow);
}
.top{
  max-width:1100px;
  margin:0 auto;
  padding:18px 16px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
.brand{
  display:flex;
  align-items:center;
  gap:14px;
}
.logo{
  width:54px;height:54px;border-radius:14px;overflow:hidden;
  border:2px solid var(--green-light);
  box-shadow:var(--shadow);
  background:#fff;
  display:flex;align-items:center;justify-content:center;
}
.logo img{width:100%;height:100%;object-fit:cover}
.titles h1{margin:0;font-size:20px;color:var(--green)}
.titles .sub{font-size:13px;color:var(--muted)}

.pills{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.pill{
  padding:6px 12px;border-radius:999px;font-size:12px;font-weight:800;
  background:#ffffff;border:1px solid var(--border);
}
.pill.ok{border-color:rgba(44,110,73,.25)}
.pill.warn{border-color:rgba(212,175,55,.35)}
.pill.bad{border-color:rgba(180,60,60,.35)}

/* MAIN */
main{
  max-width:1100px;
  margin:25px auto;
  padding:0 16px 40px;
  display:grid;
  gap:18px;
  grid-template-columns:1fr 1fr;
}
@media(max-width:900px){
  main{grid-template-columns:1fr;}
}

.card{
  background:var(--card);
  border-radius:var(--radius);
  padding:18px;
  box-shadow:var(--shadow);
  border:1px solid var(--border);
}

.card h2{
  margin:0 0 14px;
  font-size:16px;
  color:var(--green);
}

.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}

input,button{
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  font-size:14px;
}
input{flex:1;min-width:220px}
button{
  cursor:pointer;
  background:var(--green);
  color:#fff;
  border:none;
  font-weight:800;
  transition:all .2s ease;
}
button:hover{background:var(--green-light);color:#1f2a24}
button.secondary{
  background:#fff;color:var(--green);
  border:1px solid var(--green-light);
}
button.secondary:hover{background:#f2fbf5}

.muted{color:var(--muted);font-size:13px}

/* VIDEO LIST */
.list{margin-top:14px;max-height:540px;overflow:auto;padding-right:4px}
.item{
  display:grid;
  grid-template-columns: 140px 1fr;
  gap:12px;
  padding:12px;
  border-radius:14px;
  background:#f9fdfb;
  border:1px solid var(--border);
  margin-bottom:10px;
}
@media(max-width:520px){
  .item{grid-template-columns:1fr}
}
.thumb{
  width:100%;
  aspect-ratio:16/9;
  border-radius:12px;
  overflow:hidden;
  border:1px solid var(--border);
  background:#e9f3ed;
}
.thumb img{width:100%;height:100%;object-fit:cover;display:block}
.item b{display:block;margin-bottom:6px}
.meta{font-size:12px;color:var(--muted)}
.actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}

/* STATE JSON VIEW */
.stateTop{
  display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;
  margin-bottom:10px;
}
.stateBox{
  background:#f9fdfb;
  border-radius:14px;
  border:1px solid var(--border);
  padding:12px;
}
pre{
  margin:0;
  font-size:13px;
  line-height:1.35;
  max-height:520px;           /* important */
  overflow:auto;              /* important */
  white-space:pre;
}
pre::-webkit-scrollbar{height:10px;width:10px}
pre::-webkit-scrollbar-thumb{background:#cfe5d7;border-radius:999px}
pre::-webkit-scrollbar-track{background:#eff8f2;border-radius:999px}

.dialog{
  position:fixed; inset:0;
  background:rgba(0,0,0,.45);
  display:none;
  align-items:center;justify-content:center;
  padding:14px;
  z-index:9999;
}
.dialog .panel{
  width:min(1100px, 98vw);
  height:min(88vh, 720px);
  background:#fff;
  border-radius:18px;
  border:1px solid var(--border);
  box-shadow:0 18px 50px rgba(0,0,0,.25);
  display:flex;
  flex-direction:column;
}
.dialog .panel header{
  border-bottom:1px solid var(--border);
  padding:12px 14px;
  display:flex;justify-content:space-between;align-items:center;
}
.dialog .panel header b{color:var(--green)}
.dialog .panel .content{padding:12px 14px;overflow:auto;flex:1;background:#f9fdfb}
.dialog pre{max-height:none;height:100%}