:root {
  --bg: #f8fafc;
  --bg-accent: #f1f5f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-hover: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-subtle: #f1f5f9;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: #eff6ff;
  --brand-border: #bfdbfe;
  --brand-ring: rgba(37, 99, 235, 0.16);
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --ok-dot: #10b981;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-dot: #f59e0b;
  --danger: #be123c;
  --danger-hover: #9f1239;
  --danger-bg: #fef2f2;
  --danger-border: #fecdd3;
  --danger-dot: #f43f5e;
  --side-w: 232px;
  --header-h: 64px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 10px -4px rgba(15, 23, 42, 0.04);
  --shadow-dialog: 0 24px 48px -12px rgba(15, 23, 42, 0.22);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 13px;
  line-height: 1.5;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button:focus, a:focus, input:focus, select:focus, textarea:focus { outline: none; }

:root.keyboard-navigation :is(button, a, select, summary, input[type=checkbox], input[type=file]):focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* Buttons */
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  padding: 6px 12px;
  min-height: 34px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-xs);
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .1s ease;
}

button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #cbd5e1;
  color: var(--text);
}

button:active:not(:disabled) {
  transform: translateY(0.5px);
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
  box-shadow: none;
}

.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.primary:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #fff;
}

.quiet {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.quiet:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: transparent;
  color: var(--text);
}

.link {
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--brand);
  padding: 4px 8px;
  min-height: 28px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.link:hover:not(:disabled) {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand-hover);
}

.link.danger {
  color: var(--danger);
}

.link.danger:hover:not(:disabled) {
  background: var(--danger-bg);
  color: var(--danger-hover);
}

.btn-sm {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.danger { color: var(--danger); }
.muted, .hint { color: var(--muted); }
.hint { font-size: 12px; line-height: 1.5; margin: 6px 0 0; }
.full { width: 100%; justify-content: center; }

h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; margin: 0; color: var(--text); }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; margin: 0; color: var(--text); }
p { line-height: 1.55; }
a { color: inherit; text-decoration: none; }

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: block;
}

/* Sidebar */
aside {
  width: var(--side-w);
  position: fixed;
  inset: 0 auto 0 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 14px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line-subtle);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.brand-mark svg {
  width: 17px;
  height: 17px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.brand-text span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
  overflow-y: auto;
  flex: 1;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  padding: 2px 10px 4px;
  letter-spacing: 0.02em;
}

nav a {
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background .15s ease, color .15s ease;
  position: relative;
}

nav a .icon {
  color: var(--muted);
  transition: color .15s ease;
}

nav a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

nav a:hover .icon {
  color: var(--text);
}

nav .active {
  background: var(--brand-soft);
  color: var(--brand-hover);
  font-weight: 600;
}

nav .active .icon {
  color: var(--brand);
}

.account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 12px 6px 2px;
  margin-top: 12px;
}

.account-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-hover);
  border: 1px solid var(--brand-border);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.account strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account button {
  padding: 5px 8px;
  min-height: 30px;
  font-size: 12px;
}

/* Workspace & Header */
.workspace {
  margin-left: var(--side-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  min-height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  gap: 16px;
  flex-shrink: 0;
}

.header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#crumb-desc {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

#page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#content {
  padding: 20px 24px 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

#list {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 260px;
  min-width: 200px;
}

.search-field .icon {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
  width: 15px;
  height: 15px;
}

.search-field input {
  padding-left: 32px;
  margin: 0;
  width: 100%;
}

.toolbar > input {
  min-width: 200px;
  width: 240px;
  margin: 0;
}

.toolbar select {
  width: auto;
  min-width: 132px;
  margin: 0;
}

.toolbar-spacer {
  margin-left: auto;
}

/* Table */
.table-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

th, td { white-space: nowrap; }

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-subtle);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-subtle);
  font-size: 13px;
  vertical-align: middle;
  color: var(--text-secondary);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td strong {
  font-weight: 600;
  color: var(--text);
}

td small, .select-row small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

tbody tr {
  transition: background .12s ease;
}

