:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #fbfcfe;
  --border: #e4e8f0;
  --text: #1a2233;
  --muted: #6b7688;
  --brand: #3b5bdb;
  --brand-ink: #ffffff;
  --amber-bg: #fff4e0; --amber-ink: #a5680a; --amber-dot: #f0940a;
  --green-bg: #e5f6ec; --green-ink: #157347; --green-dot: #22a55f;
  --red-bg: #fdecec; --red-ink: #b02a2a; --red-dot: #e14b4b;
  --shadow: 0 1px 2px rgba(20,30,60,.06), 0 8px 24px rgba(20,30,60,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1219; --panel: #161c26; --panel-2: #1b222e; --border: #262f3d;
    --text: #e7ecf5; --muted: #94a1b5; --brand: #5b7cfa; --brand-ink: #0e1219;
    --amber-bg: #33270f; --amber-ink: #f0b45a; --green-bg: #12301f; --green-ink: #5fd08a;
    --red-bg: #331717; --red-ink: #f08b8b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--brand); text-decoration: none; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg,var(--brand),#8aa0ff); display: grid; place-items: center; color: #fff; font-weight: 800; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.nav a.active { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.nav a:hover { background: var(--panel-2); }
.nav a.disabled { opacity: .5; pointer-events: none; }
.nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 16px 12px 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--panel); }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .user { color: var(--muted); display: flex; align-items: center; gap: 14px; }
.content { padding: 24px 28px; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-weight: 600; }
.tab .count { min-width: 20px; text-align: center; padding: 1px 7px; border-radius: 20px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.tab.active { border-color: transparent; }
.tab.active.pending { background: var(--amber-bg); color: var(--amber-ink); }
.tab.active.authorized { background: var(--green-bg); color: var(--green-ink); }
.tab.active.rejected { background: var(--red-bg); color: var(--red-ink); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search { display: flex; gap: 8px; }
.search input { width: 320px; max-width: 60vw; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); color: var(--text); }
.btn { padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--panel-2); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn-green { background: var(--green-dot); color: #fff; border-color: transparent; }
.btn-red { background: var(--red-dot); color: #fff; border-color: transparent; }
.btn-sm { padding: 5px 11px; font-size: 13px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.dim { color: var(--muted); font-size: 12.5px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.pending { background: var(--amber-bg); color: var(--amber-ink); }
.badge.pending .dot { background: var(--amber-dot); }
.badge.authorized { background: var(--green-bg); color: var(--green-ink); }
.badge.authorized .dot { background: var(--green-dot); }
.badge.rejected { background: var(--red-bg); color: var(--red-ink); }
.badge.rejected .dot { background: var(--red-dot); }
.badge.time { background: var(--panel-2); color: var(--muted); }
.badge.time .dot { background: var(--muted); }

.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions form { display: inline; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-card { width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 30px 28px; }
.login-card h2 { margin: 6px 0 2px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.login-card label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 6px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); color: var(--text); }
.login-card .btn-primary { width: 100%; margin-top: 20px; padding: 11px; }
.alert { background: var(--red-bg); color: var(--red-ink); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 8px; }
.notice { background: var(--green-bg); color: var(--green-ink); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 8px; }

/* app management */
.hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.card.pad { padding: 16px; margin-bottom: 18px; }
.pad { padding: 14px 16px; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form input[type=text] { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); color: var(--text); min-width: 200px; }
.inline-form input[type=file] { color: var(--muted); font-size: 13px; }
.app-card { margin-bottom: 16px; }
.app-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.app-head > div { display: flex; align-items: center; gap: 12px; }
.app-pkg { font-size: 14px; font-weight: 600; }
.inline-form.upload { padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); color: var(--text); font: inherit; cursor: pointer; }
.inline-form select { min-width: 180px; }
tbody select { padding: 5px 8px; font-size: 13px; }

/* channel download portal */
.portal { min-height: 100vh; background: var(--bg); }
.portal-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 32px; background: var(--panel); border-bottom: 1px solid var(--border); }
.portal-top .brand { padding: 0; }
.portal-top .user { color: var(--muted); display: flex; align-items: center; gap: 16px; }
.portal-body { padding: 28px 32px; max-width: 1100px; margin: 0 auto; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.dl-card { padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.dl-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--brand); }
.dl-name { font-size: 16px; font-weight: 700; }
.dl-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; }
.dl-sha { font-size: 11px; margin-top: 2px; }
.dl-btn { margin-top: 12px; text-align: center; }

/* upload progress + rom */
.progress { display: none; width: 160px; height: 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; vertical-align: middle; }
.progress-bar { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.progress-pct { font-size: 12px; min-width: 38px; }
.ta { width: 100%; min-height: 120px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); color: var(--text); font-size: 13px; resize: vertical; margin: 4px 0 8px; }
details.pad summary { cursor: pointer; }
.codeblock { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; white-space: pre-wrap; margin: 8px 0 0; }

/* todo / 待办 */
.quick-add { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.quick-add input[name=title] { flex: 1; padding: 11px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); color: var(--text); font-size: 15px; }
.quick-add input[name=description] { width: 220px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); color: var(--text); }
.badge.pri.urgent { background: var(--red-bg); color: var(--red-ink); } .badge.pri.urgent .dot { background: var(--red-dot); }
.badge.pri.high { background: var(--amber-bg); color: var(--amber-ink); } .badge.pri.high .dot { background: var(--amber-dot); }
.badge.pri.medium { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); } .badge.pri.medium .dot { background: var(--brand); }
.badge.pri.low { background: var(--panel-2); color: var(--muted); } .badge.pri.low .dot { background: var(--muted); }
.todo-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.todo-row:last-child { border-bottom: none; }
.todo-row:hover { background: var(--panel-2); }
.todo-title { font-weight: 600; color: var(--text); flex-shrink: 0; }
.todo-title.muted { color: var(--muted); text-decoration: line-through; }
.todo-desc { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-reason { flex: 1; }
.todo-time { margin-left: auto; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.35; text-align: right; }
.todo-time .tt-created { font-size: 11px; color: var(--muted); white-space: nowrap; }
.todo-time .tt-dur { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; }
.todo-actions { display: flex; gap: 6px; align-items: center; margin-left: 12px; flex-shrink: 0; }
.todo-actions form, .todo-actions span { display: inline-flex; gap: 6px; }
.detail-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.close-box { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.close-box input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); color: var(--text); }
.edit-title { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); color: var(--text); margin: 4px 0 8px; }
.desc-view { margin-top: 10px; white-space: pre-wrap; color: var(--text); }
.timeline { position: relative; margin-top: 12px; }
.timeline::before { content: ''; position: absolute; left: 13px; top: 14px; bottom: 14px; width: 2px; background: var(--border); }
.tl-item { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; position: relative; }
.tl-icon { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--border); display: grid; place-items: center; font-size: 12px; flex-shrink: 0; z-index: 1; }
.tl-body { font-size: 13px; padding-top: 3px; }
.tl-time { font-size: 11.5px; margin-top: 1px; }

/* 低调删除(Google 风格):默认无色,悬停才泛红 */
.btn-ghost-danger { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost-danger:hover { background: var(--red-bg); color: var(--red-ink); }

/* channel endpoints */
.ep-list { font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; border-top: 1px solid var(--border); padding-top: 10px; }
.ep-k { display: inline-block; width: 116px; color: var(--muted); }
.ep-form { max-width: 640px; }
.ep-form input { width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); margin: 3px 0 8px; }
.ep-form input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.ep-row { display: flex; gap: 12px; }
