:root {
  --bg: #0b1220;
  --bg-elevated: #111827;
  --bg-card: #151f32;
  --bg-soft: #1a2438;
  --border: #243049;
  --text: #e8eef9;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-2: #3b82f6;
  --primary-soft: rgba(37, 99, 235, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37,99,235,.25), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(14,165,233,.12), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary-2); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.container { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: .85rem; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent 40%), var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: .7rem 1rem;
  font-weight: 600;
  transition: .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--border);
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  border-color: transparent;
  color: white;
}
.btn-danger { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.35); color: #fecaca; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .4rem .7rem; font-size: .85rem; border-radius: 10px; }
.btn-block { width: 100%; }

.input, .select, .textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: .75rem .9rem;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; font-weight: 500; }
.field { display: flex; flex-direction: column; gap: .25rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: #93c5fd;
  border: 1px solid rgba(37,99,235,.25);
}
.badge-ok { background: rgba(16,185,129,.12); color: #6ee7b7; border-color: rgba(16,185,129,.25); }
.badge-warn { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.25); }
.badge-danger { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.25); }

.topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(11,18,32,.8);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .9rem 0;
}
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
  display: grid; place-items: center; color: white; font-size: .9rem;
  box-shadow: 0 8px 20px rgba(37,99,235,.35);
}
.nav-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.hero {
  padding: 2.5rem 0 1.5rem;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.15;
  margin: 0 0 .75rem;
  letter-spacing: -.03em;
}
.hero p { color: var(--muted); max-width: 52ch; margin: 0 0 1.25rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .85rem;
  margin: 1rem 0 1.5rem;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .9rem 1rem;
}
.stat .n { font-size: 1.4rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .8rem; }

.grid-contacts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.contact-card h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.contact-card .meta { color: var(--muted); font-size: .9rem; margin-bottom: .75rem; }
.contact-card .actions { display: flex; flex-wrap: wrap; gap: .4rem; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,.72);
  display: grid; place-items: center; z-index: 60; padding: 1rem;
}
.modal {
  width: min(560px, 100%);
  max-height: min(90vh, 860px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.modal h2 { margin: 0 0 1rem; font-size: 1.2rem; }
.modal-wide { width: min(920px, 100%); }

.toast-wrap {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 80;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: .75rem 1rem;
  border-radius: 12px;
  min-width: 240px;
  box-shadow: var(--shadow);
  animation: slide .2s ease;
}
.toast.err { border-color: rgba(239,68,68,.45); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

.auth-wrap {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth-card { width: min(420px, 100%); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; background: var(--bg); padding: .3rem; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 1rem; }
.tab {
  border: 0; background: transparent; color: var(--muted); padding: .65rem; border-radius: 10px; font-weight: 600;
}
.tab.active { background: var(--primary-soft); color: var(--text); }

.preview-img {
  width: 100%; max-height: 180px; object-fit: contain;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
}

/* Admin layout */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: #0a101c;
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { margin-bottom: 1.5rem; }
.side-nav { display: flex; flex-direction: column; gap: .25rem; }
.side-nav button {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: .7rem .8rem;
  border-radius: 10px;
  font-weight: 600;
}
.side-nav button.active, .side-nav button:hover {
  background: var(--primary-soft);
  color: var(--text);
}
.admin-main { padding: 1.25rem 1.5rem 2.5rem; }
.admin-main h1 { margin: 0 0 .25rem; font-size: 1.5rem; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .7rem .8rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: rgba(0,0,0,.2); position: sticky; top: 0; }
tr:hover td { background: rgba(255,255,255,.02); }
.switch {
  width: 42px; height: 24px; border-radius: 999px; border: 1px solid var(--border);
  background: #334155; position: relative; cursor: pointer;
}
.switch.on { background: var(--primary); }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: white; transition: .15s;
}
.switch.on::after { left: 20px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .85rem;
  margin: 1rem 0 1.5rem;
}
.kpi { padding: 1rem; border-radius: 12px; background: var(--bg-card); border: 1px solid var(--border); }
.kpi .v { font-size: 1.5rem; font-weight: 700; }
.kpi .k { color: var(--muted); font-size: .8rem; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .82rem; }
.secret-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
}

.empty {
  text-align: center; padding: 2.5rem 1rem; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
