:root {
  --bg-deep: #f3f5f8; --bg-primary: #ffffff; --bg-secondary: #f7f9fc;
  --bg-card: #fbfcfe; --bg-card-hover: #f0f3f7; --bg-glass: rgba(255,255,255,0.82);
  --text-primary: #172033; --text-secondary: #465268;
  --text-muted: #69758a; --text-dim: #98a4b7;
  --accent: #2f7cff; --accent-light: #6b5cff;
  --success: #22c55e; --warning: #f59e0b;
  --accent-soft: rgba(47,124,255,0.08); --error: #f87171;
  --border: rgba(49,85,130,0.08); --border-light: rgba(49,85,130,0.14);
  --radius: 18px;
}
[data-theme="dark"] {
  --bg-deep: #0f0f20; --bg-primary: #161630; --bg-secondary: #1e1e3a;
  --bg-card: #262648; --bg-card-hover: #323258; --bg-glass: rgba(28,28,52,0.82);
  --text-primary: #eeeef8; --text-secondary: #b9b9d8;
  --text-muted: #9090b4; --text-dim: #6e6e88;
  --accent-soft: rgba(124,92,252,0.1);
  --border: rgba(255,255,255,0.08); --border-light: rgba(255,255,255,0.14);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% 26%, rgba(220, 225, 232, 0.78), transparent 42%),
    linear-gradient(180deg, #f5f7fa 0%, #fbfcfe 52%, #f3f6f9 100%);
  color: var(--text-primary);
  min-height: 100vh; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
.header {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  width: 176px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 10px;
  background: linear-gradient(180deg, rgba(247, 249, 252, 0.98), rgba(235, 240, 247, 0.94));
  border-right: 1px solid rgba(82, 96, 120, 0.1);
  box-shadow: 12px 0 30px rgba(82, 96, 120, 0.08);
}
.header h1 { display:flex; align-items:center; gap:8px; padding: 0 6px; font-size: 1rem; font-weight: 800; color:#1e2a3c; letter-spacing: 0; white-space: nowrap; }
.admin-logo { width:26px; height:26px; object-fit:contain; display:block; flex: 0 0 auto; }
.header-actions {
  margin-top: auto;
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.btn {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-secondary); color: var(--text-secondary);
  font-size: 0.82rem; cursor: pointer; font-weight: 500; transition: all 0.15s;
}
.btn:hover { background: var(--bg-card-hover); color: var(--text-primary); transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, #1d7cff, #725cff); color: #fff; border-color: transparent; box-shadow: 0 8px 18px rgba(47,124,255,0.18); }
.btn-primary:hover { opacity: 0.92; }
.btn.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: wait;
  opacity: 0.72;
  pointer-events: none;
}
.btn.is-loading::before {
  content: "";
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.btn-danger { background: transparent; border: 1px solid var(--error); color: var(--error); }
.btn-danger:hover { background: rgba(248,113,113,0.12); }
.btn-sm { padding: 4px 10px; font-size: 0.74rem; }
.btn-cancel { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-cancel:hover { background: var(--bg-secondary); }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px; border: 1px solid rgba(82,96,120,0.12); border-radius: 12px;
  background: rgba(255,255,255,0.74); color: var(--text-secondary); cursor: pointer;
  font-size: 0.86rem; text-decoration: none; transition: all 0.15s; font-weight: 650;
  justify-content: flex-start;
}
.back-btn:hover { background: var(--accent-soft); color: var(--text-primary); border-color: var(--accent); }

.container {
  max-width: none;
  margin: 0;
  padding: 24px 28px 40px 204px;
}
.container:has(#panelImages.active) {
  max-width: none;
  width: 100%;
  padding: 24px 28px 40px 204px;
}
#panelImages {
  width: 100%;
}

/* Tabs */
#mainTabs { display: flex; flex-direction: column; gap: 8px; }
#mainTabs .tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #657386;
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 650;
  line-height: 1;
  text-align: left;
  transition: all 0.15s;
}
#mainTabs .tab-btn span {
  display: block;
  line-height: 1;
  min-width: 0;
  text-align: left;
  white-space: nowrap;
}
#mainTabs .tab-btn .nav-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.nav-icon,
.shortcut-icon svg,
.status-icon,
.back-btn svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#mainTabs .tab-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.62); }
#mainTabs .tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, #1682ff, #5c8cff);
  box-shadow: 0 10px 22px rgba(34, 124, 255, 0.24);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.advertisement-table-card { overflow-x: auto; }