tbody tr:hover {
  background: #f8fafc;
}

.user-col {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.actions {
  white-space: nowrap;
  padding: 8px 12px;
}

.action-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

td.actions .action-group {
  flex-wrap: nowrap;
}

.role-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 240px;
}

/* Badges */
.badge {
  font-size: 11px;
  font-weight: 500;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1.4;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #94a3b8;
  flex-shrink: 0;
}

.badge.green {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #a7f3d0;
}

.badge.green::before {
  background: var(--ok-dot);
}

.badge.release-paused {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: #fde68a;
}

.badge.release-paused::before {
  background: var(--warn-dot);
}

.badge.badge-soft {
  background: var(--brand-soft);
  color: var(--brand-hover);
  border-color: var(--brand-border);
}

.badge.badge-soft::before {
  display: none;
}

/* Pager & Loading & Empty */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 12px;
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: var(--surface-subtle);
  font-variant-numeric: tabular-nums;
}

.pager > div { display: flex; gap: 8px; align-items: center; }
.pager button { font-size: 12px; min-height: 28px; padding: 3px 10px; }

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}

#list.loading, #list.empty-state, .loading-box {
  justify-content: center;
  align-items: center;
  color: var(--muted);
  min-height: 180px;
  display: flex;
  gap: 10px;
  padding: 24px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 999px;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Forms & Inputs */
label {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  margin: 0 0 12px;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid #cbd5e1;
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--text);
  font-weight: 400;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input:not([type=checkbox]):not([type=file]),
select {
  height: 36px;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 34px;
}

