:root {
  --bg: #f4f5fb;
  --bg-card: #ffffff;
  --bg-subtle: #f3f3fb;
  --bg-input: #f8f8fd;
  --border: #e6e6f2;
  --border-strong: #d3d3e8;
  --text: #14142b;
  --text-dim: #52526b;
  --text-mute: #8f8fa8;

  --accent: #6d28d9;
  --accent-2: #2563eb;
  --accent-soft: rgba(109, 40, 217, 0.1);

  /* category identity: solid + gradient pair per accent */
  --cyan: #0ea5e9;
  --cyan-2: #22d3ee;
  --purple: #8b5cf6;
  --purple-2: #d946ef;
  --green: #10b981;
  --green-2: #2dd4bf;
  --amber: #f59e0b;
  --amber-2: #fb923c;

  --grad-cyan: linear-gradient(120deg, var(--cyan), var(--cyan-2));
  --grad-purple: linear-gradient(120deg, var(--purple), var(--purple-2));
  --grad-green: linear-gradient(120deg, var(--green), var(--green-2));
  --grad-amber: linear-gradient(120deg, var(--amber), var(--amber-2));
  --grad-brand: linear-gradient(120deg, #6d28d9 0%, #d946ef 45%, #f59e0b 100%);

  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);

  --shadow-sm: 0 1px 2px rgba(20, 20, 43, 0.05);
  --shadow-card: 0 2px 6px rgba(20, 20, 43, 0.06), 0 1px 2px rgba(20, 20, 43, 0.05);
  --shadow-card-hover: 0 22px 40px -14px rgba(20, 20, 43, 0.22), 0 6px 14px rgba(20, 20, 43, 0.08);
}

/* ---- dark theme: variable overrides only — every rule below this block
   keeps working unchanged because the whole light theme is variable-driven.
   Toggled via <html data-theme="dark"> (see theme.js / inline FOUC guard). ---- */
