:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #1a2233;
  --text-muted: #5b6577;
  --border: #d9deea;
  --primary: #3d5afe;
  --primary-700: #2e46d9;
  --success: #2e9e63;
  --danger: #d9455f;
  --warn-bg: #fff4d6;
  --warn-text: #7a5b00;
  --error-bg: #fde8ec;
  --error-text: #8f1d31;
  --ok-bg: #e2f6ea;
  --ok-text: #1c6b41;
  --chart-views: #4f7cff;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.05);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --surface: #1b2029;
    --surface-2: #232a36;
    --text: #e8ebf2;
    --text-muted: #97a0b3;
    --border: #313a49;
    --primary: #6d8dff;
    --primary-700: #4f6ee6;
    --success: #3fbf7d;
    --danger: #ef6b81;
    --warn-bg: #3a3115;
    --warn-text: #ffd970;
    --error-bg: #3d1d26;
    --error-text: #ff9db0;
    --ok-bg: #173226;
    --ok-text: #7fdcae;
    --chart-views: #6d8dff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.45rem; margin: 0.2rem 0 0.8rem; }
h2 { font-size: 1.2rem; margin: 0.4rem 0; }
h3 { font-size: 1.05rem; margin: 0.4rem 0; }

.container { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; width: 100%; }

.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.brand {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand span { color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.nav-links a { padding: 0.45rem 0.6rem; border-radius: 8px; color: var(--text-muted); min-height: 36px; display: inline-flex; align-items: center; }
.nav-links a.active, .nav-links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-user { color: var(--text-muted); font-size: 0.85rem; padding: 0 0.4rem; }
.inline-form { display: inline; }
.footer { border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.8rem; padding: 1rem 0 2rem; margin-top: 1rem; }

.hero { text-align: center; padding: 2rem 0.5rem 1.5rem; }
.hero h1 { font-size: 1.7rem; margin-bottom: 0.4rem; }
.hero p { color: var(--text-muted); max-width: 560px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.empty-state { text-align: center; padding: 2.5rem 1rem; }
.center { text-align: center; }

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.campaign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.thumb-wrap { display: block; background: var(--surface-2); aspect-ratio: 1; }
.thumb { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-sm { width: 56px; height: 56px; object-fit: contain; background: var(--surface-2); border-radius: 8px; display: inline-block; vertical-align: middle; }
.cell-thumb { width: 72px; }
.card-body { padding: 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: filter 0.12s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.7rem; min-height: 38px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn-col { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }

.muted { color: var(--text-muted); }
.small { font-size: 0.84rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.req { color: var(--danger); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th, .table td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0.1rem 0.15rem 0.1rem 0;
}
.badge-active, .badge-super { background: var(--ok-bg); color: var(--ok-text); }
.badge-draft { background: var(--warn-bg); color: var(--warn-text); }
.badge-archived { background: var(--surface-2); color: var(--text-muted); }
.badge-user, .badge-home { background: var(--surface-2); color: var(--text); }

.alert { padding: 0.7rem 0.9rem; border-radius: 10px; margin-bottom: 0.9rem; font-size: 0.9rem; }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }

.banner { padding: 0.7rem 1rem; margin: -0.25rem 0 1rem; border-radius: 10px; font-size: 0.9rem; }
.banner-warn { background: var(--warn-bg); color: var(--warn-text); }

.auth-box { max-width: 420px; margin: 2.5rem auto; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); }

.form-wide { max-width: 640px; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 0.3rem; }
.input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea.input { resize: vertical; }
.checkbox-group { padding: 0.4rem 0; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; cursor: pointer; }
.checkbox-label input { width: 1.15rem; height: 1.15rem; }

.slug-row { display: flex; align-items: stretch; gap: 0; }
.slug-prefix { display: inline-flex; align-items: center; padding: 0 0.6rem; background: var(--surface-2); border: 1px solid var(--border); border-right: none; border-radius: 10px 0 0 10px; color: var(--text-muted); font-size: 0.85rem; }
.slug-row .input { border-radius: 0 10px 10px 0; flex: 1; min-width: 0; }
.slug-status { min-height: 1.2em; margin-top: 0.3rem; }
.slug-status.ok { color: var(--ok-text); }
.slug-status.bad { color: var(--error-text); }
.slug-status.loading { color: var(--text-muted); }
.current-frame { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.5rem; }

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.25rem;
  align-items: start;
}
.campaign-title { margin: 0 0 0.3rem; }
.campaign-desc { color: var(--text-muted); margin: 0 0 1rem; }

.canvas-frame {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  aspect-ratio: 1;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
#canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  pointer-events: none;
}
.preview-note { margin-top: 1rem; }

.editor-side { display: flex; flex-direction: column; gap: 0.75rem; }
.file-label { position: relative; }
.control-group { margin-top: 0.9rem; }
.control-group label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.35rem; }
.zoom-row { display: flex; align-items: center; gap: 0.5rem; }
input[type="range"] { flex: 1; min-height: 44px; accent-color: var(--primary); }
select.input { appearance: auto; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.2rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.fallback-img { width: 100%; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 0.75rem; display: block; }

.temp-password { display: flex; align-items: center; gap: 0.6rem; margin: 0.75rem 0; }
.temp-password code { background: var(--surface-2); padding: 0.55rem 0.8rem; border-radius: 8px; font-size: 1.05rem; }

.qr-details { position: relative; display: inline-block; }
.qr-details summary { list-style: none; cursor: pointer; }
.qr-details summary::-webkit-details-marker { display: none; }
.qr-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  box-shadow: var(--shadow);
  z-index: 15;
  width: 190px;
}
.qr-pop img { display: block; width: 160px; height: 160px; }
.delete-pop { width: 260px; }
.stack-form { display: flex; flex-direction: column; gap: 0.5rem; }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 0.75rem; }
.stat-box { background: var(--surface-2); border-radius: 10px; padding: 0.8rem 1.2rem; min-width: 140px; }
.stat-num { font-size: 1.6rem; font-weight: 800; }
.chart { width: 100%; height: auto; }
.legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.dot-views { background: var(--chart-views); }
.dot-downloads { background: #2e9e63; }
.pager { display: flex; align-items: center; gap: 0.75rem; justify-content: center; padding: 0.75rem 0; }

@media (max-width: 760px) {
  .editor-layout { grid-template-columns: 1fr; }
  .nav-inner { padding: 0.5rem 0.75rem; }
  .nav-links a { padding: 0.4rem 0.5rem; }
  .container { padding: 1rem 0.75rem 2rem; }
  .hero { padding: 1.25rem 0.5rem 1rem; }
  .hero h1 { font-size: 1.35rem; }
}

.schedule-row{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}
.schedule-row .input{flex:1;min-width:180px}
