:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --panel-hover: #f4f4f5;
  --line: #e4e4e7;
  --line-2: #d4d4d8;
  --text: #09090b;
  --muted: #52525b;
  --faint: #71717a;
  --label: #3f3f46;
  --accent: #111111;
  --accent-fg: #ffffff;
  --focus: #2563eb;
  --focus-ring: rgba(37, 99, 235, 0.18);
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 8px;
  --sidebar-w: 244px;
  --header-h: 56px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ——— Auth / centered ——— */
.page-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(37, 99, 235, 0.06), transparent 55%),
    radial-gradient(ellipse 55% 42% at 50% 55%, rgba(0, 0, 0, 0.025), transparent 72%),
    var(--bg);
}
.page-auth-top {
  align-items: flex-start;
  padding-top: 48px;
  padding-bottom: 64px;
}
.auth-wrap { width: min(420px, 100%); }

/* ——— User home (downloads + password) ——— */
.user-home {
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.user-home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.user-home-top .auth-brand { margin-bottom: 0; }
.user-home-account {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-guide-btn {
  text-decoration: none !important;
  white-space: nowrap;
  gap: 6px;
  padding: 8px 12px;
  height: 34px;
  box-sizing: border-box;
}
.user-guide-btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}
.user-home-account-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}
.user-home-phone {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.user-home-expiry {
  font-size: 12px;
  color: var(--faint);
}
.user-section { padding: 22px 22px 20px; }
.user-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.user-section-head h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  line-height: 1.3;
}
.user-section-head .muted { font-size: 12px; }
.user-step {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  background: var(--panel-hover);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  line-height: 1.2;
}
.user-subhead {
  font-size: 13px;
  font-weight: 600;
  color: var(--label);
  margin: 0 0 10px;
}
.user-subhead + .dl-grid { margin-bottom: 18px; }
.dl-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  transition: background .15s, border-color .15s;
}
.dl-row:hover {
  background: var(--panel-hover);
  border-color: var(--line-2);
}
.dl-row-accent {
  background: linear-gradient(180deg, #f8fafc 0%, var(--panel) 100%);
  border-color: #dbe4f0;
}
.dl-row-accent:hover { border-color: #c7d5e8; }
.dl-ico {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text);
  background: var(--panel-hover);
  border: 1px solid var(--line);
}
.dl-ico-win32, .dl-ico-win64 {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #dbeafe;
}
.dl-ico-mac {
  color: #18181b;
  background: #f4f4f5;
}
.dl-ico-config {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.dl-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dl-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.dl-detail {
  font-size: 12px;
  color: var(--faint);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dl-btn {
  flex-shrink: 0;
  min-width: 88px;
  text-decoration: none !important;
}
.dl-btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}
.user-pw-form { max-width: 100%; }
.user-pw-hint {
  margin-top: -8px;
  margin-bottom: 12px;
}
@media (max-width: 560px) {
  .user-home-top { align-items: flex-start; }
  .user-home-account {
    width: 100%;
    justify-content: space-between;
  }
  .user-home-account-text { align-items: flex-start; text-align: left; }
  .dl-detail { white-space: normal; }
  .dl-btn { min-width: 72px; padding-left: 12px; padding-right: 12px; }
}

.auth-wrap-wide { width: min(560px, 100%); }
.section-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 20px 0 6px;
  color: var(--text);
}
.section-title:first-of-type { margin-top: 0; }
.download-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-hover);
}
.download-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.download-label {
  font-size: 14px;
  font-weight: 550;
  color: var(--text);
}
.download-detail {
  font-size: 12px;
  color: var(--faint);
  word-break: break-all;
}
.download-item .btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-eyebrow {
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
}
.auth-wrap .card { width: 100%; }
.card-head { margin-bottom: 20px; }
.card-head h1 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1.3;
}
.card-head p,
.muted { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.5; }
.hint { color: var(--faint); font-size: 12px; margin: 0 0 14px; line-height: 1.45; }
.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 13px;
  padding: 10px 12px;
  margin: 0 0 14px;
}
.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  font-size: 13px;
  padding: 10px 12px;
  margin: 0 0 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--label);
  margin-bottom: 14px;
}
input[type="text"],
input[type="password"],
input:not([type]),
input[type="file"],
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input[readonly] {
  background: var(--panel-hover);
  color: var(--muted);
  cursor: default;
}
input[readonly]:focus {
  border-color: var(--line);
  box-shadow: none;
}
input[type="file"] {
  padding: 8px 10px;
  background: var(--panel-hover);
  font-size: 13px;
}