:root[data-theme="dark"] {
  --bg: #0a0d18;
  --bg-card: #131728;
  --bg-subtle: #1a2036;
  --bg-input: #10131f;
  --border: #2b3252;
  --border-strong: #3d4770;
  --text: #eef0fb;
  --text-dim: #b6bcd9;
  --text-mute: #7d84a8;

  --accent: #ab8ffb;
  --accent-2: #67a3fb;
  --accent-soft: rgba(171, 143, 251, 0.2);

  --cyan: #38bdf8;
  --cyan-2: #67e8f9;
  --purple: #ab8ffb;
  --purple-2: #f0abfc;
  --green: #34d399;
  --green-2: #5eead4;
  --amber: #fbbf24;
  --amber-2: #fdba74;

  --grad-cyan: linear-gradient(120deg, var(--cyan), var(--cyan-2));
  --grad-purple: linear-gradient(120deg, var(--purple), var(--purple-2));
  --grad-green: linear-gradient(120deg, var(--green), var(--green-2));
  --grad-amber: linear-gradient(120deg, var(--amber), var(--amber-2));
  --grad-brand: linear-gradient(120deg, #ab8ffb 0%, #f0abfc 45%, #fbbf24 100%);

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-card-hover: 0 24px 46px -16px rgba(0, 0, 0, 0.65), 0 8px 18px rgba(0, 0, 0, 0.45);
}

/* a handful of rules below use literal rgba()/hex instead of the palette
   variables above (translucent glass panels, per-accent glow shadows, badge
   text tints) — those need explicit dark counterparts since they can't
   inherit from a variable override. Everything else in this file is
   variable-driven and needs no dark-specific rule at all. */

[data-theme="dark"] body {
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
}

[data-theme="dark"] .bg-glow {
  background: radial-gradient(
      ellipse 900px 560px at 8% -10%,
      rgba(171, 143, 251, 0.2) 0%,
      transparent 68%
    ),
    radial-gradient(
      ellipse 760px 540px at 96% 4%,
      rgba(56, 189, 248, 0.16) 0%,
      transparent 68%
    ),
    radial-gradient(
      ellipse 820px 520px at 50% 110%,
      rgba(251, 191, 36, 0.14) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 640px 480px at 78% 92%,
      rgba(240, 171, 252, 0.13) 0%,
      transparent 70%
    );
}

[data-theme="dark"] .hero::after {
  opacity: 0.22;
}

[data-theme="dark"] .stat-chip {
  background: rgba(19, 23, 40, 0.72);
}

[data-theme="dark"] .login-panel {
  background: rgba(14, 17, 30, 0.82);
}

/* card top-bar/icon/hover glows are hardcoded per-accent so they read
   correctly against the accent's own hue — brighten them to the dark accent
   values so hover glow intensity matches the (now lighter) accent colors */
[data-theme="dark"] .card.accent-cyan:hover {
  box-shadow: var(--shadow-card-hover), 0 0 0 1px rgba(56, 189, 248, 0.4), 0 18px 34px -14px rgba(56, 189, 248, 0.45);
}
[data-theme="dark"] .card.accent-purple:hover {
  box-shadow: var(--shadow-card-hover), 0 0 0 1px rgba(171, 143, 251, 0.4), 0 18px 34px -14px rgba(171, 143, 251, 0.45);
}
[data-theme="dark"] .card.accent-green:hover {
  box-shadow: var(--shadow-card-hover), 0 0 0 1px rgba(52, 211, 153, 0.4), 0 18px 34px -14px rgba(52, 211, 153, 0.45);
}
[data-theme="dark"] .card.accent-amber:hover {
  box-shadow: var(--shadow-card-hover), 0 0 0 1px rgba(251, 191, 36, 0.4), 0 18px 34px -14px rgba(251, 191, 36, 0.45);
}

[data-theme="dark"] .accent-cyan .card-icon {
  box-shadow: 0 6px 16px -4px rgba(56, 189, 248, 0.55);
}
[data-theme="dark"] .accent-purple .card-icon {
  box-shadow: 0 6px 16px -4px rgba(171, 143, 251, 0.55);
}
[data-theme="dark"] .accent-green .card-icon {
  box-shadow: 0 6px 16px -4px rgba(52, 211, 153, 0.55);
}
[data-theme="dark"] .accent-amber .card-icon {
  box-shadow: 0 6px 16px -4px rgba(251, 191, 36, 0.55);
}

/* category/kind badge text — light theme uses dark-on-light tints (e.g.
   #0369a1 on a pale cyan wash); on dark cards those need to flip to
   light-on-dark tints to stay legible and keep each category distinguishable */
[data-theme="dark"] .accent-cyan .card-badge-cat {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.4);
}
[data-theme="dark"] .accent-purple .card-badge-cat {
  background: rgba(171, 143, 251, 0.18);
  color: #d8b4fe;
  border-color: rgba(171, 143, 251, 0.4);
}
[data-theme="dark"] .accent-green .card-badge-cat {
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.4);
}
[data-theme="dark"] .accent-amber .card-badge-cat {
  background: rgba(251, 191, 36, 0.18);
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.42);
}

[data-theme="dark"] .role-select.role-admin {
  background-color: rgba(171, 143, 251, 0.18);
  color: #d8b4fe;
  border-color: rgba(171, 143, 251, 0.42);
}

[data-theme="dark"] .hero {
  background: linear-gradient(155deg, rgba(171, 143, 251, 0.16), rgba(56, 189, 248, 0.11) 55%, rgba(251, 191, 36, 0.1));
}

[data-theme="dark"] button.primary {
  box-shadow: 0 4px 14px rgba(171, 143, 251, 0.35);
}

[data-theme="dark"] button.primary:hover {
  box-shadow: 0 8px 20px rgba(171, 143, 251, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background-image: radial-gradient(rgba(20, 20, 43, 0.055) 1px, transparent 1px);
  background-size: 22px 22px;
}

a {
  color: inherit;
}

/* ── background atmosphere: mesh gradient wash + floating blur orbs ── */
.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background: radial-gradient(
      ellipse 900px 560px at 8% -10%,
      rgba(109, 40, 217, 0.14) 0%,
      transparent 68%
    ),
    radial-gradient(
      ellipse 760px 540px at 96% 4%,
      rgba(14, 165, 233, 0.12) 0%,
      transparent 68%
    ),
    radial-gradient(
      ellipse 820px 520px at 50% 110%,
      rgba(245, 158, 11, 0.1) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 640px 480px at 78% 92%,
      rgba(217, 70, 239, 0.09) 0%,
      transparent 70%
    );
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  will-change: transform;
}