select {
  appearance: none;
  padding-right: 30px;
  background-color: var(--surface);
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

input[readonly] {
  background: var(--surface-subtle);
  color: var(--muted);
}

input[type=checkbox] {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

input[type=file] {
  height: auto;
  font-size: 12px;
  line-height: 1.4;
  padding: 9px 11px;
  background: var(--surface-subtle);
  border-style: dashed;
  cursor: pointer;
}

input[type=file]::file-selector-button {
  font: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  margin-right: 10px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

input[type=file]::file-selector-button:hover {
  background: var(--surface-hover);
  border-color: #cbd5e1;
}

textarea {
  height: auto;
  min-height: 80px;
  line-height: 1.55;
  resize: vertical;
}

.file-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: var(--brand-hover);
  font-size: 12px;
}

.file-meta strong {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modal / Dialog */
html:has(#modal[open]) { overflow: hidden; }

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-dialog);
  animation: dialog-in .16s ease-out;
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

dialog.confirm-modal {
  max-width: 440px;
}

.confirm-message {
  margin: 4px 0 6px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.65;
}

#modal-body,
.modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.modal-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 24px;
}

.modal-head button {
  min-height: 30px;
  width: 30px;
  padding: 0;
  border-radius: 8px;
}

#modal-title:focus { outline: none; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.modal-footer > span {
  color: var(--muted);
  font-size: 12px;
}

.modal-footer-note { margin-right: auto; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.form-grid label { margin: 0; }
.check { display: flex; align-items: center; gap: 7px; margin: 0; cursor: pointer; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 14px 0;
  padding: 12px 14px;
  background: var(--surface-subtle);
}

legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.selection-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.selection-toolbar input { flex: 1 1 220px; min-width: 0; margin: 0; }
.selection-list {
  max-height: 280px;
  overflow: auto;
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.copy-toolbar { display: flex; align-items: center; gap: 8px; }
.copy-toolbar select { flex: 1; min-width: 0; margin: 0; }

.media-group { border-bottom: 1px solid var(--line-subtle); }
.media-group:last-child { border-bottom: 0; }
.media-group summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  cursor: pointer;
  list-style: none;
}
.media-group summary:hover { background: var(--surface-subtle); }
.media-group summary::before { content: '▸'; color: var(--muted); font-size: 11px; }
.media-group[open] summary::before { content: '▾'; }
.media-group summary::-webkit-details-marker { display: none; }
.media-group summary .check { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.media-count { font-size: 11px; white-space: nowrap; }
.media-children { padding-left: 22px; background: #fcfcfd; }
.media-children .select-row > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }

.select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 0;
  border-bottom: 1px solid var(--line-subtle);
  cursor: pointer;
}
.select-row:last-child { border-bottom: 0; }
.select-row > span:nth-child(2) { flex: 1; }
.select-row strong { font-size: 13px; font-weight: 500; color: var(--text); }
.select-row:hover { background: var(--brand-soft); }

.notice {
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: #1e40af;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  line-height: 1.5;
}

.notice.is-warning {
  background: var(--warn-bg);
  border-color: #fde68a;
  color: var(--warn);
}

.target-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.target-cards > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.target-cards small { display: block; color: var(--muted); font-size: 12px; }
.target-cards strong { display: block; margin: 6px 0 2px; font-size: 16px; color: var(--text); }

/* Login */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: radial-gradient(circle at top, #eef2ff 0%, #f8fafc 55%);
}

.login-card {
  width: 380px;
  max-width: 100%;
  background: var(--surface);
  padding: 32px 30px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.login-brand {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.login-brand svg {
  width: 24px;
  height: 24px;
}

.login-card h1 {
  font-size: 20px;
  letter-spacing: -.02em;
  margin: 0;
  text-align: center;
}

.login-kicker {
  margin: 4px 0 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.login-card label { margin: 0 0 14px; color: var(--text-secondary); }
.login-card input { margin-top: 6px; height: 40px; padding: 0 12px; line-height: 38px; }
.login-card button[type=submit] { margin-top: 8px; min-height: 40px; font-size: 14px; }

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 6px;
}

.password-wrap input {
  margin-top: 0;
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  min-height: 30px;
  width: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.password-toggle:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translate(-50%, -6px);
  background: #0f172a;
  color: #f8fafc;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  z-index: 100;
  width: max-content;
  max-width: calc(100vw - 32px);
  overflow-wrap: anywhere;
  text-align: center;
  line-height: 1.45;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#toast.toast-success::before,
#toast.toast-error::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

#toast.toast-success::before { background: #34d399; }
#toast.toast-error::before { background: #fb7185; }

[hidden] { display: none !important; }

/* Comics */
.comic-roles,
.comic-previews { display: flex; flex-wrap: wrap; gap: 12px; }
.comic-previews figure {
  margin: 8px 0 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  width: fit-content;
}
.comic-previews img {
  display: block;
  max-width: min(100%, 14rem);
  max-height: 260px;
  border-radius: 4px;
  object-fit: contain;
}
.comic-previews figcaption { color: var(--muted); font-size: 11px; margin-top: 6px; }

.comic-upload-grid,
#comic-souvenir { margin-top: 12px; }
.comic-upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
  gap: 12px 14px;
}
.comic-upload { min-width: 0; }
.comic-upload-label {
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-weight: 600;
}
.comic-upload-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.comic-upload-box:has(.comic-upload-pick:not([hidden])) { border-style: dashed; }
.comic-upload-box.is-dragging,
.comic-upload-box:has(.comic-upload-pick:hover) {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.comic-upload-box.has-error { border-color: var(--danger-dot); }
.comic-upload-pick {
  flex-direction: column;
  gap: 3px;
  width: 100%;
  min-height: 116px;
  padding: 12px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.comic-upload-pick:hover:not(:disabled) { background: transparent; }
.comic-upload-plus {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 3px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 19px;
  line-height: 1;
}
.comic-upload-pick small,
.comic-upload-size { color: var(--muted); font-size: 12px; }
.comic-upload-selected {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 116px;
  padding: 9px 12px;
}
.comic-upload-media {
  flex: 0 0 72px;
  height: 96px;
  border-radius: 5px;
  background: var(--surface-subtle);
  overflow: hidden;
}
.comic-upload-media :is(canvas, img) {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.comic-upload-details { min-width: 0; }
.comic-upload-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.comic-upload-size:empty { display: none; }
.comic-upload-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.comic-upload-actions button { min-height: 28px; }
.comic-upload-error { color: var(--danger); font-size: 12px; }
.comic-upload-error:not(:empty) { margin-top: 5px; }

/* Activity KPI Cards */
#activity-summary { flex: none; min-width: 0; }
.activity-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.activity-cards .panel {
  flex: none;
  padding: 16px 20px;
  position: relative;
}

.activity-cards .panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.activity-cards .panel:nth-child(2)::before { background: #6366f1; }
.activity-cards .panel:nth-child(3)::before { background: var(--ok-dot); }

.activity-cards strong {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-top: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.activity-cards small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

/* App Releases & Versions */
.app-release-channels { gap: 14px; margin-bottom: 0; }
.app-release-channels > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
}

.channel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.channel-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #cbd5e1;
  flex-shrink: 0;
}

.channel-dot.is-live {
  background: var(--ok-dot);
  box-shadow: 0 0 0 3px var(--ok-bg);
}

.app-release-channels strong {
  margin: 8px 0 4px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.app-release-channels p { margin: 0; color: var(--muted); font-size: 12px; }

.app-release-table { table-layout: fixed; min-width: 980px; }
.app-release-table th { padding: 12px 16px; }
.app-release-table td { padding: 14px 16px; vertical-align: middle; }
.app-release-table th:nth-child(1) { width: 14%; }
.app-release-table th:nth-child(2) { width: 12%; }
.app-release-table th:nth-child(3) { width: 10%; }
.app-release-table th:nth-child(4) { width: 16%; }
.app-release-table th:nth-child(5) { width: 26%; }
.app-release-table th:nth-child(6) { width: 22%; }
.app-release-table td:first-child { white-space: normal; overflow-wrap: anywhere; }
.app-release-table td small { margin-top: 6px; }
.app-release-table .release-error { white-space: normal; overflow-wrap: anywhere; color: var(--danger); }
.app-release-table .release-notes-cell { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }

.release-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.release-actions button { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.release-publish-button { color: var(--brand-hover); border-color: var(--brand-border); background: var(--brand-soft); }
.release-publish-button:hover:not(:disabled) { background: #dbeafe; border-color: #93c5fd; }
.release-pause-button { color: var(--danger); }
.release-pause-button:hover:not(:disabled) { border-color: var(--danger-border); background: var(--danger-bg); }

.apk-checksum { margin-top: 6px; font-size: 11px; color: var(--muted); }
.apk-checksum summary, .release-package-details summary { cursor: pointer; width: fit-content; padding: 3px 0; font-weight: 500; }
.apk-checksum summary:hover, .release-package-details summary:hover { color: var(--brand); }
.apk-digest-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 6px; }
.apk-digest-inline {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}

.apk-digest {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.6;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  flex: 1;
}

.app-release-modal { max-width: 640px; padding: 0; color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.app-release-modal [hidden] { display: none !important; }
.app-release-modal .modal-head { padding: 18px 24px; border-bottom: 1px solid var(--line); margin: 0; }
.app-release-modal .modal-head h2 { font-size: 17px; font-weight: 600; }
.app-release-modal .modal-content { padding: 0; }
.release-form-body { display: grid; gap: 20px; padding: 22px 24px; min-width: 0; }
.release-form-body label { margin: 0; font-size: 13px; font-weight: 500; }
.release-form-body .hint { display: block; margin-top: 6px; font-size: 11px; font-weight: 400; }
.release-form-body input:not([type=checkbox]):not([type=file]) { height: 38px; line-height: 36px; }
.release-form-body input, .release-form-body textarea { margin-top: 6px; }
.release-form-body input[type=checkbox] { margin-top: 2px; }
.release-form-body textarea { min-height: 104px; padding: 10px 12px; }
.release-form-intro { margin: 0; color: var(--muted); font-size: 12px; }
.release-form-body .form-grid { gap: 16px; }

.apk-upload-status { padding: 12px 14px; border: 1px solid var(--brand-border); background: var(--brand-soft); border-radius: 8px; }
.apk-upload-status p { margin: 0; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; color: var(--brand-hover); }
.apk-upload-status progress { width: 100%; height: 6px; margin-top: 10px; accent-color: var(--brand); }
.apk-upload-status.is-error { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.apk-upload-status.is-error p { color: var(--danger); }

.release-package-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}
.release-package-summary > div { min-width: 0; }
.release-package-label { display: block; color: var(--muted); font-size: 11px; }
.release-package-summary strong { display: block; margin-top: 4px; font-size: 19px; overflow-wrap: anywhere; }
.release-package-summary > .muted { white-space: nowrap; font-size: 12px; }

.release-update-notes h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; }
.release-update-notes p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-secondary); font-size: 13px; line-height: 1.7; }

.release-channel-picker { margin: 0; padding: 0; border: 0; background: transparent; min-width: 0; }
.release-channel-picker legend { padding: 0; margin-bottom: 10px; font-size: 13px; font-weight: 600; }
.release-channel-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.release-form-body .release-channel-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}
.release-channel-option:hover { border-color: #cbd5e1; }
.release-channel-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.release-channel-option input { flex-shrink: 0; width: 16px; height: 16px; }
.release-channel-option strong { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.release-channel-option small { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; margin-top: 4px; font-weight: 400; }

.release-package-details { border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font-size: 12px; }
.release-package-details p { margin: 10px 0 4px; font-size: 11px; }
.release-pause-notice { margin: 0; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--danger-border); background: var(--danger-bg); color: var(--danger); font-size: 13px; line-height: 1.7; }
.release-danger-primary { color: #fff; background: var(--danger); border-color: var(--danger); box-shadow: 0 1px 2px rgba(190, 18, 60, 0.25); }
.release-danger-primary:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }

/* App Version Distribution Bar */
.dist-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.dist-bar {
  flex: 1;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--bg-accent);
  overflow: hidden;
  appearance: none;
}

.dist-bar::-webkit-progress-bar {
  background: var(--bg-accent);
  border-radius: 999px;
}

.dist-bar::-webkit-progress-value {
  background: var(--brand);
  border-radius: 999px;
}

.dist-bar::-moz-progress-bar {
  background: var(--brand);
  border-radius: 999px;
}

.dist-val {
  min-width: 56px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
}

/* Responsive */
@media (max-width: 960px) {
  :root { --side-w: 196px; }
  header { padding: 10px 16px; }
  #content { padding: 16px; }
  .search-field { flex-basis: 200px; min-width: 150px; }
}

@media (max-width: 640px) {
  :root { --side-w: 60px; }
  aside { padding: 12px 8px; align-items: center; }
  .brand { padding: 2px 0 12px; justify-content: center; width: 100%; }
  .brand-text, .nav-group-label, .account-user strong, .account button span { display: none; }
  nav { width: 100%; align-items: center; }
  .nav-group { width: 100%; align-items: center; }
  nav a { font-size: 0; gap: 0; justify-content: center; padding: 10px; width: 42px; height: 42px; }
  .account { flex-direction: column; width: 100%; padding: 10px 0 0; }
  .account button { width: 38px; height: 34px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  header { padding: 10px 14px; }
  #crumb-desc { display: none; }
  #content { padding: 12px; gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .target-cards { grid-template-columns: 1fr; }
  dialog { width: calc(100% - 16px); }
  .modal-head { padding: 14px 16px; }
  .modal-content { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  .login { padding: 24px 12px; }
  .login-card { width: 100%; max-width: 360px; padding: 24px 20px; }
  .toolbar { padding: 10px 12px; }
  .search-field { flex: 1 1 100%; }
  .activity-cards { gap: 8px; }
  .activity-cards .panel { padding: 12px 10px; }
  .activity-cards strong { font-size: 22px; }
  .activity-cards small { font-size: 11px; }
  .app-release-channels { grid-template-columns: 1fr; gap: 10px; }
  .app-release-channels > div { padding: 14px 16px; }
  .app-release-modal .modal-head { padding: 16px 18px; }
  .release-form-body { padding: 18px; gap: 16px; }
  .app-release-modal .modal-footer { padding: 12px 18px; }
  .release-channel-options { grid-template-columns: 1fr; }
}