button, .btn {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
button:hover, .btn:hover { background: #27272a; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--focus); }
button.primary:hover, .btn.primary:hover { background: #1d4ed8; }
button.ghost, .btn.ghost {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}
button.ghost:hover, .btn.ghost:hover { background: var(--panel-hover); }
button.linkish, .btn.linkish {
  background: transparent;
  color: var(--muted);
  padding: 4px 6px;
  border: 0;
  font-weight: 500;
}
button.linkish:hover, .btn.linkish:hover { color: var(--text); background: transparent; }
.btn-block { width: 100%; }

.form-actions { margin-top: 4px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap { gap: 12px; }
.gap-sm { gap: 8px; }

/* ——— Admin shell ——— */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  background: var(--bg);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 18px;
}
.sidebar-brand .brand-mark { width: 32px; height: 32px; font-size: 12px; }
.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 0.04em;
  padding: 8px 12px 6px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: default;
}
.nav-item.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--focus);
}
.nav-item .nav-ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: .85;
}
.nav-item.active .nav-ico { opacity: 1; }
.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--faint);
}

.shell-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--faint);
}
.crumb strong { color: var(--text); font-weight: 550; }
.crumb-sep { color: var(--line-2); }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--panel-hover);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.content {
  padding: 24px 28px 48px;
  width: min(1200px, 100%);
  margin: 0 auto;
}
.content-wide {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px 28px 40px;
}
.page-head { margin-bottom: 16px; }
.page-head h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.page-head .sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 16px;
}
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-title.bare {
  margin: 0;
  gap: 10px;
}
.panel-title.bare span:first-child { margin-right: 4px; }

/* Filter bar — single row, all controls same height */
.filter-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  box-sizing: border-box;
  overflow-x: auto;
}
.filter-bar > .filter-input,
.filter-bar > input.filter-input,
.filter-bar > select.filter-input {
  display: block;
  flex: 0 0 160px;
  width: 160px;
  max-width: 160px;
  height: 34px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  box-sizing: border-box;
}
.filter-bar > select.filter-input.filter-select {
  flex: 0 0 130px;
  width: 130px;
  max-width: 130px;
}
.filter-bar > .ui-select-wrap--filter {
  flex: 0 0 130px;
  width: 130px;
  max-width: 130px;
  height: 34px;
  margin: 0;
}
.filter-bar > .filter-input:focus,
.filter-bar > select.filter-input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.filter-bar > .filter-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: 34px;
  margin: 0;
}
.filter-bar > .filter-actions button,
.filter-bar > .filter-actions .btn {
  height: 34px;
  margin: 0;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* Pagination footer */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  min-height: 56px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  box-sizing: border-box;
}
.pager-info {
  display: inline-flex;
  align-items: center;
  height: 32px;
  margin: 0;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
}
.pager-info strong { color: var(--text); font-weight: 600; }
.pager-size {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
}
.pager-size select {
  display: inline-block;
  width: auto;
  height: 32px;
  margin: 0;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  box-sizing: border-box;
}
.pager-size .ui-select-wrap--pager {
  height: 32px;
  min-width: 115px;
  width: auto;
}
.pager-size .ui-select-wrap--pager .ui-select-trigger {
  width: auto;
  min-width: 115px;
}

/* Custom select (replaces native chrome) */
.ui-select-wrap {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  box-sizing: border-box;
}
.ui-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.ui-select-trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.ui-select-trigger:hover {
  background: var(--panel-hover);
  border-color: var(--line-2);
}
.ui-select-wrap.is-open .ui-select-trigger,
.ui-select-trigger:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--panel);
}
.ui-select-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.ui-select-chevron {
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--faint);
  transition: transform .15s;
}
.ui-select-wrap.is-open .ui-select-chevron {
  transform: rotate(180deg);
  border-top-color: var(--text);
}
.ui-select-menu {
  position: fixed;
  z-index: 1300;
  min-width: 128px;
  max-height: min(280px, calc(100vh - 24px));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
  box-sizing: border-box;
}
.ui-select-menu[hidden] { display: none !important; }
.ui-select-option {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent !important;
  color: var(--text) !important;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  box-shadow: none !important;
}
.ui-select-option:hover {
  background: var(--panel-hover) !important;
  color: var(--text) !important;
}
.ui-select-option.is-selected {
  background: rgba(37, 99, 235, 0.08) !important;
  color: #1d4ed8 !important;
}
.ui-select-option.is-selected:hover {
  background: rgba(37, 99, 235, 0.12) !important;
}

.pager-nav {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  height: 32px;
}
.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  box-sizing: border-box;
}
a.pager-btn:hover {
  border-color: var(--focus);
  color: var(--focus);
}
.pager-btn.current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.pager-btn.disabled {
  color: var(--faint);
  pointer-events: none;
  opacity: 0.55;
}
.pager-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 32px;
  color: var(--faint);
  font-size: 13px;
  line-height: 1;
}

@media (max-width: 720px) {
  .filter-bar {
    flex-wrap: wrap;
  }
  .filter-bar > .filter-input,
  .filter-bar > input.filter-input,
  .filter-bar > select.filter-input,
  .filter-bar > select.filter-input.filter-select,
  .filter-bar > .ui-select-wrap--filter {
    flex: 1 1 calc(50% - 10px);
    width: auto;
    max-width: none;
  }
  .filter-bar > .filter-actions {
    flex: 1 1 100%;
    width: 100%;
  }
  .filter-bar > .filter-actions button,
  .filter-bar > .filter-actions .btn {
    flex: 1;
  }
  .pager-nav { margin-left: 0; width: 100%; }
}