.orb-1 {
  width: 380px;
  height: 380px;
  top: -120px;
  left: -80px;
  background: radial-gradient(circle at 35% 35%, #22d3ee, transparent 72%);
  animation: floatA 17s ease-in-out infinite;
}

.orb-2 {
  width: 420px;
  height: 420px;
  top: -60px;
  right: -140px;
  background: radial-gradient(circle at 40% 40%, #d946ef, transparent 72%);
  animation: floatB 21s ease-in-out infinite;
}

.orb-3 {
  width: 340px;
  height: 340px;
  bottom: -140px;
  left: 22%;
  background: radial-gradient(circle at 45% 45%, #f59e0b, transparent 72%);
  animation: floatC 19s ease-in-out infinite;
}

.orb-4 {
  width: 300px;
  height: 300px;
  bottom: -80px;
  right: 6%;
  background: radial-gradient(circle at 50% 50%, #10b981, transparent 72%);
  animation: floatA 24s ease-in-out infinite reverse;
}

@keyframes floatA {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, 24px) scale(1.06); }
  66% { transform: translate(-18px, 14px) scale(0.96); }
}

@keyframes floatB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-34px, 30px) scale(1.08); }
}

@keyframes floatC {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40% { transform: translate(22px, -20px) scale(1.05); }
  75% { transform: translate(-24px, -8px) scale(0.94); }
}

@media (prefers-reduced-motion: reduce) {
  .orb, .logo-dot, .card { animation: none !important; }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px 24px 52px;
}

/* ── logo / brand ── */
.logo-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.logo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  animation: dotPulse 2.5s infinite;
  box-shadow: 0 0 10px currentColor;
}

.logo-dot:nth-child(1) {
  background: var(--cyan);
  color: var(--cyan);
  animation-delay: 0s;
}
.logo-dot:nth-child(2) {
  background: var(--purple);
  color: var(--purple);
  animation-delay: 0.3s;
}
.logo-dot:nth-child(3) {
  background: var(--amber);
  color: var(--amber);
  animation-delay: 0.6s;
}

@keyframes dotPulse {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.45);
  }
}

.brand-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-text span {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- top bar (index) ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 22px;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar .topbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
  min-width: 0;
}

/* every direct child keeps its natural (min-content) size and wraps onto a
   new line instead of being squeezed — squeezing is what causes button/link
   text to collapse into a vertical single-character stack on narrow screens */
.topbar .topbar-right > * {
  flex-shrink: 0;
}

.topbar .topbar-right #current-username {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  color: var(--text-dim);
  padding: 5px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  max-width: min(240px, 45vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

/* ---- theme toggle (light/dark switch) ---- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: 999px;
}

.theme-toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 50px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover .theme-toggle-track {
  border-color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle-icon {
  position: relative;
  z-index: 1;
  font-size: 12px;
  line-height: 1;
  color: var(--text-mute);
  transition: color 0.2s ease;
}

.theme-toggle[aria-checked="false"] .icon-sun {
  color: var(--amber);
}

.theme-toggle[aria-checked="true"] .icon-moon {
  color: #f4f0ff;
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--grad-brand);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.theme-toggle[aria-checked="true"] .theme-toggle-thumb {
  transform: translateX(24px);
}

/* login.html has no topbar to sit in — pin it to the corner instead */
.theme-toggle-floating {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
}

@media (max-width: 560px) {
  .theme-toggle-floating {
    top: 12px;
    right: 12px;
  }
}

/* ---- hero ---- */
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
  padding: 30px 30px 26px;
  margin-bottom: 24px;
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(109, 40, 217, 0.09), rgba(14, 165, 233, 0.07) 55%, rgba(245, 158, 11, 0.07));
  border: 1px solid var(--border);
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: -60%;
  right: -10%;
  width: 320px;
  height: 320px;
  background: conic-gradient(from 180deg, #22d3ee, #d946ef, #f59e0b, #22d3ee);
  opacity: 0.14;
  filter: blur(50px);
  border-radius: 50%;
  pointer-events: none;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 560px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 12px;
}