.advertisement-thumb { display:block; width:96px; height:38px; object-fit:contain; border:1px solid var(--border); border-radius:6px; background:var(--bg-secondary); }
.advertisement-link-cell { max-width:260px; }
.advertisement-link { display:block; max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--accent); text-decoration:none; }
.advertisement-link:hover { text-decoration:underline; }

.toolbar {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.card {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(89, 130, 178, 0.08);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(74, 124, 190, 0.09);
}
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas:
    "overview quick"
    "cost quick"
    "announcement quick"
    "api quick";
  gap: 16px;
  align-items: start;
}
.dashboard-overview { grid-area: overview; }
.dashboard-quick-card { grid-area: quick; position: sticky; top: 18px; }
.dashboard-api-card { grid-area: api; }
.dashboard-cost-card { grid-area: cost; }
.dashboard-announcement-card { grid-area: announcement; }
.data-board-panel { padding: 16px 18px 18px; }
.data-board-body {
  display: block;
}
.data-board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.data-board-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: #111827;
  font-size: 1.18rem;
  font-weight: 850;
}
.data-board-title span {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 500;
}
.data-board-refresh {
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}
.data-board-refresh:hover { color: var(--accent); background: var(--accent-soft); }
.data-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.data-metric {
  min-height: 90px;
  padding: 13px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #f7f9fc);
  border: 1px solid rgba(82,96,120,0.08);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: center;
}
.data-metric.is-loading {
  background: linear-gradient(180deg, #fff, #f8fbff);
}
.data-metric-main {
  min-width: 0;
}
.data-metric-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
  margin-bottom: 9px;
}
.data-metric-value {
  color: #111827;
  font-size: 1.62rem;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0;
}
.data-metric.is-loading .data-metric-value {
  color: #9aa7ba;
}
.data-metric-trend {
  align-self: stretch;
  min-height: 46px;
}
.data-metric-trend svg {
  width: 100%;
  height: 100%;
  display: block;
}
.dashboard-loading-line,
.dashboard-trend-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #edf2f8 0%, #f8fbff 42%, #edf2f8 100%);
  background-size: 220% 100%;
  animation: dashboardShimmer 1.15s ease-in-out infinite;
}
.dashboard-trend-skeleton {
  width: 100%;
  height: 100%;
  min-height: 46px;
  border-radius: 12px;
}
.dashboard-loading-text,
.dashboard-state-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #7f8ba0;
}
.dashboard-loading-text::before,
.dashboard-state-loading::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(47, 124, 255, 0.18);
  border-top-color: #2f7cff;
  animation: dashboardSpin 0.8s linear infinite;
}
.dashboard-table-loading td {
  color: var(--text-dim);
  text-align: center;
  padding: 18px;
}
@keyframes dashboardSpin {
  to { transform: rotate(360deg); }
}
@keyframes dashboardShimmer {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}
.shortcut-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.shortcut-btn {
  min-height: 92px;
  border: 1px solid rgba(89,130,178,0.08);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f7fbff);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 650;
  transition: transform 0.15s, box-shadow 0.15s;
}
.shortcut-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px rgba(47,124,255,0.14);
  color: var(--text-primary);
}
.shortcut-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #2f7cff, #725cff);
}
.shortcut-icon svg,
.status-icon {
  display: block;
  margin: auto;
}
#mainTabs .nav-icon,
.back-btn svg {
  display: block;
  margin: 0;
}
.shortcut-btn:nth-child(2) .shortcut-icon { background: linear-gradient(135deg, #20a5ff, #2f7cff); }
.shortcut-btn:nth-child(3) .shortcut-icon { background: linear-gradient(135deg, #22c55e, #16a3b8); }
.shortcut-btn:nth-child(4) .shortcut-icon { background: linear-gradient(135deg, #f59e0b, #ff7a1a); }
.site-status-mini {
  padding: 10px 18px 10px;
  border-bottom: 1px solid var(--border);
}
.site-status-mini-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.site-status-title {
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 780;
  margin-bottom: 5px;
}
.site-status-bars {
  height: 26px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
}
.site-status-bar {
  width: 5px;
  min-height: 6px;
  border-radius: 999px;
  background: #d9e2ef;
}
.site-status-bar.success { background: #43c88a; }
.site-status-bar.abnormal { background: #e74b67; }
.site-status-bar.processing { background: #f4a62a; }
.site-status-rate {
  min-width: 86px;
  text-align: right;
  color: #dc2453;
  font-size: 1.22rem;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0;
}
.site-status-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  color: var(--text-dim);
  font-size: 0.72rem;
}
.site-status-meta strong {
  color: var(--text-secondary);
  font-weight: 650;
}
.site-status-error-btn {
  border: none;
  background: transparent;
  color: #dc2453;
  cursor: pointer;
  font: inherit;
  font-weight: 760;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.site-status-error-btn:disabled {
  color: var(--text-dim);
  cursor: default;
  text-decoration: none;
}
.operation-list {
  padding: 6px 18px 18px;
  display: grid;
  gap: 10px;
}
.operation-btn {
  width: 100%;
  border: 1px solid rgba(82,96,120,0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #f7f9fc);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s, box-shadow 0.15s;
}
.operation-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(82,96,120,0.1);
}
.operation-btn strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.86rem;
  font-weight: 760;
}
.operation-btn span {
  display: block;
  color: var(--text-dim);
  font-size: 0.72rem;
  margin-top: 2px;
}
.operation-btn .operation-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff;
  background: linear-gradient(135deg, #2f7cff, #725cff);
  line-height: 0;
}
.operation-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  margin: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.operation-btn:nth-child(2) .operation-icon { background: linear-gradient(135deg, #20a5ff, #2f7cff); }
.operation-btn:nth-child(3) .operation-icon { background: linear-gradient(135deg, #f59e0b, #ff7a1a); }
.operation-btn:nth-child(4) .operation-icon { background: linear-gradient(135deg, #22c55e, #16a3b8); }
.dashboard-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.dashboard-section-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text-primary);
}
.dashboard-section-title span {
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 400;
}
.announcement-empty {
  padding: 34px 18px;
  color: var(--text-dim);
  text-align: center;
  font-size: 0.86rem;
}
.announcement-content-cell {
  max-width: 680px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}
.cost-stats-panel {
  padding: 16px 18px 18px;
  display: grid;
  gap: 14px;
}
.cost-filter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto auto;
  gap: 10px;
  align-items: end;
}
.cost-filter-row label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-dim);
  font-size: 0.72rem;
}
.cost-filter-row input,
.cost-filter-row select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0 10px;
  font-size: 0.82rem;
}
.cost-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.cost-period-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: #f2f5f9;
  border: 1px solid rgba(82,96,120,0.08);
}
.cost-period-btn {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.cost-period-btn.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 6px 14px rgba(82,96,120,0.1);
}
.cost-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.72fr);
  gap: 14px;
  align-items: start;
}
.cost-left-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
  align-content: start;
}
.api-trend-chart {
  min-height: 300px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f7f9fc);
  border: 1px solid rgba(82,96,120,0.08);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}
.api-trend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 750;
}
.api-trend-canvas-wrap {
  position: relative;
  min-height: 250px;
}
.api-trend-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.api-trend-empty {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--text-dim);
  font-size: 0.82rem;
  pointer-events: none;
}
.api-trend-empty.show { display: grid; }
.cost-summary-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 68px;
  padding: 8px 10px;
  background: var(--bg-secondary);
}
.cost-summary-label {
  color: var(--text-dim);
  font-size: 0.7rem;
  margin-bottom: 3px;
}
.cost-summary-value {
  color: var(--text-primary);
  font-size: 1.12rem;
  line-height: 1.15;
  font-weight: 750;
}
.cost-summary-sub {
  color: var(--text-dim);
  font-size: 0.68rem;
  margin-top: 2px;
}
.cost-breakdown-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.cost-breakdown-title {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 650;
  margin-bottom: 6px;
}
.cost-breakdown-table {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.64);
}
.cost-breakdown-table table {
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}
.cost-breakdown-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.cost-breakdown-table th,
.cost-breakdown-table td {
  padding: 8px 10px;
  font-size: 0.78rem;
}
@media (max-width: 1100px) {
  .cost-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cost-summary-grid, .cost-breakdown-grid, .cost-content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1280px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "overview"
      "quick"
      "cost"
      "announcement"
      "api";
  }
  .dashboard-quick-card { position: static; }
  .dashboard-overview { grid-template-columns: 1fr; }
  .data-board-body { grid-template-columns: 1fr; }
  .shortcut-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .header {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid rgba(74,124,190,0.12);
  }
  #mainTabs {
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  #mainTabs .tab-btn {
    flex: 0 0 auto;
    width: auto;
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.84rem;
  }
  .header-actions {
    position: static;
    margin-top: 0;
  }
  .container,
  .container:has(#panelImages.active) {
    padding: 18px 14px 32px;
  }
  .data-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shortcut-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .settings-actions {
    padding-left: 0;
  }
}
@media (max-width: 560px) {
  .shortcut-grid,
  .data-metric-grid,
  .cost-filter-row {
    grid-template-columns: 1fr;
  }
  .dashboard-section-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
.announcement-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid transparent;
}
.announcement-status-active {
  background: rgba(34,197,94,0.12);
  color: var(--success);
  border-color: rgba(34,197,94,0.24);
}
.announcement-status-expired {
  background: rgba(248,113,113,0.12);
  color: var(--error);
  border-color: rgba(248,113,113,0.22);
}
.announcement-status-forever {
  background: rgba(124,92,252,0.14);
  color: var(--accent-light);
  border-color: rgba(124,92,252,0.22);
}
.settings-form {
  padding: 18px;
  display: grid;
  gap: 14px;
}
.settings-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}
.settings-row label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 132px;
}
.settings-status {
  color: var(--text-dim);
  font-size: 0.78rem;
}
.modal.settings-modal {
  width: min(520px, 92vw);
  padding: 28px 36px 30px;
  overflow-y: auto;
}
.modal.settings-modal.settings-modal-wide {
  width: min(760px, 92vw);
}
.settings-modal-head {
  display: block;
  padding: 0;
  border-bottom: none;
  margin-bottom: 24px;
}
.settings-modal-title {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 820;
  line-height: 1.2;
}
.settings-modal-desc {
  display: none;
}
.settings-modal-close {
  display: none;
}
.settings-modal-close:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}
.settings-modal .settings-form {
  padding: 0;
  gap: 18px;
}
.settings-modal .settings-row {
  display: block;
}
.settings-modal .settings-row > label:first-child {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
}
.settings-modal .settings-row input:not([type="checkbox"]):not([type="file"]),
.settings-modal .settings-row select,
.settings-modal .settings-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.84rem;
}
.settings-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0;
  margin-top: 28px;
  border-top: none;
  background: transparent;
}
.settings-modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}
.settings-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-qr-preview {
  width: 86px;
  height: 86px;
  border: 1px solid var(--border);
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-secondary);
  display: none;
}
.settings-ad-preview {
  width: min(220px, 100%);
  max-height: 150px;
  border: 1px solid var(--border);
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg-secondary);
  display: none;
}
.settings-file-input {
  font-size: 0.78rem;
}
.settings-inline-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.settings-inline-tools select,
.settings-inline-tools input {
  min-width: 180px;
  flex: 1 1 180px;
}
.api-profile-grid {
  padding: 14px 18px 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 10px;
}
.api-profile-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 126px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
}
.api-profile-card.active {
  border-color: rgba(124,92,252,0.38);
  box-shadow: 0 10px 24px rgba(124,92,252,0.08);
  background: linear-gradient(180deg, rgba(124,92,252,0.08), var(--bg-secondary));
}
.api-profile-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.api-profile-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}
.api-profile-rank {
  flex: 0 0 auto;
  min-width: 30px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(23,162,184,0.1);
  color: #138496;
  font-size: 0.66rem;
  font-weight: 800;
  text-align: center;
}
.api-profile-title {
  min-width: 0;
  max-width: 120px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-primary);
  overflow-wrap: anywhere;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.api-profile-badge {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(124,92,252,0.14);
  color: var(--accent-light);
  font-size: 0.66rem;
  font-weight: 700;
}
.api-profile-meta {
  display: grid;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}
