:root {
  --ground: #f6f7f5; --panel: #fff; --ink: #15171c; --muted: #5b616e; --line: #e4e6ea; --line-soft: #eef0f2;
  --accent: #0f766e; --accent-ink: #115e59; --accent-soft: #e6f2f1;
  --side: #13201f; --side-active: #1f3a37; --side-ink: #c9d6d4;
  --warn: #8a4208; --warn-soft: #fdf1e7; --danger: #b91c1c; --danger-soft: #fdecec; --good: #15803d; --good-soft: #e7f5ec;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); background: var(--ground); color: var(--ink); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { margin: 2px 0 0; font-size: 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { margin: 0; font-size: 16px; }
p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, Menlo, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 240px; background: var(--side); color: #e8efee; padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 15px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--side-ink); }
.side nav a:hover { background: #1a2c2a; }
.side nav a[aria-current="page"] { background: var(--side-active); color: #fff; font-weight: 600; }
.who { margin-top: auto; padding: 0 8px; font-size: 12px; color: #9fb3b0; display: flex; flex-direction: column; gap: 6px; word-break: break-all; }
.who button { width: 100%; background: none; border: 1px solid #2e4442; color: #e8efee; border-radius: 8px; padding: 8px; cursor: pointer; margin-top: 4px; }
.main { flex: 999 1 600px; min-width: 0; padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 700px) { .side { max-width: none; } .main { padding: 18px 14px; } }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.head .sub { color: var(--muted); margin-top: 4px; }
.spacer { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.card-pad { padding: 18px; }
.split { display: flex; justify-content: space-between; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat .value .small { font-size: 13px; font-weight: 500; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.grow-1 { flex: 1 1 320px; } .grow-2 { flex: 2 1 420px; }
.form-card { max-width: 760px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
details.form-card > summary { list-style: none; display: inline-flex; }
details.form-card > summary::-webkit-details-marker { display: none; }
details.form-card[open] > summary { margin-bottom: 16px; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled { opacity: .7; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 10px; border: 1px solid #d6dadf; background: var(--panel); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #b9c0c8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-danger { color: var(--danger); border-color: #f1c4c4; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; align-items: flex-start; }
.actions form { margin: 0; }
.actions-left { display: flex; gap: 8px; margin-top: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--muted); font-size: 13px; }
.field input:not([type=range]), .field select, .field textarea { border: 1px solid #d6dadf; border-radius: 8px; padding: 9px 12px; min-height: 40px; background: #fff; color: var(--ink); font-weight: 400; font-size: 14px; }
.field input[type=range] { accent-color: var(--accent); }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field .hint, .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.field output { color: var(--ink); }
.narrow { max-width: 360px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; }
.form-row > .field { flex: 1 1 200px; }
.self-end { align-self: flex-end; padding-bottom: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); font-weight: 400; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.pick-list { border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow-y: auto; margin: 4px 0 14px; }
.pick-row { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.pick-row:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.data.compact { min-width: 0; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px; font-weight: 700; border-bottom: 1px solid var(--line); }
table.data td { padding: 11px 14px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
table.data tr:hover td { background: #fafbfa; }
.narrow-table { max-width: 560px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-muted { background: #f1f3f2; color: var(--muted); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-type { background: var(--accent-soft); color: var(--accent-ink); }
.usage { display: flex; align-items: center; gap: 8px; }
.bar { width: 80px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; flex: none; }
.bar > div { height: 100%; background: var(--accent); }
.bar > div.hot { background: #b45309; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--accent-ink); border-bottom-color: var(--accent); }

details.pop { position: relative; }
details.pop > summary { list-style: none; }
details.pop > summary::-webkit-details-marker { display: none; }
.pop-body { position: absolute; right: 0; top: 38px; z-index: 10; width: 300px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(21, 23, 28, .14); padding: 14px; display: flex; flex-direction: column; gap: 10px; text-align: left; }

.notice { padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--good-soft); color: var(--good); }
.notice-info { background: var(--accent-soft); color: var(--accent-ink); }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.secret-label { font-weight: 700; margin-bottom: 6px; }
.secret { display: flex; gap: 8px; align-items: center; background: #fff; border: 1px dashed #9cc7b0; border-radius: 8px; padding: 8px 10px; color: var(--ink); max-width: 460px; }
.secret code { flex: 1; font-size: 15px; word-break: break-all; }

.login-body { background: var(--side); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.brand-dark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }

/* footer + branding */
.app-foot { margin-top: auto; padding-top: 18px; font-size: 12px; color: var(--muted, #5b616e); text-align: center; }
.app-foot a { color: inherit; font-weight: 600; text-decoration: none; }
.app-foot a:hover { text-decoration: underline; }
.login-wrap { flex-direction: column; gap: 4px; }
.app-foot-dark { color: rgba(255, 255, 255, .7); }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 40px; padding: 2px; border: 1px solid #d6dadf; border-radius: 8px; background: #fff; flex: none; }
.color-row input:not([type=color]) { flex: 1; }
.brand-preview { border: 1px solid #e4e6ea; border-radius: 12px; overflow: hidden; background: #f6f7f5; font-size: 14px; }
.bp-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-bottom: 1px solid #e4e6ea; min-height: 52px; }
.bp-top img { height: 30px; max-width: 160px; object-fit: contain; }
.bp-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--bc); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.bp-body { display: flex; flex-direction: column; gap: 8px; padding: 14px; width: 180px; }
.bp-btn { background: var(--bc); color: #fff; border-radius: 8px; padding: 8px; text-align: center; font-weight: 600; }
.bp-folder { background: color-mix(in srgb, var(--bc) 12%, #fff); color: var(--bc); border-radius: 8px; padding: 7px 10px; font-weight: 600; }
.bp-foot { font-size: 11px; color: #5b616e; text-align: center; padding: 6px; border-top: 1px solid #e4e6ea; background: #fff; }

.prefix-input { display: flex; align-items: stretch; border: 1px solid #d6dadf; border-radius: 8px; overflow: hidden; background: #fff; font-weight: 400; }
.prefix-input > span { padding: 10px 0 10px 12px; color: var(--muted); white-space: nowrap; background: #f6f7f5; padding-right: 4px; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.prefix-input input { border: 0 !important; flex: 1; min-width: 80px; border-radius: 0 !important; }
.url-list { display: flex; flex-direction: column; gap: 8px; }
.url-list > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #f6f7f5; }
.url-list a { font-weight: 600; word-break: break-all; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
form.inline { display: inline; }

/* top bar + account menu */
.shell { flex-wrap: nowrap; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; flex: 0 0 232px; max-width: 232px; }
.side-foot { margin-top: auto; padding: 0 8px; font-size: 12px; color: #7f9592; }
.main-wrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.main-wrap .main { flex: 1 0 auto; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 24px 0 32px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top-search { flex: 1 1 auto; max-width: 460px; margin-left: auto; display: flex; align-items: center; gap: 8px; background: #f1f3f2; border: 1px solid transparent; border-radius: 10px; padding: 0 12px; color: var(--muted); }
.top-search:focus-within { background: #fff; border-color: var(--accent); }
.top-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 9px 0; outline: none; color: var(--ink); }
.topbar .spacer { flex: 1; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--line-soft); }
.side-toggle { display: none; margin-left: -8px; }
.top-link { flex: none; }
.acct { position: relative; flex: none; }
.acct-btn { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: 999px; background: none; cursor: pointer; color: var(--ink); }
.acct-btn:hover, .acct-btn[aria-expanded="true"] { background: var(--line-soft); border-color: var(--line); }
.acct-name { font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn .ic { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.acct-btn[aria-expanded="true"] .ic { transform: rotate(180deg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar-lg { width: 42px; height: 42px; font-size: 15px; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 290px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(21, 23, 28, .16); padding: 6px; z-index: 30; }
.menu-head { display: flex; gap: 12px; align-items: center; padding: 10px 10px 12px; }
.menu-head > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.menu-head strong { font-size: 14px; }
.menu-head > div > span:not(.pill) { font-size: 12px; color: var(--muted); word-break: break-all; }
.menu-group { border-top: 1px solid var(--line-soft); padding: 4px 0; margin: 0; }
.acct-menu [role=menuitem] { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 0; background: none; color: var(--ink); text-decoration: none; font-size: 14px; cursor: pointer; text-align: left; }
.acct-menu [role=menuitem] .ic { color: var(--muted); }
.acct-menu [role=menuitem]:hover, .acct-menu [role=menuitem]:focus-visible { background: var(--accent-soft); color: var(--accent-ink); outline: none; }
.acct-menu [role=menuitem]:hover .ic, .acct-menu [role=menuitem]:focus-visible .ic { color: var(--accent-ink); }
.acct-menu .ext { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu-signout { color: var(--danger) !important; }
.menu-signout .ic { color: var(--danger) !important; }
.menu-signout:hover { background: var(--danger-soft) !important; }
.side-scrim { display: none; }
.kv { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: 10px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; }
.ext-list { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 900px) {
  .acct-name, .top-link span { display: none; }
  .top-link { padding: 4px 8px; }
}
@media (max-width: 700px) {
  .shell { display: block; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; height: auto; z-index: 40; transform: translateX(-100%); transition: transform .2s; max-width: 270px; width: 270px; }
  .side-open .side { transform: none; }
  .side-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 35; }
  .side-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .top-search { display: none; }
  .top-title { flex: 1; }
  .acct-menu { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}
.grow-1, .grow-2 { min-width: 0; }
@media (max-width: 700px) {
  .grow-1, .grow-2 { flex-basis: 100%; }
  table.data.compact { table-layout: fixed; }
  table.data.compact td, table.data.compact th { word-break: break-word; padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 700px) {
  table.data.compact .nowrap, table.data.compact td { white-space: normal; }
  .card > table.data { display: block; overflow-x: auto; }
}
