:root{
  --bg:#0C1220; --surface:#151D30; --surface2:#1D2740; --line:#26325A;
  --fg:#EAF0FF; --muted:#A4B0CC;
  --accent:#3F5FE8; --accent-text:#8FA6FF;
  --ok:#35D6A4; --warn:#F2C14E; --danger:#FF8A7A; --danger-bg:#3A1E22;
  --font-head:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; --font-body:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  color-scheme:dark;
}
@media (prefers-color-scheme: light){
  :root{
    --bg:#F4F6FC; --surface:#FFFFFF; --surface2:#EAEFFA; --line:#D3DBF0;
    --fg:#0E1630; --muted:#4F5B7A; --accent:#3F5FE8; --accent-text:#2B47C4;
    --ok:#0B7A5C; --warn:#8A6100; --danger:#B3321F; --danger-bg:#FBE3DF;
    color-scheme:light;
  }
}
*{box-sizing:border-box}
html,body{margin:0}
body{
  background:var(--bg); color:var(--fg); font-family:var(--font-body); font-size:15px; line-height:1.45;
  padding:24px max(16px, env(safe-area-inset-right, 0px)) 56px max(16px, env(safe-area-inset-left, 0px));
}
[hidden]{display:none!important}
button,input,select,textarea{font-family:inherit}
:focus-visible{outline:2px solid var(--accent-text); outline-offset:2px}
.sr{position:absolute; left:-9999px}
.wrap{max-width:1040px; margin:0 auto; display:flex; flex-direction:column; gap:20px}
header{display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap}
.brand{display:flex; align-items:center; gap:10px}
.brand h1{margin:0; font-family:var(--font-head); font-size:24px; font-weight:700; letter-spacing:-0.01em}
.badge{height:26px; padding:0 10px; border-radius:13px; background:var(--surface2); border:1px solid var(--line); color:var(--accent-text); font-size:12px; font-weight:600; letter-spacing:.08em; display:inline-flex; align-items:center}
.stats{display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px}
.stat{background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:14px 16px; display:flex; flex-direction:column; gap:2px; min-width:0}
.stat span{font-size:13px; color:var(--muted)}
.stat strong{font-family:var(--font-head); font-size:28px; font-weight:700; font-variant-numeric:tabular-nums}
.panel{background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:16px}
.panel h2{margin:0 0 12px; font-family:var(--font-head); font-size:18px; font-weight:700}
.login{max-width:380px; width:100%; margin:12vh auto 0; display:flex; flex-direction:column; gap:18px}
.layout{display:flex; flex-wrap:wrap; gap:20px; align-items:flex-start}
.listp{flex:999 1 460px; min-width:0}
.formp{flex:1 1 320px; min-width:0}
.toolbar{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:6px}
.toolbar .grow{flex:1 1 200px; min-width:0}
.grow{flex:1 1 200px; min-width:0}
.note{margin:0 0 12px; padding:10px 12px; border-radius:12px; background:var(--surface2); color:var(--muted); font-size:13px}
.node,.keyrow{display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--line); flex-wrap:wrap}
.node:last-child,.keyrow:last-child{border-bottom:0}
.cc{width:40px; height:40px; border-radius:12px; background:var(--surface2); display:grid; place-items:center; font-size:13px; font-weight:600; letter-spacing:.04em; flex:none}
.main{flex:1 1 200px; min-width:0; display:flex; flex-direction:column; gap:2px}
.name-input{width:calc(100% + 16px); margin-left:-8px; background:transparent; border:1px solid transparent; border-radius:8px; color:var(--fg); font:600 16px var(--font-body); padding:4px 8px; min-height:36px}
.name-input:hover{border-color:var(--line)}
.name-input:focus{border-color:var(--accent-text); background:var(--bg)}
.meta{font-size:13px; color:var(--muted); overflow-wrap:anywhere}
.keylabel{font-weight:600; font-size:16px; overflow-wrap:anywhere}
.actions{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.coderow{flex:1 1 100%; display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.code{flex:1 1 200px; min-width:0; max-height:6.5em; overflow:auto; overflow-wrap:anywhere; padding:9px 12px; border-radius:10px; background:var(--bg); border:1px dashed var(--line); color:var(--muted); font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:12.5px; line-height:1.45; letter-spacing:.02em}
.code.open{color:var(--fg); border-style:solid}
.state{font-size:13px; font-weight:600; min-width:44px}
.on{color:var(--ok)} .off{color:var(--muted)} .bad{color:var(--danger)}
.sw{width:52px; height:32px; padding:3px; border:0; border-radius:16px; background:var(--surface2); box-shadow:inset 0 0 0 1px var(--line); display:flex; align-items:center; justify-content:flex-start; cursor:pointer; flex:none}
.sw[aria-checked="true"]{background:var(--accent); justify-content:flex-end; box-shadow:none}
.sw i{width:26px; height:26px; border-radius:13px; background:var(--muted); display:block}
.sw[aria-checked="true"] i{background:#fff}
.btn{min-height:44px; padding:0 16px; border-radius:12px; border:1px solid var(--line); background:var(--surface2); color:var(--fg); font:500 14px var(--font-body); cursor:pointer}
.btn:hover{border-color:var(--accent-text)}
.btn:disabled{opacity:.6; cursor:default}
.btn.primary{background:var(--accent); border-color:transparent; color:#fff; font-weight:600}
.btn.danger{color:var(--danger)}
.btn.sure{background:var(--danger-bg); border-color:var(--danger); color:var(--danger); font-weight:600}
.btn.small{padding:0 12px}
.empty{padding:24px 8px; text-align:center; color:var(--muted)}
form{display:flex; flex-direction:column; gap:12px}
.keyform{flex-direction:row; flex-wrap:wrap; align-items:flex-end}
.kdays{flex:0 1 140px; min-width:0}
.field{display:flex; flex-direction:column; gap:6px; min-width:0}
.field label,.field .lbl{font-size:13px; font-weight:500; color:var(--muted)}
input[type=text],input[type=search],input[type=password],input[type=number],textarea{
  width:100%; min-height:44px; padding:0 12px; border-radius:12px; border:1px solid var(--line);
  background:var(--bg); color:var(--fg); font-size:15px
}
.upper{text-transform:uppercase}
textarea{padding:10px 12px; min-height:120px; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:12.5px; line-height:1.5; resize:vertical}
.row2{display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px}
.check{display:flex; align-items:center; gap:10px; min-height:44px; font-size:15px}
.check input{width:20px; height:20px; accent-color:var(--accent)}
.msg{min-height:20px; font-size:13px; color:var(--muted)}
.msg.err{color:var(--danger)} .msg.good{color:var(--ok)}
.formbtns{display:flex; gap:10px; flex-wrap:wrap}
.foot{font-size:13px; color:var(--muted); margin:0 0 8px}
.newkey{margin:4px 0 14px; padding:12px; border:1px solid var(--accent-text); border-radius:12px; background:var(--surface2)}
