/* ============================================================
   FreeShow Cloud Sync Server — Admin UI
   Hero + Bento layout. Dark-first w/ light toggle. No deps.
   ============================================================ */

/* --- Reset & Base ------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark theme (default) */
  --bg-0:        #0A0C12;
  --bg-1:        #11141B;
  --bg-2:        #161A23;
  --surface:     rgba(22, 26, 35, 0.72);
  --surface-solid: #161A23;
  --surface-hover: rgba(31, 36, 48, 0.85);
  --border:      rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text:        #ECEEF3;
  --text-muted:  #8A93A6;
  --text-dim:    #5B6478;

  --accent:      #5B8DEF;
  --accent-2:    #8B5CF6;
  --accent-3:    #EC4899;
  --accent-hover: #6B9AFC;
  --accent-fg:   #FFFFFF;
  --accent-glow: rgba(91, 141, 239, 0.35);

  --green:       #34D399;
  --green-bg:    rgba(52, 211, 153, 0.12);
  --green-border: rgba(52, 211, 153, 0.28);
  --orange:      #FBBF24;
  --orange-bg:   rgba(251, 191, 36, 0.12);
  --orange-border: rgba(251, 191, 36, 0.28);
  --red:         #F87171;
  --red-bg:      rgba(248, 113, 113, 0.12);
  --red-border:  rgba(248, 113, 113, 0.32);

  --radius-sm:   8px;
  --radius:      14px;
  --radius-lg:   20px;
  --radius-pill: 999px;

  --shadow-sm:   0 1px 2px rgba(0,0,0,.25);
  --shadow:      0 4px 16px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --shadow-lg:   0 24px 48px -12px rgba(0,0,0,.55), 0 4px 12px rgba(0,0,0,.30);

  --font:        "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --font-mono:   "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --ease:        cubic-bezier(.2, .8, .2, 1);
  --ease-out:    cubic-bezier(.16, 1, .3, 1);

  --gradient-accent: linear-gradient(135deg, #5B8DEF 0%, #8B5CF6 50%, #EC4899 100%);
  --gradient-accent-soft: linear-gradient(135deg, rgba(91,141,239,.16), rgba(139,92,246,.14) 50%, rgba(236,72,153,.12));
  --gradient-bg:     radial-gradient(1400px 700px at 75% -20%, rgba(139,92,246,.20), transparent 60%),
                     radial-gradient(1000px 600px at -10% 5%, rgba(91,141,239,.18), transparent 55%),
                     radial-gradient(800px 600px at 110% 60%, rgba(236,72,153,.10), transparent 60%),
                     linear-gradient(180deg, #0A0C12 0%, #08090F 100%);
}

[data-theme="light"] {
  --bg-0:        #F4F6FA;
  --bg-1:        #ECEFF5;
  --bg-2:        #FFFFFF;
  --surface:     rgba(255, 255, 255, 0.85);
  --surface-solid: #FFFFFF;
  --surface-hover: rgba(248, 250, 253, 0.95);
  --border:      rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text:        #0F172A;
  --text-muted:  #5C6478;
  --text-dim:    #94A3B8;

  --accent:      #2563EB;
  --accent-2:    #7C3AED;
  --accent-3:    #DB2777;
  --accent-hover: #1D4ED8;
  --accent-glow: rgba(37, 99, 235, 0.22);

  --green:       #16A34A;
  --green-bg:    rgba(22, 163, 74, 0.10);
  --green-border: rgba(22, 163, 74, 0.25);
  --orange:      #D97706;
  --orange-bg:   rgba(217, 119, 6, 0.10);
  --orange-border: rgba(217, 119, 6, 0.25);
  --red:         #DC2626;
  --red-bg:      rgba(220, 38, 38, 0.10);
  --red-border:  rgba(220, 38, 38, 0.25);

  --shadow:      0 4px 16px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06);
  --shadow-lg:   0 24px 48px -12px rgba(15,23,42,.18), 0 4px 12px rgba(15,23,42,.08);

  --gradient-bg: radial-gradient(1400px 700px at 75% -20%, rgba(124,58,237,.12), transparent 60%),
                 radial-gradient(1000px 600px at -10% 5%, rgba(37,99,235,.12), transparent 55%),
                 radial-gradient(800px 600px at 110% 60%, rgba(219,39,119,.08), transparent 60%),
                 linear-gradient(180deg, #F4F6FA 0%, #ECEFF5 100%);
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--gradient-bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

/* Decorative dot grid */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 100% 80% at 50% 0%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 100% 80% at 50% 0%, #000 30%, transparent 100%);
}
[data-theme="light"] body::before {
  background-image: radial-gradient(rgba(15,23,42,.07) 1px, transparent 1px);
}

/* --- Utility ------------------------------------------------ */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

::selection { background: var(--accent-glow); color: var(--text); }

/* --- Scrollbar --------------------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: content-box; }

/* --- Animations -------------------------------------------- */
@keyframes fadeUp     { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn     { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn    { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes pulseDot   { 0%,100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; } 50% { box-shadow: 0 0 0 6px transparent; opacity: .8; } }
@keyframes pulseRing  { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(2.4); opacity: 0; } }
@keyframes shimmer    { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes spin       { to { transform: rotate(360deg); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { to { opacity: 0; transform: translateX(20px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --- Buttons ------------------------------------------------ */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: 500 13.5px var(--font);
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease),
              border-color .18s var(--ease), transform .12s var(--ease),
              box-shadow .18s var(--ease), opacity .18s var(--ease);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  isolation: isolate;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):active { transform: translateY(1px) scale(.98); }

.btn-primary {
  background: var(--gradient-accent);
  background-size: 200% 100%;
  color: var(--accent-fg);
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset,
              0 6px 16px -4px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  background-position: 100% 50%;
  box-shadow: 0 1px 0 rgba(255,255,255,.22) inset,
              0 10px 22px -4px var(--accent-glow);
}
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform .6s var(--ease);
  pointer-events: none;
  z-index: -1;
}
.btn-primary:hover:not(:disabled)::after { transform: translateX(100%); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red-border);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.20);
  border-color: var(--red);
}
[data-theme="light"] .btn-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.16); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; gap: 5px; }

.btn[data-loading="true"] {
  pointer-events: none;
  color: transparent !important;
}
.btn[data-loading="true"]::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--text);
  animation: spin .7s linear infinite;
}
.btn-primary[data-loading="true"]::before { color: #fff; }

/* --- Cards -------------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
  animation: fadeUp .5s var(--ease-out) backwards;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
  letter-spacing: -0.01em;
}
.card-title svg { color: var(--accent); flex-shrink: 0; }
.card-body { padding: 20px; }

/* Stagger card entry */
.bento .card:nth-child(1) { animation-delay: .10s; }
.bento .card:nth-child(2) { animation-delay: .16s; }
.clients-card { animation: fadeUp .5s var(--ease-out) .28s backwards; }


/* ============================================================
   LOGIN VIEW
   ============================================================ */
#view-login {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .5s var(--ease-out);
  overflow: hidden;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 24px 28px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.login-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--accent-glow), transparent 60%);
  pointer-events: none;
  opacity: .8;
}
.login-logo-icon {
  position: relative;
  width: 60px;
  height: 60px;
  background: var(--gradient-accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 8px 24px -4px var(--accent-glow),
              inset 0 1px 0 rgba(255,255,255,.25);
}
.login-logo-title {
  position: relative;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.login-logo-sub {
  position: relative;
  font-size: 13px;
  color: var(--text-muted);
}

.login-form {
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.form-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: 14px var(--font);
  color: var(--text);
  background: var(--bg-1);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.form-input::placeholder { color: var(--text-dim); }
.form-input:hover { border-color: var(--border-strong); }
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: var(--bg-2);
}

.login-error {
  font-size: 13px;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: none;
  animation: fadeUp .25s var(--ease-out);
}
.login-error.visible { display: block; }
.btn-login { width: 100%; height: 46px; font-size: 14.5px; margin-top: 4px; }


/* ============================================================
   DASHBOARD VIEW
   ============================================================ */
#view-dashboard { display: none; min-height: 100dvh; flex-direction: column; position: relative; z-index: 1; }
#view-dashboard.active { display: flex; }

/* --- Top App Bar ------------------------------------------- */
.app-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}
.app-bar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.app-bar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px -2px var(--accent-glow),
              inset 0 1px 0 rgba(255,255,255,.2);
}
.app-bar-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.app-bar-name {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-bar-version {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 2px 7px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
}
.app-bar-actions { display: flex; align-items: center; gap: 8px; }

/* Theme toggle */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* --- Main content ------------------------------------------ */
.main-content {
  flex: 1;
  padding: 28px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

/* --- Error banner ------------------------------------------ */
.error-banner {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13.5px;
  display: none;
  align-items: center;
  gap: 10px;
  animation: fadeUp .25s var(--ease-out);
}
.error-banner.visible { display: flex; }


/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 24px;
  padding: 32px 36px;
  background:
    linear-gradient(180deg, rgba(22,26,35,.6) 0%, rgba(22,26,35,.35) 100%),
    var(--gradient-accent-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  animation: fadeUp .5s var(--ease-out);
}
[data-theme="light"] .hero {
  background:
    linear-gradient(180deg, rgba(255,255,255,.65) 0%, rgba(255,255,255,.45) 100%),
    var(--gradient-accent-soft);
}

.hero-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.hero-glow::before,
.hero-glow::after {
  content: "";
  position: absolute;
  width: 80%;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(60px);
  will-change: transform;
}

.hero-glow::before {
  top: -10%;
  left: -5%;
  background: radial-gradient(circle,
    var(--accent-glow),
    rgb(from var(--accent-glow) r g b / 0) 70%);
  animation: heroDriftA 17s ease-in-out infinite;
}

.hero-glow::after {
  top: 20%;
  left: 40%;
  background: radial-gradient(circle,
    rgb(from var(--accent-3) r g b / .28),
    rgb(from var(--accent-3) r g b / 0) 70%);
  animation: heroDriftB 23s ease-in-out infinite;
}

@keyframes heroDriftA {
  0%, 100% { transform: translate(0%, 0%); }
  33%      { transform: translate(22%, -12%); }
  66%      { transform: translate(-16%, 20%); }
}

@keyframes heroDriftB {
  0%, 100% { transform: translate(0%, 0%); }
  40%      { transform: translate(-24%, 16%); }
  80%      { transform: translate(20%, -22%); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-glow::before,
  .hero-glow::after { animation: none; }
}

.hero-left, .hero-right { position: relative; z-index: 1; min-width: 0; }

.hero-left { display: flex; flex-direction: column; gap: 14px; }

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}
.hero-badge .pulse-dot {
  position: relative;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
}
.hero-badge .pulse-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--green);
  animation: pulseRing 1.8s var(--ease-out) infinite;
}
.hero-eyebrow-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-code-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.join-code-expiry {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  background: rgba(0,0,0,.18);
  border: 1px solid var(--border-strong);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.join-code-expiry-label { opacity: .7; }
.join-code-expiry strong { font-weight: 700; font-family: var(--font-mono); }
.join-code-expiry.is-soon { color: var(--accent); border-color: var(--accent); }
.join-code-expiry.is-critical {
  color: #ff6b6b;
  border-color: rgba(255,107,107,.6);
  animation: joinCodeExpiryPulse 1s ease-in-out infinite;
}
.join-code-expiry.is-disabled {
  color: var(--text-muted);
  border-color: var(--border-strong);
  opacity: .65;
}
@keyframes joinCodeExpiryPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

.join-code-display {
  font-family: var(--font-mono);
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 800;
  letter-spacing: 0.16em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
  user-select: all;
  cursor: copy;
  transition: filter .15s var(--ease), transform .15s var(--ease);
  text-shadow: 0 0 60px var(--accent-glow);
}
.join-code-display:hover { filter: brightness(1.1); transform: translateY(-1px); }
.join-code-display:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 4px; }
.join-code-display.copied { animation: scaleIn .3s var(--ease-out); }