.hero-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grad-brand);
  box-shadow: 0 0 8px rgba(217, 70, 239, 0.55);
}

.hero-title {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: var(--text);
  margin-bottom: 10px;
}

.hero-title .grad-text {
  background: var(--grad-brand);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradShift 7s ease-in-out infinite;
}

@keyframes gradShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero-sub {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.7;
}

.hero-stats {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 108px;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-chip strong {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-chip span {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
}

@media (max-width: 720px) {
  .hero { padding: 24px 20px; }
  .hero-title { font-size: 30px; }
}

/* ---- buttons ---- */
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-dim);
  padding: 8px 16px;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease,
    box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

button.primary {
  background: var(--grad-brand);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(109, 40, 217, 0.32);
}

button.primary:hover {
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(109, 40, 217, 0.4);
  transform: translateY(-1px);
}

button.danger-btn {
  color: var(--danger);
}

button.danger-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

/* ---- add-mockup form (admin only) ---- */
.panel {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 26px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-card);
  border-top: 3px solid transparent;
  border-image: var(--grad-brand) 1;
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.panel h2::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--grad-brand);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
}

.field.field-wide {
  grid-column: 1 / -1;
}

.field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-mute);
}

input[type="text"],
input[type="password"],
input[type="url"],
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-mute);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

textarea {
  resize: vertical;
  min-height: 44px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.error-msg {
  color: var(--danger);
  font-size: 12px;
}

.pwd-success-msg {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--green);
}

.empty-msg {
  color: var(--text-mute);
  font-size: 13px;
  padding: 40px 0;
  text-align: center;
}

/* ---- edit modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 10, 24, 0.5);
  backdrop-filter: blur(3px);
  animation: modalBackdropIn 0.15s ease both;
}

/* the `hidden` attribute is only UA-stylesheet `display: none` — it loses to
   our own `.modal-backdrop { display: flex }` rule above, so it must be
   restated explicitly here or the modal stays visible on load */
.modal-backdrop[hidden] {
  display: none;
}

[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.65);
}

@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 26px 26px;
  box-shadow: var(--shadow-card-hover);
  border-top: 3px solid transparent;
  border-image: var(--grad-brand) 1;
  animation: modalIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.modal-close {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .modal-backdrop {
    padding: 12px;
    align-items: flex-end;
  }

  .modal {
    padding: 18px 16px 20px;
    border-radius: 16px 16px 0 0;
    max-height: calc(100vh - 24px);
  }
}

/* ---- confirm dialog (register/update/delete gate — replaces window.confirm) ----
   Reuses .modal-backdrop/.modal for the overlay/card chrome (dark theme,
   animation, mobile bottom-sheet layout all come along for free) and only
   adds the bits specific to a confirm prompt: a narrower card, the message
   line, and the action row. */
.confirm-modal {
  max-width: 420px;
}

.confirm-message {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 22px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

/* danger variant (delete): red-tinted title + solid red confirm button,
   toggled via .is-danger on #confirm-modal / #confirm-ok-btn in portal.js */
.confirm-modal.is-danger .modal-header h2 {
  color: var(--danger);
}

#confirm-ok-btn.is-danger {
  background: linear-gradient(120deg, var(--danger), #f43f5e);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.32);
}

#confirm-ok-btn.is-danger:hover {
  color: #fff;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.4);
  transform: translateY(-1px);
}

[data-theme="dark"] #confirm-ok-btn.is-danger {
  box-shadow: 0 4px 14px rgba(248, 113, 113, 0.28);
}

[data-theme="dark"] #confirm-ok-btn.is-danger:hover {
  box-shadow: 0 8px 20px rgba(248, 113, 113, 0.34);
}

/* ---- category groups + card grid ---- */
.cat-group {
  margin-bottom: 26px;
}

