/* ============================================================================
   R2 内容签发控制台 — 样式表（无构建，纯静态）
   ========================================================================== */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1e293b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .92em; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }

/* ---------------- 布局 ---------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex: none; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 18px 18px 14px; font-weight: 700; font-size: 15px; color: #fff; display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 20px; }
.nav { list-style: none; margin: 6px 10px; padding: 0; flex: 1; }
.nav li { margin: 2px 0; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav .nav-icon { width: 18px; text-align: center; }
.sidebar-user { padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; }
.sidebar-user .name { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

/* ---------------- 头部 / 卡片 ---------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  font-size: 13.5px; font-weight: 500; background: var(--panel); transition: background .15s, border-color .15s;
  user-select: none; line-height: 1.4; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; }
.btn-small { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-block { width: 100%; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #374151; margin-bottom: 5px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=number], input[type=search], input[type=password], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; background: #fff; color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37, 99, 235, .25); border-color: var(--primary); }
textarea { min-height: 74px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
.search-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.search-row input { flex: 1; min-width: 220px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.checkbox-row input[type=checkbox] { width: auto; accent-color: var(--primary); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { background: #f8fafc; font-weight: 600; color: #475569; white-space: nowrap; font-size: 12.5px; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #f8fafc; }
table.data .mono, .key-col { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); }
.empty-row td { text-align: center; color: var(--muted); padding: 26px 12px; }

/* ---------------- 徽章 ---------------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

.chip { display: inline-flex; align-items: center; gap: 5px; background: #f1f5f9; border-radius: 999px; padding: 2px 9px 2px 6px; margin: 2px; font-size: 12px; }
.chip .chip-x { cursor: pointer; color: var(--muted); font-weight: 700; padding: 0 2px; }
.chip .chip-x:hover { color: var(--danger); }
.chip-admin { background: #fee2e2; color: #b91c1c; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---------------- 签发结果 ---------------- */
.sign-result { margin-top: 16px; }
.url-box { background: #0f172a; color: #a5f3fc; font-family: var(--mono); font-size: 12px;
  padding: 12px 14px; border-radius: 8px; word-break: break-all; max-height: 150px; overflow-y: auto; }
.url-meta { display: flex; gap: 18px; margin-top: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.ttl-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.ttl-preset { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 12.5px; }
.ttl-preset.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------------- toast ---------------- */
#toast-root { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast {
  background: #111827; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; transform: translateY(-8px);
  transition: opacity .25s, transform .25s; word-break: break-word;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: #b91c1c; }
.toast-success { background: #15803d; }

/* ---------------- dialog ---------------- */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 900;
  display: flex; align-items: flex-start; justify-content: center; padding: 9vh 16px 16px;
  opacity: 0; transition: opacity .18s;
}
.dialog-overlay.show { opacity: 1; }
.dialog {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 78vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(15,23,42,.3);
  transform: translateY(8px); transition: transform .18s;
}
.dialog-overlay.show .dialog { transform: none; }
.dialog-title { margin: 0; padding: 16px 20px 0; font-size: 16px; }
.dialog-body { padding: 14px 20px; overflow-y: auto; }
.dialog-footer { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); margin-top: 4px; }
.confirm-text { margin: 4px 0; }

/* ---------------- 登录页 ---------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.35); padding: 34px 36px; width: 100%; max-width: 400px; text-align: center; }
.login-card .logo-big { font-size: 40px; }
.login-card h1 { font-size: 19px; margin: 10px 0 4px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-err { background: #fee2e2; color: #b91c1c; border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.login-note { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------------- 杂项 ---------------- */
.loading { color: var(--muted); text-align: center; padding: 40px 0; font-size: 13.5px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(37,99,235,.25); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #fee2e2; color: #b91c1c; }
.alert-success { background: #dcfce7; color: #166534; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.divider { border-top: 1px dashed var(--border); margin: 14px 0; }
.perm-list { display: flex; flex-direction: column; gap: 6px; }
.perm-item { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 7px 11px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.perm-item .mono { font-family: var(--mono); }

@media (max-width: 860px) {
  .sidebar { position: static; width: 100%; height: auto; }
  .layout { flex-direction: column; }
  .main { padding: 18px 14px 50px; }
  .nav { display: flex; flex-wrap: wrap; }
}