.hero-url {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  background: rgba(0,0,0,.18);
  border: 1px solid var(--border-strong);
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
}
[data-theme="light"] .hero-url { background: rgba(255,255,255,.6); }
.hero-url svg { color: var(--accent); flex-shrink: 0; }
.hero-url-label { color: var(--text-dim); font-weight: 500; flex-shrink: 0; }
.hero-url strong {
  color: var(--text);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* Hero right: 2-stat sidekick */
.hero-right {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
}
.hero-stat-card {
  position: relative;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow: hidden;
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
[data-theme="light"] .hero-stat-card { background: rgba(255,255,255,.7); }
.hero-stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--gradient-accent);
  opacity: .35;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.hero-stat-card:hover { transform: translateY(-2px); }
.hero-stat-card.hero-stat-pending::before {
  background: linear-gradient(135deg, var(--orange), transparent 60%);
  opacity: .5;
}
.hero-stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero-stat-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 6px 0 4px;
}
.hero-stat-value {
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-stat-pending .hero-stat-value {
  background: linear-gradient(135deg, var(--orange), #F59E0B);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-stat-total {
  font-size: 17px;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hero-stat-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 500;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding: 24px; }
  .hero-right { grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
}
@media (max-width: 480px) {
  .hero { padding: 20px; }
  .hero-right { grid-template-columns: 1fr; }
}


/* ============================================================
   BENTO GRID
   ============================================================ */
.bento {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
  gap: 16px;
}
@media (max-width: 600px) {
  .bento { grid-template-columns: 1fr; }
}

.bento-tile { display: flex; flex-direction: column; }
.bento-tile .card-body { flex: 1; display: flex; flex-direction: column; }

/* Settings */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:first-child { padding-top: 0; }
.settings-row:last-child  { border-bottom: none; padding-bottom: 0; }
.settings-row-label { font-size: 13.5px; font-weight: 500; color: var(--text); }
.settings-row-desc  { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.settings-row-name { flex-direction: column; align-items: stretch; gap: 8px; }
.settings-row-name .settings-row-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}
.toggle input:checked + .toggle-track {
  background: var(--gradient-accent);
  border-color: transparent;
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.30), 0 1px 0 rgba(255,255,255,.3) inset;
  transition: transform .25s var(--ease-out);
  pointer-events: none;
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(20px); }
.toggle input:focus-visible ~ .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.settings-name-row { display: flex; gap: 8px; align-items: center; }
.settings-name-input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: 14px var(--font);
  color: var(--text);
  background: var(--bg-1);
  min-width: 0;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.settings-name-input::placeholder { color: var(--text-dim); }
.settings-name-input:hover { border-color: var(--border-strong); }
.settings-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: var(--bg-2);
}
.settings-retention-input { flex: 0 0 90px; text-align: center; }
.settings-retention-input::-webkit-outer-spin-button,
.settings-retention-input::-webkit-inner-spin-button { margin: 0; }
.settings-unit { font-size: 13px; color: var(--text-muted); margin-right: 4px; }