.cat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  /* padding + matching negative margin: enlarges the click/hover/touch area
     without shifting the visible row or the 14px gap to the grid below */
  padding: 8px 6px;
  margin: -8px -6px 6px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.cat-title:hover {
  background: var(--bg-subtle);
}

.cat-title:hover .cat-name {
  color: var(--accent);
}

.cat-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cat-title::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

/* collapse chevron — rotates from pointing down (expanded) to pointing
   right (collapsed); colored to match the category's accent */
.cat-toggle-icon {
  flex-shrink: 0;
  color: var(--text-mute);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.cat-group.accent-cyan .cat-toggle-icon { color: var(--cyan); }
.cat-group.accent-purple .cat-toggle-icon { color: var(--purple); }
.cat-group.accent-green .cat-toggle-icon { color: var(--green); }
.cat-group.accent-amber .cat-toggle-icon { color: var(--amber); }

.cat-title[aria-expanded="false"] .cat-toggle-icon {
  transform: rotate(-90deg);
}

/* collapsible panel — grid-template-rows 1fr/0fr animates smoothly to any
   content height (no magic max-height number), the inner wrapper clips it */
.cat-collapse {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.cat-title[aria-expanded="false"] + .cat-collapse {
  grid-template-rows: 0fr;
}

.cat-collapse-inner {
  overflow: hidden;
  min-height: 0;
}

.cat-name {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text);
  white-space: nowrap;
}

.cat-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  flex-shrink: 0;
}

.cat-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

.cat-group.accent-cyan .cat-title::before {
  background: var(--grad-cyan);
  color: var(--cyan);
}
.cat-group.accent-purple .cat-title::before {
  background: var(--grad-purple);
  color: var(--purple);
}
.cat-group.accent-green .cat-title::before {
  background: var(--grad-green);
  color: var(--green);
}
.cat-group.accent-amber .cat-title::before {
  background: var(--grad-amber);
  color: var(--amber);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 960px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 14px 16px;
  }
}

/* ---- card ---- */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.25s ease;
  animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  cursor: pointer;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card:hover {
  transform: translateY(-6px) scale(1.012);
  border-color: transparent;
}

/* top gradient bar — always visible so category color-coding reads at a
   glance, not just on hover; thickens + glows on hover */
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  transition: height 0.2s ease;
  z-index: 1;
}

.card:hover::before {
  height: 6px;
}

.card.accent-cyan::before {
  background: var(--grad-cyan);
}
.card.accent-purple::before {
  background: var(--grad-purple);
}
.card.accent-green::before {
  background: var(--grad-green);
}
.card.accent-amber::before {
  background: var(--grad-amber);
}

.card.accent-cyan:hover {
  box-shadow: var(--shadow-card-hover), 0 0 0 1px rgba(14, 165, 233, 0.35), 0 18px 34px -14px rgba(14, 165, 233, 0.4);
}
.card.accent-purple:hover {
  box-shadow: var(--shadow-card-hover), 0 0 0 1px rgba(139, 92, 246, 0.35), 0 18px 34px -14px rgba(139, 92, 246, 0.4);
}
.card.accent-green:hover {
  box-shadow: var(--shadow-card-hover), 0 0 0 1px rgba(16, 185, 129, 0.35), 0 18px 34px -14px rgba(16, 185, 129, 0.4);
}
.card.accent-amber:hover {
  box-shadow: var(--shadow-card-hover), 0 0 0 1px rgba(245, 158, 11, 0.35), 0 18px 34px -14px rgba(245, 158, 11, 0.4);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  margin-bottom: 8px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.card:hover .card-icon {
  transform: scale(1.08) rotate(-3deg);
}

.accent-cyan .card-icon {
  background: var(--grad-cyan);
  box-shadow: 0 6px 16px -4px rgba(14, 165, 233, 0.55);
}
.accent-purple .card-icon {
  background: var(--grad-purple);
  box-shadow: 0 6px 16px -4px rgba(139, 92, 246, 0.55);
}
.accent-green .card-icon {
  background: var(--grad-green);
  box-shadow: 0 6px 16px -4px rgba(16, 185, 129, 0.55);
}
.accent-amber .card-icon {
  background: var(--grad-amber);
  box-shadow: 0 6px 16px -4px rgba(245, 158, 11, 0.55);
}

/* admin card actions (edit + delete) — always visible, not hover-gated, so
   the affordance is discoverable at a glance (and works on touch devices) */
.card-admin-actions {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.edit-btn,
.delete-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: var(--text-mute);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease,
    transform 0.15s ease;
}

.edit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.delete-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.card-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: fit-content;
}