.file-label input[type="file"] {
  margin-top: 6px;
  background: var(--panel);
}

/* Modal dialogs */
.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
}
.modal::backdrop {
  background: rgba(9, 9, 11, 0.48);
}
.modal-card {
  width: min(480px, 100%);
  margin: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.04), 0 20px 56px rgba(0,0,0,.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}
.modal-card-lg { width: min(640px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.modal-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  padding: 0;
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-x:hover { color: var(--text); background: var(--panel-hover); }
.modal-body {
  padding: 8px 22px 12px;
  overflow-y: auto;
  flex: 1;
}
.modal-body > label { margin-bottom: 14px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fafafa;
  flex-shrink: 0;
}
.form-section {
  padding: 14px 0 6px;
  border-bottom: 1px solid var(--line);
}
.form-section:last-child { border-bottom: 0; }
.form-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.form-stack > label { display: block; }
.req { color: var(--danger); font-weight: 600; }
.field-hint {
  margin: -4px 0 12px;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.45;
}
.template-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--panel-hover);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.template-row .btn {
  text-decoration: none;
  padding: 7px 12px;
  font-size: 12.5px;
}
.template-row .btn:hover { text-decoration: none; }

/* Toast (aigc-style top center) */
.toast-host {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast.is-out { opacity: 0; transform: translateY(-6px); }
.toast-ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.toast-err { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content, .content-wide { padding: 16px 16px 32px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .modal-foot { justify-content: stretch; }
  .modal-foot button { flex: 1; }
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-pad { padding: 18px 18px 16px; }
.panel-title {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel + .panel { margin-top: 16px; }

.banner {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 0 0 16px;
  background: var(--panel);
  font-size: 13px;
  color: var(--text);
}
.banner.warn {
  background: var(--warn-bg);
  border-color: #fcd34d;
  color: #92400e;
}
.banner.info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}
.banner pre {
  white-space: pre-wrap;
  margin: 8px 0 0;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(255,255,255,.7);
  border-radius: 4px;
  padding: 8px 10px;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 11px 14px;
  color: var(--faint);
  font-weight: 550;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  background: #fcfcfc;
  white-space: nowrap;
}
tbody td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-hover); }
.cell-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.empty {
  text-align: center;
  color: var(--faint);
  padding: 36px 16px !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.5;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--panel-hover); color: var(--muted); }

.ops {
  white-space: nowrap;
  vertical-align: middle;
}
.ops-bar {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.ops-bar > form { margin: 0; display: inline; }
.ops-link {
  appearance: none;
  border: 0;
  background: transparent !important;
  color: var(--focus) !important;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1.4;
  box-shadow: none !important;
}
.ops-link:hover {
  background: rgba(37, 99, 235, 0.08) !important;
  color: #1d4ed8 !important;
  text-decoration: none;
}
.ops-more {
  position: relative;
  display: inline-flex;
}
.ops-more-btn::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 4px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: .7;
}
.ops-more.is-open .ops-more-btn {
  background: rgba(37, 99, 235, 0.08) !important;
}
.ops-menu {
  position: fixed;
  min-width: 148px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.14);
  padding: 6px;
  z-index: 1200;
}
.ops-menu[hidden] { display: none !important; }
.ops-menu form {
  margin: 0;
  display: block;
}
.ops-menu button,
.ops-menu .ops-menu-item {
  appearance: none;
  border: 0;
  background: transparent !important;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #18181b !important;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  box-shadow: none !important;
  display: block;
}
.ops-menu button:hover,
.ops-menu .ops-menu-item:hover {
  background: #f4f4f5 !important;
  color: #18181b !important;
  text-decoration: none;
}
.ops-menu button.danger,
.ops-menu .ops-menu-item.danger {
  color: #dc2626 !important;
}
.ops-menu button.danger:hover,
.ops-menu .ops-menu-item.danger:hover {
  background: #fef2f2 !important;
  color: #b91c1c !important;
}
.ops-menu-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 8px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 600px) {
  .field-row { grid-template-columns: 1fr; }
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.inline-form .btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-row.fill {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  width: 100%;
}
.stat-row.fill-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat-row.fill-1 {
  grid-template-columns: minmax(0, 240px);
}
.ops-link.danger {
  color: var(--danger);
}
.ops-link.danger:hover {
  color: var(--danger);
  background: var(--danger-bg);
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-width: 0;
}
.stat-row.fill .stat {
  width: 100%;
}
.stat .k { font-size: 12px; color: var(--faint); margin: 0 0 6px; }
.stat .v { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.02em; }
@media (max-width: 900px) {
  .stat-row.fill { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .stat-row.fill { grid-template-columns: 1fr; }
}