/* Storage tile */
.storage-body { gap: 0 !important; padding: 0; }
.storage-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
}
.storage-divider {
  height: 1px;
  background: var(--border);
  margin: 0 20px;
}
.storage-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-1);
  border: 1px solid var(--border);
}
.storage-icon.snapshot { color: var(--accent); background: rgba(91,141,239,.10); border-color: rgba(91,141,239,.25); }
.storage-icon.media    { color: var(--accent-2); background: rgba(139,92,246,.10); border-color: rgba(139,92,246,.25); }
.storage-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.storage-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.storage-ver {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  margin-left: 2px;
}
.storage-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Storage retention row */
.storage-retention {
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.storage-retention-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.storage-retention-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.storage-retention-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Storage action buttons */
.storage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px 18px;
}
.storage-actions .btn { flex: 1 1 auto; min-width: 0; }

/* Archive restore dialog */
.archive-list {
  max-height: 280px;
  overflow-y: auto;
  margin: 8px 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
}
.archive-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s var(--ease);
}
.archive-list-item:last-child { border-bottom: none; }
.archive-list-item:hover { background: var(--bg-2); }
.archive-list-item.selected {
  background: var(--accent-glow);
  outline: 1px solid var(--accent);
}
.archive-list-date { font-family: var(--font-mono); font-size: 13.5px; color: var(--text); }
.archive-list-meta { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.archive-list-empty {
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}


/* ============================================================
   CLIENTS TABLE
   ============================================================ */
.count-pill {
  margin-left: 6px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-glow);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead tr { border-bottom: 1px solid var(--border-strong); }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  background: var(--bg-1);
}
thead th:first-child { padding-left: 22px; }
thead th:last-child  { padding-right: 22px; text-align: right; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s var(--ease);
  animation: fadeIn .3s var(--ease-out) backwards;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
tbody td {
  padding: 14px 16px;
  vertical-align: middle;
}
tbody td:first-child { padding-left: 22px; }
tbody td:last-child  { padding-right: 22px; }

tbody tr:nth-child(1) { animation-delay: 0.02s; }
tbody tr:nth-child(2) { animation-delay: 0.05s; }
tbody tr:nth-child(3) { animation-delay: 0.08s; }
tbody tr:nth-child(4) { animation-delay: 0.11s; }
tbody tr:nth-child(5) { animation-delay: 0.14s; }
tbody tr:nth-child(n+6) { animation-delay: 0.17s; }

/* Status badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-pending  { background: var(--orange-bg); color: var(--orange); border-color: var(--orange-border); }
.badge-approved { background: var(--green-bg);  color: var(--green);  border-color: var(--green-border); }
.badge-blocked  { background: var(--red-bg);    color: var(--red);    border-color: var(--red-border); }

/* Online dot */
.online-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  position: relative;
}
.online-dot.online {
  background: var(--green);
  color: rgba(52,211,153,.45);
  animation: pulseDot 2s var(--ease) infinite;
}
.online-dot.offline { background: var(--text-dim); }

