:root {
  color-scheme: light;
  --ink: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --border: #e2e8f0;
  --canvas: #f5f7fa;
  font-family: "Inter", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); }
a { color: var(--accent); }
button, input { font: inherit; }
button, summary { cursor: pointer; }
:focus-visible { outline: 3px solid #238cbb; outline-offset: 3px; }
.mono, code { font-family: "IBM Plex Mono", Consolas, monospace; overflow-wrap: anywhere; }
h1, h2, h3, h4, p, dl { margin: 0; }
h1 { font-size: 1.7rem; line-height: 1.4; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; line-height: 1.5; }
h3 { font-size: 1.18rem; line-height: 1.4; overflow-wrap: anywhere; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 16rem minmax(0,1fr); }
.rail { position: sticky; top: 0; display: flex; flex-direction: column; align-self: start; height: 100dvh; padding: 1.6rem 1rem 1.25rem; background: white; border-right: 1px solid var(--border); color: var(--ink); overflow-y:auto; }
.brand { color: inherit; display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; font-size: 1.32rem; letter-spacing: -.05em; white-space: nowrap; }
.rail .brand { margin: 0 .55rem 2rem; }
.brand-mark { display: inline-block; flex: none; width: 1.8rem; height: 1.85rem; border-radius: .38rem; background: #8ce2bc; position: relative; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; height: .33rem; width: 1rem; background: #1a443d; transform: skew(-28deg); border-radius: .08rem; }
.brand-mark::before { top: .5rem; left: .52rem; }
.brand-mark::after { top: 1rem; left: .28rem; }
.navlink { display: flex; align-items: center; gap: .75rem; color: #475569; padding: .72rem 1rem; margin: .2rem 0; border-radius: .42rem; font-size: 1rem; text-decoration: none; }
.navlink:hover, .navlink:focus-visible { color: var(--accent); background: #f1f5f9; }
.navlink.current { color: #1d4ed8; background: #eff6ff; font-weight: 600; }
.nav-icon { width: 1.3rem; text-align: center; font-size: 1.3rem; line-height: 1; color: #a0d4bc; }
.nav-group { margin: 1.7rem .8rem .4rem; font-size: .8rem; color: #a2bab8; }
.adminlink { padding-left: 1rem; }
.identity { display: flex; align-items: center; gap: .6rem; margin-top: auto; padding: 1.1rem .25rem 0; border-top: 1px solid var(--border); font-size: .88rem; }
.identity-name { overflow-wrap: anywhere; }
.identity form { margin-left: auto; }
.avatar { display: grid; place-content: center; flex: none; width: 2rem; height: 2rem; background: #eff6ff; color: #2563eb; border-radius: 50%; font-weight: 700; }
.signout { background: transparent; border: 0; color: #64748b; padding: .5rem; white-space: nowrap; }
.signout:hover { color: var(--accent); text-decoration: underline; }
.workspace { width: 100%; max-width: 110rem; padding: 2rem 2.4rem 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1.25rem; }
.context { color: var(--muted); font-size: .88rem; margin-bottom: .75rem; }
.context span { margin: 0 .25rem; color: #abb4b2; }
.panel-section { margin-top: 1.6rem; scroll-margin-top: 1.25rem; }
.section-head, .grant-heading { display: flex; gap: 1rem; align-items: baseline; }
.section-head { margin-bottom: .8rem; justify-content: space-between; }
.count { color: var(--muted); font-size: .88rem; }
.card { background: #fff; border: 1px solid var(--border); border-radius: .7rem; }
.device-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%,22rem),1fr)); align-items: start; gap: 1rem; }
.device { padding: 1.25rem 1.4rem; min-width: 0; }
.device-head, .grant-title { display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
.device-type { color: var(--muted); font-size: .82rem; margin-bottom: .15rem; }
.pill { display: inline-flex; align-items: center; gap: .38rem; border-radius: 100vmax; padding: .2rem .62rem; font-size: .8rem; white-space: nowrap; font-weight: 600; background: #e4f4e9; color: #1c6346; }
.pill i { width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; }
.pill.off { color: #6c6056; background: #f1ede8; }
.button { border: 1px solid transparent; border-radius: .4rem; padding: .52rem .9rem; font-size: .9rem; font-weight: 600; color: inherit; text-decoration: none; line-height: 1.5; display: inline-flex; align-items: center; justify-content: center; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: #1d4ed8; }
.button.ghost { background: #fff; border-color: #bfcac6; }
.button.ghost:hover { background: #eff5f2; border-color: #879e96; }
.device-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin: 1.1rem 0; }
.device-actions:empty { display:none; }
.grant-heading { border-top: 1px solid var(--border); padding-top: .85rem; justify-content: space-between; }
.grant-heading h4, .grant-title { font-size: .93rem; }
.grant { padding: .75rem 0; border-bottom: 1px solid #e6ece8; }
.grant:last-child { padding-bottom: .1rem; border-bottom: 0; }
.grant-title { align-items: baseline; }
.grant-title b { overflow-wrap: anywhere; }
.muted, .inline-empty { color: var(--muted); font-size: .88rem; }
.inline-empty { margin: .5rem 0 .1rem; }
.credentials { margin-top: .35rem; color: var(--accent); font-size: .88rem; }
.credentials dl { display: grid; grid-template-columns: auto minmax(0,1fr); gap: .3rem .9rem; margin-top: .5rem; padding: .75rem; background: #f1f6f2; color: var(--ink); border-radius: .35rem; }
dd { margin: 0; }
.help { margin-top: .9rem; font-size: .94rem; color: var(--muted); }
.help summary { color: var(--accent); font-weight: 600; }
.help p { margin-top: .5rem; max-width: 60rem; }
.empty { padding: 2.2rem 1.6rem; border-left: 4px solid #83b9a1; }
.empty p { color: var(--muted); margin-top: .4rem; }
.grid-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: .85rem 1rem; text-align: left; border-bottom: 1px solid #e4ebe6; }
thead th { background: #f8fafc; color: #64748b; white-space: nowrap; font-weight: 500; }
tbody td, tbody th { overflow-wrap: anywhere; }
tbody tr:last-child > * { border-bottom: 0; }
.table-empty { padding: 1.15rem 1rem; color: var(--muted); }
.notice { padding: .8rem 1rem; border: 1px solid #a3cdb9; background: #eaf7ef; border-radius: .42rem; margin-top: 1rem; color: #1e5541; }
.notice-error { background: #fff3ed; border-color: #d9a08c; color: #7c3625; }
.subscription { background: #eff5f0; padding: .8rem; margin-bottom: 1rem; border-radius: .4rem; }
.subscription label { margin: 0 0 .5rem; }
.copy-row { display: flex; gap: .35rem; }
.copy-row input { min-width: 0; }
.copy-row button { white-space: nowrap; }
.login-body { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login-panel { width: min(100%, 27rem); background: #fff; border: 1px solid var(--border); border-top: .35rem solid var(--accent); border-radius: .7rem; padding: clamp(1.35rem,5vw,2.3rem); }
.login-brand { color: #24433f; margin-bottom: 2.6rem; font-size: 1.16rem; }
.login-panel h1 { font-size: 1.8rem; }
label { display: block; margin: 1.25rem 0 .4rem; font-size: .92rem; font-weight: 600; }
input { border: 1px solid #acbdb5; width: 100%; min-height: 2.7rem; padding: .5rem .65rem; border-radius: .4rem; }
input[type=hidden] { display: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat { display: grid; gap: .65rem; background: white; border: 1px solid var(--border); border-radius: .7rem; padding: 1.3rem; color: var(--muted); text-decoration: none; }
.stat strong { color: var(--ink); font-size: 2rem; line-height: 1.2; }
.stat small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.stat:hover { border-color: #93b4ed; }
.brand-mark { background: #dbeafe; }
.brand-mark::before, .brand-mark::after { background: #2563eb; }
.context { margin-bottom: .3rem; }
.empty .button { margin-top: 1rem; }
.login-submit { width: 100%; margin-top: 1.55rem; min-height: 2.75rem; }
.skip, .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
.skip:focus { width: auto; height: auto; padding: .5rem; overflow: visible; clip-path: none; background: white; z-index: 2; }
@media(max-width: 820px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .rail { position: static; height: auto; padding: 1rem 1.25rem; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .7rem; }
  .rail .brand, .identity { margin: 0; }
  .rail nav { grid-column: 1/-1; grid-row: 2; display: flex; flex-wrap: wrap; gap: .3rem; }
  .navlink { padding: .3rem .5rem; font-size: .88rem; }
  .nav-icon, .nav-group { display: none; }
  .identity { padding: 0; border: 0; }
  .page-head { padding-bottom: 1.25rem; }
  .panel-section { margin-top: 1.6rem; }
}
@media(max-width: 420px) {
  .avatar { display: none; }
  .page-head { flex-wrap: wrap; }
  .device { padding: 1rem; }
}