.api-profile-meta span {
  overflow-wrap: anywhere;
}
.api-profile-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.api-profile-options {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.api-profile-chip {
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.64rem;
}
.api-profile-chip.off {
  color: #d93025;
  border-color: rgba(217,48,37,0.24);
  background: rgba(217,48,37,0.06);
}
.api-profile-card-actions {
  margin-top: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.api-profile-card-actions .btn {
  padding: 4px 8px;
  font-size: 0.7rem;
}
.api-profile-status {
  padding: 0 18px 16px;
}
.api-profile-modal {
  max-width: 520px;
}
.api-profile-modal textarea {
  width: 100%;
  resize: vertical;
  min-height: 74px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
}
.api-profile-modal .two-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}
.api-profile-modal .two-cols .option-row {
  grid-template-columns: minmax(0, 1fr);
  align-content: end;
}
.api-profile-modal .two-cols .settings-help {
  font-size: 0.72rem;
}
.api-profile-modal .option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
  align-items: center;
}
.api-profile-modal .option-row label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.api-profile-modal .option-row input[type="checkbox"] {
  width: auto;
}
.api-profile-detail-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.api-profile-detail-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-size: 0.82rem;
}
.api-profile-detail-item span {
  color: var(--text-dim);
}
.api-profile-detail-item strong {
  color: var(--text-primary);
  font-weight: 600;
  overflow-wrap: anywhere;
}
@media (min-width: 1180px) {
  .api-profile-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.user-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.user-filter-left,
.user-filter-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.user-search-input {
  width: 260px;
  max-width: min(100%, 70vw);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.82rem;
}
.user-page-size {
  width: auto;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.82rem;
}
.user-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}
table {
  width: 100%;
  min-width: 760px;
  table-layout: fixed;
  border-collapse: collapse;
}
.card:has(> table) {
  overflow-x: auto;
  overflow-y: hidden;
}
.card:has(#userTable) {
  overflow: visible;
}
th, td {
  min-width: 0;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.82rem;
  vertical-align: middle;
}
th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
td {
  border-top: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table:has(#announcementTable) { min-width: 860px; }
table:has(#userTable) { min-width: 1080px; }
table:has(#typeTable) { min-width: 1120px; }
table:has(#styleOptionTable),
table:has(#colorOptionTable) { min-width: 720px; }
table:has(#orderTable),
table:has(#queueTable) { min-width: 1080px; }
table:has(#cdkTable) { min-width: 980px; }
table:has(#announcementTable) th:nth-child(5),
table:has(#announcementTable) td:nth-child(5),
table:has(#styleOptionTable) th:nth-child(4),
table:has(#styleOptionTable) td:nth-child(4),
table:has(#colorOptionTable) th:nth-child(4),
table:has(#colorOptionTable) td:nth-child(4) { width: 150px; }
table:has(#userTable) th:nth-child(2),
table:has(#userTable) td:nth-child(2),
table:has(#userTable) th:nth-child(7),
table:has(#userTable) td:nth-child(7),
table:has(#typeTable) th:nth-child(3),
table:has(#typeTable) td:nth-child(3),
table:has(#typeTable) th:nth-child(4),
table:has(#typeTable) td:nth-child(4),
table:has(#typeTable) th:nth-child(5),
table:has(#typeTable) td:nth-child(5),
table:has(#queueTable) th:nth-child(4),
table:has(#queueTable) td:nth-child(4) { width: 82px; }
table:has(#userTable) th:nth-child(1),
table:has(#userTable) td:nth-child(1) { width: 128px; }
table:has(#userTable) th:nth-child(3),
table:has(#userTable) td:nth-child(3) { width: 106px; }
table:has(#userTable) th:nth-child(4),
table:has(#userTable) td:nth-child(4) { width: 150px; }
table:has(#userTable) th:nth-child(5),
table:has(#userTable) td:nth-child(5) { width: 150px; }
table:has(#userTable) th:nth-child(6),
table:has(#userTable) td:nth-child(6) { width: 210px; }
table:has(#userTable) th:nth-child(8),
table:has(#userTable) td:nth-child(8) { width: 150px; }
table:has(#userTable) th:nth-child(9),
table:has(#userTable) td:nth-child(9) { width: 286px; }
table:has(#typeTable) th:nth-child(1),
table:has(#typeTable) td:nth-child(1),
table:has(#queueTable) th:nth-child(3),
table:has(#queueTable) td:nth-child(3) { width: 130px; }
table:has(#typeTable) th:nth-child(2),
table:has(#typeTable) td:nth-child(2) { width: 120px; }
table:has(#typeTable) th:nth-child(7),
table:has(#typeTable) td:nth-child(7) { width: 200px; }
table:has(#userTable) td:nth-child(9) { overflow: visible; }
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; }
.role-admin { background: rgba(124,92,252,0.2); color: var(--accent-light); }
.role-user { background: var(--accent-soft); color: var(--text-muted); }
.risk-badge { display:inline-flex;align-items:center;justify-content:center;min-width:72px;padding:2px 8px;border-radius:999px;font-size:0.7rem;font-weight:700;border:1px solid transparent;white-space:nowrap; }
.risk-lv1 { background:rgba(34,197,94,0.12);color:var(--success);border-color:rgba(34,197,94,0.22); }
.risk-lv2 { background:rgba(245,158,11,0.12);color:var(--warning);border-color:rgba(245,158,11,0.22); }
.risk-lv3 { background:rgba(249,115,22,0.14);color:#f97316;border-color:rgba(249,115,22,0.24); }
.risk-lv4 { background:rgba(248,113,113,0.14);color:var(--error);border-color:rgba(248,113,113,0.26); }
.user-meta { margin-top:4px;color:var(--text-dim);font-size:0.72rem;line-height:1.35; }
.actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.actions-user {
  justify-content: flex-end;
  gap: 5px;
}
.actions .btn { flex: 0 0 auto; }
.row-actions-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: visible;
  --row-actions-popover-gap: 6px;
}
.row-actions-trigger {
  min-width: 58px;
}
.row-actions-popover {
  position: absolute;
  right: 0;
  top: calc(100% + var(--row-actions-popover-gap));
  z-index: 30;
  min-width: 118px;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 16px 34px rgba(15,23,42,0.16);
}
.row-actions-popover::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(-1 * var(--row-actions-popover-gap) - 2px);
  height: calc(var(--row-actions-popover-gap) + 2px);
}
.row-actions-menu:hover .row-actions-popover,
.row-actions-menu:focus-within .row-actions-popover {
  display: flex;
}
.row-actions-popover .btn {
  width: 100%;
  justify-content: center;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  min-width: 48px;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status-queued { background: rgba(245,158,11,0.12); color: var(--warning); border-color: rgba(245,158,11,0.22); }
.status-running { background: rgba(124,92,252,0.14); color: var(--accent-light); border-color: rgba(124,92,252,0.22); }
.status-done { background: rgba(34,197,94,0.12); color: var(--success); border-color: rgba(34,197,94,0.22); }
.status-error { background: rgba(248,113,113,0.12); color: var(--error); border-color: rgba(248,113,113,0.22); }
.task-id-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
  color: var(--text-muted);
}
.queue-detail {
  max-width: 420px;
  max-height: 5.2em;
  overflow: auto;
  white-space: pre-line;
  line-height: 1.35;
  color: var(--text-muted);
}

.config-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
}
.config-tab-btn {
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.config-tab-btn:hover {
  color: var(--text-primary);
  background: var(--accent-soft);
}
.config-tab-btn.active {
  color: #fff;
  background: var(--accent);
}
.config-tab-panel { display: none; }
.config-tab-panel.active { display: block; }
.type-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.type-filter-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.15s;
}
.type-filter-tab:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}
.type-filter-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
}

.masonry-grid {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}
.masonry-item {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  width: 180px;
}
.masonry-item:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.masonry-item .img-wrapper {
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
}
.masonry-item .img-wrapper .skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }
.masonry-item .img-wrapper img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.masonry-item .img-wrapper img.loaded + .skeleton {
  display: none;
}
.masonry-item .item-info {
  padding: 10px 12px;
}
.masonry-item .item-info .item-type {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.masonry-item .item-info .item-meta {
  font-size: 0.66rem;
  color: var(--text-dim);
  margin-top: 4px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}
.masonry-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 50%;
  background: rgba(15,15,32,0.58);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.16s, transform 0.16s, background 0.16s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.masonry-item:hover .masonry-delete-btn,
.masonry-delete-btn:focus-visible {
  opacity: 1;
  transform: translateY(0);
}
.masonry-delete-btn:hover {
  background: rgba(248,113,113,0.88);
}
.masonry-delete-btn svg {
  width: 15px;
  height: 15px;
}
#imgLoading { display: none; }
#imgLoading.show,
#imgLoading.observe-sentinel { display: block; }
#imgLoading.observe-sentinel:not(.show) {
  height: 1px;
  padding: 1px;
  overflow: hidden;
  color: transparent;
}
#imgLoading.observe-sentinel:not(.show) * { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15,15,32,0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
[data-theme="light"] .modal-overlay { background: rgba(240,240,245,0.82); }
.modal-overlay.show { display: flex; }
.modal {
  width: min(460px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.18);
  color: var(--text-primary);
}
.modal h2 { font-size: 1rem; margin-bottom: 16px; }
.api-error-modal {
  width: min(860px, 92vw);
}
.api-error-log-list {
  max-height: 62vh;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}
.api-error-log-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--bg-secondary);
}
.api-error-log-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.api-error-log-title {
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 750;
  margin-bottom: 6px;
}
.api-error-log-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 0.72rem;
  margin: -2px 0 8px;
}
.api-error-dot {
  color: var(--text-dim);
  opacity: 0.65;
}
.api-error-log-detail {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.55;
  max-height: 220px;
  overflow-y: auto;
}
.api-error-empty {
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.84rem;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(0,0,0,0.48);
  color: #fff;
  cursor: pointer;
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.84rem;
}
.field textarea { resize: vertical; min-height: 92px; }
.combo-field {
  position: relative;
}
.combo-options {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-primary);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.14);
}
.combo-options.show {
  display: grid;
  gap: 3px;
}
.combo-option {
  width: 100%;
  border: none;
  border-radius: 7px;
  padding: 8px 10px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}
.combo-option:hover,
.combo-option.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.combo-empty {
  padding: 10px;
  color: var(--text-dim);
  font-size: 0.78rem;
}
.field-help {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.5;
}
.advanced-field {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
}
.advanced-field summary {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  user-select: none;
}
.advanced-field[open] summary { margin-bottom: 10px; }
.advanced-field .field { margin-bottom: 0; }
.quota-current {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
}
.quota-current-title {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
}
.quota-current-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.quota-current-item {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
}
.quota-current-item span {
  display: block;
  color: var(--text-dim);
  font-size: 0.68rem;
  line-height: 1.35;
}
.quota-current-item strong {
  display: block;
  margin-top: 2px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.quota-current-note {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1.45;
}
@media (max-width: 520px) {
  .quota-current-grid { grid-template-columns: 1fr; }
}
.preview-thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: block;
}
.preview-empty {
  color: var(--text-dim);
  font-size: 0.72rem;
}
.preview-field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.preview-paste-zone {
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px dashed var(--border-light);
  border-radius: 8px;
  color: var(--text-dim);
  background: var(--bg-secondary);
  font-size: 0.74rem;
  outline: none;
}
.preview-paste-zone:focus {
  border-color: var(--accent);
  color: var(--text-secondary);
  background: var(--accent-soft);
}
.preview-field-row input[type="file"] {
  padding: 6px;
  font-size: 0.78rem;
}
.preview-modal-img {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: none;
}
.error {
  min-height: 20px;
  color: var(--error);
  font-size: 0.78rem;
  margin: 4px 0 10px;
}
.btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.modal-image {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
}
.modal-image img {
  display: block;
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  cursor: zoom-in;
}
.modal-info {
  width: 320px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.modal-prompt-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.modal-prompt-text {
  min-height: 140px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.7;
  word-break: break-all;
  white-space: pre-wrap;
}
.modal-ref-section {
  display: none;
  flex-direction: column;
  gap: 8px;
}
.modal-ref-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.modal-ref-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary);
  cursor: zoom-in;
}
.modal-ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.modal-ref-thumb span {
  position: absolute;
  left: 5px;
  bottom: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.56);
  color: #fff;
  font-size: 0.68rem;
  line-height: 1.3;
}
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.modal-actions .btn-action {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.modal-actions .btn-action-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.image-preview-dialog {
  display: flex;
  flex-direction: row;
  width: min(1120px, 94vw);
  height: min(85vh, 760px);
  max-height: 85vh;
  padding: 0;
  overflow: hidden;
  position: relative;
  border-radius: 20px;
}

#imgPreviewModal .modal-img-zone {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

#imgPreviewModal .modal-image img {
  max-height: 100%;
  cursor: zoom-in;
}

#imgPreviewModal .modal-info {
  flex: 0 0 360px;
  width: 360px;
  min-width: 320px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 20px 20px;
}

#imgPreviewModal .modal-prompt-text {
  flex: 0 0 auto;
  min-height: 120px;
  max-height: 260px;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

#imgPreviewModal .modal-ref-section {
  flex: 0 0 auto;
  max-height: 168px;
  overflow-y: auto;
  padding-right: 2px;
}

#imgPreviewModal .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 2px;
  padding-top: 12px;
  padding-bottom: 2px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}
.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.confirm-dialog-overlay.show { opacity: 1; }
.confirm-dialog {
  position: relative;
  width: min(500px, calc(100vw - 40px));
  min-height: 0;
  padding: 34px 36px 30px;
  border-radius: 20px;
  background: #fff;
  color: #111827;
  box-shadow: 0 26px 70px rgba(0,0,0,0.22);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.confirm-dialog-overlay.show .confirm-dialog { transform: scale(1) translateY(0); }
.confirm-dialog-close {
  position: absolute;
  top: 26px;
  right: 28px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #111827;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.confirm-dialog-close:hover { background: #f3f4f6; }
.confirm-dialog-close:active { transform: scale(0.94); }
.confirm-dialog-title {
  margin: 0 42px 24px 0;
  color: #111827;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
}
.confirm-dialog-message {
  margin: 0;
  min-height: 0;
  color: #667085;
  font-size: 0.95rem;
  line-height: 1.6;
}
.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
}
.confirm-dialog-btn {
  min-width: 96px;
  height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, color 0.15s;
}
.confirm-dialog-btn:active { transform: scale(0.97); }
.confirm-dialog-btn-cancel { background: #f0f0f0; color: #111827; }
.confirm-dialog-btn-cancel:hover { background: #e7e7e7; }
.confirm-dialog-btn-confirm { background: #0d0d10; color: #fff; }
.confirm-dialog-btn-confirm:hover { background: #1f1f23; }
[data-theme="dark"] .confirm-dialog {
  background: #2c2c2c;
  color: #ebebf5;
  box-shadow: 0 28px 78px rgba(0,0,0,0.48);
}
[data-theme="dark"] .confirm-dialog-title,
[data-theme="dark"] .confirm-dialog-close { color: #ebebf5; }
[data-theme="dark"] .confirm-dialog-message { color: rgba(235,235,245,0.64); }
[data-theme="dark"] .confirm-dialog-close:hover,
[data-theme="dark"] .confirm-dialog-btn-cancel {
  background: rgba(255,255,255,0.08);
  color: #ebebf5;
}
[data-theme="dark"] .confirm-dialog-btn-cancel:hover { background: rgba(255,255,255,0.13); }
[data-theme="dark"] .confirm-dialog-btn-confirm { background: #ebebf5; color: #1d1d1f; }
[data-theme="dark"] .confirm-dialog-btn-confirm:hover { background: #fff; }
@media (max-width: 860px) {
  .image-preview-dialog {
    flex-direction: column;
    width: min(94vw, 640px);
    height: min(90vh, 760px);
    max-height: 90vh;
  }
  #imgPreviewModal .modal-img-zone {
    flex: 1 1 52%;
    height: auto;
  }
  #imgPreviewModal .modal-info {
    flex: 1 1 48%;
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
@media (max-width: 640px) {
  .confirm-dialog {
    width: min(100%, calc(100vw - 32px));
    min-height: 0;
    padding: 28px 20px 22px;
    border-radius: 18px;
  }
  .confirm-dialog-close { top: 20px; right: 18px; }
  .confirm-dialog-title { margin-bottom: 20px; font-size: 1.15rem; }
  .confirm-dialog-message { min-height: 0; font-size: 0.95rem; }
  .confirm-dialog-actions { gap: 10px; margin-top: 24px; }
  .confirm-dialog-btn { flex: 1; min-width: 0; height: 44px; padding: 0 16px; }
  .masonry-delete-btn {
    opacity: 1;
    transform: none;
  }
}

/* 统一后台弹窗关闭按钮和底部操作按钮。 */
.modal-close,
.settings-modal-close,
.confirm-dialog-close {
  position: absolute !important;
  top: 22px !important;
  right: 22px !important;
  z-index: 20 !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  border: 1px solid transparent !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: #111827 !important;
  box-shadow: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  transform: none !important;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease !important;
}

.modal-close::before,
.settings-modal-close::before,
.confirm-dialog-close::before {
  content: "×";
  font-size: 26px;
  line-height: 1;
  font-weight: 400;
}

.modal-close:hover,
.settings-modal-close:hover,
.confirm-dialog-close:hover {
  background: rgba(17,24,39,0.08) !important;
  border-color: transparent !important;
  color: #111827 !important;
  transform: none !important;
}

.modal-close:active,
.settings-modal-close:active,
.confirm-dialog-close:active {
  transform: scale(0.96) !important;
}

.settings-modal-head {
  padding-right: 56px !important;
}

.btn,
.confirm-dialog-btn,
.modal-actions .btn-action {
  border-radius: 14px;
  font-weight: 700;
}

.btn-primary,
.confirm-dialog-btn-confirm,
.modal-actions .btn-action:not(.btn-action-outline) {
  background: #171a21 !important;
  color: #fff !important;
  border-color: #171a21 !important;
  box-shadow: none !important;
}

.btn-cancel,
.confirm-dialog-btn-cancel,
.modal-actions .btn-action-outline {
  background: #f4f5f7 !important;
  color: #333746 !important;
  border-color: rgba(17,24,39,0.08) !important;
  box-shadow: none !important;
}

.btn:hover,
.confirm-dialog-btn:hover,
.modal-actions .btn-action:hover {
  transform: none !important;
  filter: none !important;
}
