:root{
  --bg:#0b0f14; --panel:#121821; --panel2:#161d27; --line:#222c3a;
  --txt:#e6edf5; --dim:#8b9bb0; --accent:#3fa9f5; --accent2:#2b7fc4;
  --ok:#2ecc71; --warn:#f0a020; --err:#ff5d5d; --mod:#f0a020;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--txt);
  font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
}
button{font:inherit;cursor:pointer;border:0;border-radius:9px;padding:9px 15px}
button.primary{background:var(--accent);color:#04121e;font-weight:650}
button.primary:disabled{background:#25313f;color:#5d6b7d;cursor:not-allowed}
button.ghost{background:transparent;color:var(--dim);border:1px solid var(--line)}
button.ghost:hover{color:var(--txt);border-color:#33415a}
input,textarea{
  font:inherit;background:#0d131b;color:var(--txt);
  border:1px solid var(--line);border-radius:9px;padding:10px 12px;width:100%
}
input:focus,textarea:focus{outline:0;border-color:var(--accent)}

/* ---------- login ---------- */
.login-wrap{min-height:100vh;display:grid;place-items:center;padding:20px}
/* `display:grid` beats the [hidden] attribute, so the signed-out card kept
   reserving a full viewport above the signed-in panel. */
.login-wrap[hidden]{display:none}
#app[hidden]{display:none}
.login-card{
  width:100%;max-width:390px;background:var(--panel);
  border:1px solid var(--line);border-radius:16px;padding:26px
}
.brand{display:flex;gap:13px;align-items:center;margin-bottom:18px}
.brand-mark{
  width:42px;height:42px;border-radius:11px;display:grid;place-items:center;
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  color:#04121e;font-weight:800;letter-spacing:.5px;flex:0 0 auto
}
.brand h1{font-size:17px;margin:0}
.brand .sub{margin:1px 0 0;font-size:12.5px;color:var(--dim)}
.notice{
  background:#0f1a26;border:1px solid #1d3247;
  border-radius:10px;padding:11px 13px;font-size:13px;color:#a9bed3;margin-bottom:18px
}
.notice strong{color:var(--txt)}
form label{display:block;margin-bottom:13px;font-size:13px;color:var(--dim)}
form label input{margin-top:6px}
form button[type=submit]{width:100%;background:var(--accent);color:#04121e;font-weight:650;padding:11px}
.err{margin-top:12px;color:var(--err);font-size:13.5px}

/* ---------- top bar ---------- */
.top{
  display:flex;justify-content:space-between;align-items:center;gap:14px;
  padding:13px 18px;border-bottom:1px solid var(--line);
  background:var(--panel);position:sticky;top:0;z-index:20;flex-wrap:wrap
}
.brand.small .brand-mark{width:34px;height:34px;border-radius:9px;font-size:13px}
.brand.small h1{font-size:15px}
.top-actions{display:flex;gap:9px;align-items:center}
.badge{
  background:var(--mod);color:#231703;font-weight:700;font-size:12px;
  padding:4px 10px;border-radius:20px
}

/* ---------- toolbar ---------- */
.toolbar{
  display:flex;gap:12px;align-items:center;padding:12px 18px;flex-wrap:wrap;
  border-bottom:1px solid var(--line);background:var(--panel2);
  position:sticky;top:61px;z-index:19
}
.toolbar #search{flex:1;min-width:210px}
.seg{display:flex;background:#0d131b;border:1px solid var(--line);border-radius:9px;overflow:hidden}
.seg button{background:transparent;color:var(--dim);border-radius:0;padding:8px 15px;font-size:13.5px}
.seg button.on{background:var(--accent);color:#04121e;font-weight:650}
.chk{display:flex;gap:7px;align-items:center;font-size:13.5px;color:var(--dim);white-space:nowrap}
.chk input{width:auto}

/* ---------- layout ---------- */
.layout{display:flex;align-items:flex-start;gap:0}
.groups{
  width:210px;flex:0 0 210px;padding:14px 10px;
  border-right:1px solid var(--line);position:sticky;top:118px;
  max-height:calc(100vh - 118px);overflow:auto
}
.groups h4{
  font-size:11px;text-transform:uppercase;letter-spacing:.9px;
  color:#5f7089;margin:14px 8px 7px
}
.groups h4:first-child{margin-top:0}
.groups a{
  display:flex;justify-content:space-between;gap:8px;
  padding:7px 10px;border-radius:8px;color:var(--dim);
  text-decoration:none;font-size:13.5px;cursor:pointer
}
.groups a:hover{background:#182231;color:var(--txt)}
.groups a.on{background:#1b2836;color:var(--txt);font-weight:600}
.groups a i{font-style:normal;font-size:11.5px;color:#5f7089}

.list{flex:1;min-width:0;padding:16px 18px 80px}

/* ---------- rows ---------- */
.grp{margin-bottom:26px}
.grp > h3{
  font-size:13px;text-transform:uppercase;letter-spacing:.7px;
  color:#7d8ea6;margin:0 0 11px;padding-bottom:7px;border-bottom:1px solid var(--line)
}
.row{
  background:var(--panel);border:1px solid var(--line);
  border-radius:12px;padding:13px 15px;margin-bottom:11px
}
.row.modified{border-color:#3d3418}
.row.dirty{border-color:var(--accent)}
.row.invalid{border-color:var(--err)}
.row-head{display:flex;justify-content:space-between;align-items:baseline;gap:10px;margin-bottom:3px}
.row-label{font-weight:620;font-size:14.5px}
.row-key{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;color:#5f7089}
.row-desc{font-size:12.5px;color:var(--dim);margin:0 0 9px}
.row textarea{
  min-height:44px;resize:vertical;line-height:1.5;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:13px
}
.row-foot{
  display:flex;justify-content:space-between;align-items:center;
  gap:10px;margin-top:8px;flex-wrap:wrap
}
.chips{display:flex;gap:6px;flex-wrap:wrap}
.chip{
  background:#16202c;border:1px solid #24303f;color:#93a6bd;
  font-family:ui-monospace,monospace;font-size:11px;padding:2px 8px;border-radius:20px
}
.chip.req{border-color:#2f4a66;color:#8fc4f0}
.chip.warn{border-color:#4a3a18;color:#e0a94a}
.row-acts{display:flex;gap:7px}
.row-acts button{padding:5px 11px;font-size:12.5px}
.msg{font-size:12.5px;margin-top:7px}
.msg.bad{color:var(--err)}
.msg.good{color:var(--ok)}
.count{font-size:11.5px;color:#5f7089}

/* ---------- drawer ---------- */
.drawer{position:fixed;inset:0;background:rgba(4,8,13,.72);z-index:60;display:grid;place-items:center;padding:20px}
/* `display:grid` overrides the [hidden] attribute, so the invisible drawer
   was still covering the page and swallowing every click. */
.drawer[hidden]{display:none}
.drawer-inner{
  width:100%;max-width:640px;max-height:80vh;overflow:auto;
  background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:18px
}
.drawer-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}
.drawer-head h3{margin:0;font-size:15px}
.hist{border-left:2px solid var(--line);padding:0 0 14px 13px;margin-left:4px}
.hist .when{font-size:12px;color:var(--dim)}
.hist .who{font-size:12px;color:#7d8ea6}
.hist pre{
  background:#0d131b;border:1px solid var(--line);border-radius:8px;
  padding:9px 11px;font-size:12.5px;white-space:pre-wrap;word-break:break-word;margin:6px 0 0
}
.hist .old{color:#c98b8b}
.hist .new{color:#8bc9a0}

/* ---------- toast ---------- */
.toast{
  position:fixed;left:50%;bottom:26px;transform:translateX(-50%);
  background:#1b2836;border:1px solid var(--line);color:var(--txt);
  padding:11px 19px;border-radius:11px;z-index:80;font-size:14px;
  box-shadow:0 10px 34px rgba(0,0,0,.5)
}
.toast.bad{border-color:var(--err);color:#ffc9c9}
.toast.good{border-color:var(--ok)}
.empty{color:var(--dim);text-align:center;padding:46px 20px}

@media(max-width:820px){
  .layout{flex-direction:column}
  .groups{
    width:100%;flex:auto;position:static;max-height:none;
    border-right:0;border-bottom:1px solid var(--line);
    display:flex;flex-wrap:wrap;gap:6px
  }
  .groups h4{width:100%;margin:8px 6px 2px}
  .groups a{padding:6px 11px;background:#141c26}
  .toolbar{top:auto;position:static}
}