/* category badge — gradient-tinted so it reads as a color-family, not a flat chip */
.accent-cyan .card-badge-cat {
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
  border: 1px solid rgba(14, 165, 233, 0.28);
}
.accent-purple .card-badge-cat {
  background: rgba(139, 92, 246, 0.12);
  color: #6d28d9;
  border: 1px solid rgba(139, 92, 246, 0.28);
}
.accent-green .card-badge-cat {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.28);
}
.accent-amber .card-badge-cat {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* internal/external badge — neutral, so it reads as a distinct axis from
   category color */
.card-badge-kind {
  background: var(--bg-subtle);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.card-title {
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 7px;
  word-break: break-word;
}

/* The title is the item's link; the whole card forwards clicks to it
   (see attachOpenOnClick in portal.js). */
.item-link {
  color: inherit;
  text-decoration: none;
}

.card:hover .item-link,
.item-link:hover {
  text-decoration: underline;
}

.item-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* blocked by isSafePath — shown, but never linked */
.item-link.disabled {
  color: var(--text-mute);
  text-decoration: line-through;
  cursor: not-allowed;
}

/* path tooltip — see attachPathTooltip in portal.js */
.path-tip {
  position: absolute;
  z-index: 60;
  max-width: min(90vw, 420px);
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-card-hover);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
  pointer-events: none; /* never steals the click that follows */
}

/* ---- view toggle (card / list) ---- */
.view-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.view-toggle button {
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-mute);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.view-toggle button:hover {
  color: var(--text-dim);
}

.view-toggle button.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.view-toggle button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- list view ---- */
.list-rows {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row:hover {
  background: var(--bg-subtle);
}

/* admin rows carry two 40px icon buttons; 44px would make the touch targets
   collide, so they get 4px more. Density loses to mis-tapping delete. */
.list-row.is-admin {
  min-height: 48px;
}

.list-row-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.list-row-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-row-badge {
  flex-shrink: 0;
}

.list-row-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Overrides the global 28px (32px under 560px) .edit-btn/.delete-btn size.
   `.list-row-actions button` is specificity 0,1,1 vs those rules' 0,1,0, so it
   wins regardless of where it sits in the file. */
.list-row-actions button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  /* the category chip costs more than it earns once the title has to
     ellipsize on a narrow screen */
  .list-row-badge {
    display: none;
  }
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.6;
  flex: 1;
}

footer {
  margin-top: 28px;
  color: var(--text-mute);
  font-size: 11px;
  text-align: center;
}

/* ---- login page ---- */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 26px;
}

.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.login-header h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.login-header h1 span {
  background: var(--grad-brand);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradShift 7s ease-in-out infinite;
}

.login-panel {
  position: relative;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 30px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-card-hover);
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 20px;
  padding: 1px;
  background: var(--grad-brand);
  opacity: 0.55;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: -1;
}

.login-panel .sub {
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: 22px;
  text-align: center;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.login-panel button.primary {
  margin-top: 6px;
  padding: 11px;
  font-size: 13px;
}

.login-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.login-badges span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 11px;
  border-radius: 999px;
  color: #fff;
}

.login-badges span:nth-child(1) { background: var(--grad-cyan); }
.login-badges span:nth-child(2) { background: var(--grad-purple); }
.login-badges span:nth-child(3) { background: var(--grad-green); }
.login-badges span:nth-child(4) { background: var(--grad-amber); }