.client-name { font-weight: 500; color: var(--text); }
.client-ip   { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.client-time { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }

.action-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

/* Empty state */
.empty-state {
  padding: 56px 20px;
  text-align: center;
  color: var(--text-muted);
  animation: fadeUp .4s var(--ease-out);
}
.empty-state-icon {
  margin: 0 auto 14px;
  width: 64px; height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state-desc  { font-size: 13.5px; line-height: 1.6; max-width: 420px; margin: 0 auto; color: var(--text-muted); }

/* Skeleton */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-2) 0%,
    var(--border-strong) 50%,
    var(--bg-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  color: transparent !important;
  border-radius: var(--radius-sm);
  display: inline-block;
  min-width: 28px;
  height: 0.9em;
}


/* ============================================================
   TOAST
   ============================================================ */
#toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}
.toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 380px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  color: var(--text);
  animation: slideInRight .3s var(--ease-out);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.toast.leave { animation: slideOutRight .25s var(--ease) forwards; }
.toast-icon { flex-shrink: 0; display: flex; padding-top: 1px; }
.toast-content { flex: 1; line-height: 1.45; }
.toast-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.toast-close:hover { color: var(--text); background: var(--bg-1); }

.toast-success { border-left-color: var(--green); }
.toast-success .toast-icon { color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-error .toast-icon   { color: var(--red); }
.toast-info    { border-left-color: var(--accent); }
.toast-info .toast-icon    { color: var(--accent); }


/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .2s var(--ease-out);
}
.dialog {
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .25s var(--ease-out);
}
.dialog-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.dialog-title .dialog-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--orange-bg);
  color: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dialog-title.danger .dialog-icon {
  background: var(--red-bg);
  color: var(--red);
}
.dialog-body { font-size: 13.5px; color: var(--text-muted); line-height: 1.55; margin-bottom: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
  .main-content { padding: 18px 14px 32px; gap: 16px; }
  .card-header  { padding: 14px 16px; }
  .card-body    { padding: 16px; }
  thead th, tbody td { padding: 11px 12px; }
  thead th:first-child, tbody td:first-child { padding-left: 14px; }
  thead th:last-child,  tbody td:last-child  { padding-right: 14px; }

  thead th.hide-mobile,
  tbody td.hide-mobile { display: none; }

  #toast-container { top: auto; bottom: 16px; right: 12px; left: 12px; max-width: none; }
  .toast { max-width: none; }
}

@media (max-width: 480px) {
  .app-bar { padding: 0 14px; height: 56px; }
  .app-bar-name { font-size: 14px; }
  .app-bar-version { display: none; }
}
