/* Survey Notifier Admin — Design System (UI/UX Pro Max: Glassmorphism / Dark tech + status green)
   Colors: bg #0F172A, card #1B2336, primary #1E293B, accent #22C55E, text #F8FAFC, muted #94A3B8
   Fonts: Fira Sans (UI), Fira Code (data) */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #0F172A;
  --surface: rgba(27, 35, 54, 0.72);
  --surface-solid: #1B2336;
  --surface-2: #212C44;
  --primary: #1E293B;
  --secondary: #334155;
  --accent: #22C55E;
  --accent-hover: #16A34A;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --text: #F8FAFC;
  --muted: #94A3B8;
  --muted-2: #64748B;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.32);
  --ring: rgba(255, 255, 255, 0.6);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 14px;
  --radius-sm: 9px;
  --font-ui: 'Fira Sans', system-ui, -apple-system, sans-serif;
  --font-data: 'Fira Code', ui-monospace, monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 60% 50% at 20% -10%, rgba(34, 197, 94, 0.08), transparent),
    radial-gradient(ellipse 50% 40% at 90% 110%, rgba(59, 130, 246, 0.07), transparent);
  background-attachment: fixed;
}

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

::selection { background: rgba(34, 197, 94, 0.3); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--secondary); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 34px;
  box-shadow: var(--shadow);
  animation: rise 0.4s ease;
}

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

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
}

.brand-mark svg { width: 24px; height: 24px; color: #052e16; }

.brand h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand .sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.login-card .subtitle {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 28px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.form-group input::placeholder { color: var(--muted-2); }

.error-box {
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
  font-size: 0.875rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  display: none;
}

.error-box.visible { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--accent);
  color: #052e16;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn:hover { background: var(--accent-hover); box-shadow: 0 4px 18px rgba(34, 197, 94, 0.3); }
.btn:active { transform: scale(0.99); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn:focus-visible, button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-weight: 600;
}
.btn-outline:hover { background: rgba(148, 163, 184, 0.1); box-shadow: none; }

.btn-sm { padding: 7px 12px; font-size: 0.8125rem; border-radius: 7px; width: auto; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; box-shadow: 0 4px 18px rgba(239, 68, 68, 0.3); }

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-2);
}

.version-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-data);
  font-size: 0.7rem;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 20px;
}

/* ============ APP LAYOUT ============ */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar .brand { padding: 0 8px; margin-bottom: 18px; }

.sidebar .brand h1 { font-size: 1.05rem; }
.sidebar .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.sidebar .brand-mark svg { width: 19px; height: 19px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
}

.nav-item:hover { background: rgba(148, 163, 184, 0.08); color: var(--text); text-decoration: none; }

.nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(34, 197, 94, 0.25);
  color: var(--accent);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar .spacer { flex: 1; }

.sidebar .side-foot {
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.sidebar .side-foot .user {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
  word-break: break-all;
}

.main {
  flex: 1;
  padding: 28px 34px 50px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.topbar h2 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar .crumbs { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }

.page { display: none; animation: fade 0.25s ease; }
.page.active { display: block; }

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

/* Cards */
.card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.card + .card { margin-top: 18px; }

.card h3 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.card .card-sub { font-size: 0.8rem; color: var(--muted); margin-bottom: 16px; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.5;
}

.stat-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.stat-card .value {
  font-family: var(--font-data);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-card .hint { font-size: 0.75rem; color: var(--muted-2); }

/* Toolbar / filters */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar input, .toolbar select {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
}

.toolbar input:focus, .toolbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

.toolbar input::placeholder { color: var(--muted-2); }

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:hover { background: rgba(148, 163, 184, 0.05); }
tbody tr:last-child td { border-bottom: none; }

td.mono { font-family: var(--font-data); font-size: 0.78rem; }
td .dim { color: var(--muted-2); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid transparent;
}

.badge-green { background: var(--accent-soft); color: var(--accent); border-color: rgba(34, 197, 94, 0.25); }
.badge-gray { background: rgba(148, 163, 184, 0.1); color: var(--muted); border-color: var(--border); }
.badge-red { background: var(--danger-soft); color: #FCA5A5; border-color: rgba(239, 68, 68, 0.25); }

.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.pager .btn { width: auto; }

/* Forms (push / settings) */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full { grid-column: 1 / -1; }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
}

.field input, .field textarea, .field select {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field textarea { resize: vertical; min-height: 90px; font-family: var(--font-data); font-size: 0.82rem; }

.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

.field .hint { font-size: 0.72rem; color: var(--muted-2); margin-top: 4px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}

.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Toast */
.toast-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  min-width: 260px;
  max-width: 360px;
  animation: slideIn 0.25s ease;
}

.toast.err { border-left-color: var(--danger); }
.toast.info { border-left-color: #3B82F6; }

@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Empty state */
.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted-2);
}

.empty svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: 0.4; }
.empty p { font-size: 0.9rem; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Backups list */
.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  font-size: 0.85rem;
}

.backup-item:last-child { border-bottom: none; }
.backup-item .name { font-family: var(--font-data); font-size: 0.78rem; word-break: break-all; }
.backup-item .meta { font-size: 0.75rem; color: var(--muted-2); margin-top: 2px; }
.backup-item .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Responsive */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    align-items: center;
  }
  .sidebar .brand { margin-bottom: 0; margin-right: 8px; }
  .sidebar .spacer { display: none; }
  .nav-item { padding: 8px 10px; }
  .main { padding: 20px 16px 40px; }
  .form-grid { grid-template-columns: 1fr; }
}

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