/* visibility is controlled via the `hidden` attribute (toggled by portal.js
   applyAdminUI()) on every [data-admin-only] element. But `hidden` is only a
   UA-stylesheet `display: none` — any author rule that sets `display` on the
   same element (e.g. `.topbar-link { display: inline-flex }` below) wins
   over it regardless of source order, since author styles always beat UA
   styles at equal specificity. Without the override rule right below, a
   non-admin briefly sees (and could still click into) the admin-only link
   before the server's 403 kicks in. Same class of bug already fixed once for
   `.modal-backdrop[hidden]` above — restate `display: none` here too. */
[data-admin-only][hidden] {
  display: none !important;
}

/* ---- topbar link (e.g. "사용자 관리") ---- */
.topbar-link {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-dim);
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease,
    transform 0.15s ease;
}

.topbar-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* ---- back link (users.html → index.html) ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  text-decoration: none;
  margin-bottom: 16px;
  transition: color 0.15s ease, gap 0.15s ease;
}

.back-link:hover {
  color: var(--accent);
  gap: 10px;
}

/* ---- users.html: compact hero variant ---- */
.hero-compact {
  padding: 24px 30px 22px;
}

.hero-compact .hero-title {
  font-size: 30px;
}

/* ---- users.html: panel heading without the "+" glyph ---- */
.panel h2.plain-h2::before {
  content: none;
}

.panel h2.plain-h2 {
  margin-bottom: 14px;
}

/* ---- user table ---- */
.user-table-panel {
  overflow-x: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.user-table thead th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}

.user-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.user-table tbody tr:last-child td {
  border-bottom: none;
}

.user-table tbody tr:hover {
  background: var(--bg-subtle);
}

.user-cell-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

.me-badge {
  font-family: inherit;
  font-weight: 800;
}

.user-cell-date {
  color: var(--text-mute);
  font-size: 12px;
  white-space: nowrap;
}

.user-cell-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

/* role select — styled like a status badge, colored by current role */
.role-select {
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: 96px;
  padding: 5px 24px 5px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 12px) center, calc(100% - 8px) center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.role-select.role-admin {
  background-color: rgba(139, 92, 246, 0.12);
  color: #6d28d9;
  border-color: rgba(139, 92, 246, 0.3);
}

.role-select.role-user {
  background-color: var(--bg-subtle);
  color: var(--text-dim);
  border-color: var(--border);
}

.role-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* row action buttons — smaller footprint than the primary form buttons */
.row-btn {
  font-size: 11.5px;
  padding: 6px 12px;
}

.row-btn.primary-mini {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
}

.row-btn.primary-mini:hover {
  color: #fff;
}

/* inline password-reset row, expanded beneath the target user's row */
.reset-row td {
  background: var(--bg-subtle);
  padding: 12px !important;
}

.reset-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.reset-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

.reset-inline input[type="password"] {
  width: auto;
  min-width: 160px;
  flex: 0 1 220px;
}

.reset-msg {
  font-size: 11.5px;
}

.reset-msg.error-msg {
  color: var(--danger);
}

/* ---- shared small print under a panel (usage hints, IP disclaimer, etc.) ---- */
.section-note {
  font-size: 11.5px;
  color: var(--text-mute);
  line-height: 1.6;
  margin: -6px 0 14px;
}

.section-note code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.token-usage-note {
  margin: 14px 0 0;
}

/* ---- API tokens panel (users.html, admin only) ---- */
#tokens-table-wrap,
#audit-table-wrap {
  overflow-x: auto;
}

/* one-time plaintext-token reveal — deliberately loud (danger-tinted) since
   this is the only moment the value is ever visible */
.token-reveal {
  margin: 4px 0 18px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
}

.token-reveal-warning {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 10px;
  line-height: 1.6;
}

.token-reveal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.token-reveal-value {
  flex: 1 1 260px;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  padding: 8px 11px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  word-break: break-all;
  user-select: all;
}

.token-status {
  font-weight: 800;
}

.token-status.status-active {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

[data-theme="dark"] .token-status.status-active {
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.4);
}

.token-status.status-revoked,
.token-status.status-expired {
  background: var(--bg-subtle);
  color: var(--text-mute);
  border: 1px solid var(--border);
}

/* revoked token row: struck-through name + dimmed background, in addition
   to the status badge — never rely on color/badge alone */
tr.is-revoked {
  background: var(--bg-subtle);
}

tr.is-revoked .token-name {
  text-decoration: line-through;
  color: var(--text-mute);
}

.never-used {
  font-style: italic;
}

/* ---- audit log panel (users.html, admin only) ---- */
.panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-heading-row .plain-h2 {
  margin-bottom: 0;
}

.audit-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.audit-controls select {
  width: auto;
  padding: 6px 24px 6px 10px;
}

.audit-actor-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.audit-actor-type {
  font-size: 9.5px;
}

.audit-target-cell {
  max-width: 260px;
  overflow-wrap: break-word;
}

.audit-action {
  font-weight: 800;
}

.audit-action.audit-neutral {
  background: var(--bg-subtle);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.audit-action.audit-ok {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.audit-action.audit-warn {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

[data-theme="dark"] .audit-action.audit-ok {
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.4);
}

[data-theme="dark"] .audit-action.audit-warn {
  background: rgba(248, 113, 113, 0.16);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
}

@media (max-width: 640px) {
  .user-table {
    font-size: 12px;
  }
  .user-cell-actions {
    flex-direction: column;
    gap: 6px;
  }
}

/* ---- tablet pass (≤900px): tighten outer rhythm a touch ---- */
@media (max-width: 900px) {
  .wrap {
    padding: 24px 20px 44px;
  }

  .hero {
    padding: 26px 24px 22px;
  }

  /* the account table's 4 columns (id/role/date/actions) are tight at
     iPad-portrait widths — trim padding/gaps so it fits without needing
     the horizontal scroll fallback (which reads as "cut off" at this size) */
  .panel {
    padding: 20px 18px;
  }

  .user-table {
    font-size: 12.5px;
  }

  .role-select {
    width: 84px;
    padding: 5px 20px 5px 10px;
  }

  .user-cell-actions {
    gap: 6px;
  }

  .row-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}

/* ---- mobile pass (≤560px): stack everything, fluid type, ≥40px touch targets ---- */
@media (max-width: 560px) {
  .wrap {
    padding: 16px 14px 36px;
  }

  .topbar {
    padding: 12px 14px;
    border-radius: 14px;
  }

  .brand-text {
    font-size: 16.5px;
  }

  .logo-group {
    gap: 5px;
  }

  .topbar .topbar-right {
    font-size: 11.5px;
  }

  .hero {
    padding: 20px 16px 18px;
    border-radius: 16px;
  }

  .hero-eyebrow {
    font-size: 10px;
    margin-bottom: 9px;
  }

  .hero-title,
  .hero-compact .hero-title {
    font-size: clamp(21px, 7.4vw, 27px);
  }

  .hero-sub {
    font-size: 12.5px;
    line-height: 1.6;
  }

  .hero-stats {
    width: 100%;
    gap: 10px;
  }

  .stat-chip {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 12px;
  }

  .stat-chip strong {
    font-size: 20px;
  }

  .panel {
    padding: 18px 16px;
    border-radius: 14px;
  }

  .panel h2 {
    font-size: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  /* ≥40px-tall tap targets on touch-scale screens */
  button {
    min-height: 40px;
    padding: 9px 16px;
  }

  .topbar-link {
    min-height: 32px;
    padding: 7px 14px;
  }

  .back-link {
    padding: 6px 0;
  }

  .edit-btn,
  .delete-btn {
    width: 32px;
    height: 32px;
  }

  .row-btn {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 12px;
  }

  .user-cell-actions {
    width: 100%;
  }

  .user-cell-actions .row-btn {
    flex: 1 1 auto;
  }

  .role-select {
    min-height: 36px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .cat-title {
    min-height: 40px;
  }

  .login-wrap {
    padding: 16px;
    gap: 20px;
  }

  .login-header h1 {
    font-size: clamp(23px, 8vw, 30px);
  }

  .login-panel {
    padding: 26px 18px 22px;
    border-radius: 18px;
  }

  .login-badges span {
    font-size: 10px;
    padding: 4px 9px;
  }
}
