/* Nestina Client Panel — elegant, light, GPU-friendly CSS */
:root {
  --bg: #f4f7fb;
  --bg-soft: #eef3f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #0f766e;
  --brand-2: #0ea5a4;
  --brand-soft: rgba(15, 118, 110, 0.1);
  --accent: #0284c7;
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.1);
  --danger: #e11d48;
  --danger-soft: rgba(225, 29, 72, 0.08);
  --warn: #d97706;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 248px;
  --font: "Manrope", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--mono); font-size: 0.84rem; }
.muted { color: var(--muted); }
.help { margin: 6px 0 0; font-size: 0.82rem; color: var(--muted); }

/* ---------- App shell (sidebar) ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background:
    linear-gradient(180deg, #0b1c2c 0%, #0d2436 48%, #0a1a28 100%);
  color: #e2e8f0;
  border-right: 1px solid rgba(148, 163, 184, 0.12);
  overflow: auto;
  overscroll-behavior: contain;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  margin-bottom: 14px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: #042f2e;
  background: linear-gradient(135deg, #2dd4bf, #38bdf8);
  box-shadow: 0 8px 20px rgba(45, 212, 191, 0.25);
  flex-shrink: 0;
}

.brand-text strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text span {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 1px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-label {
  margin: 12px 10px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
  will-change: transform;
}

.nav-link:hover {
  background: rgba(148, 163, 184, 0.1);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.18), rgba(56, 189, 248, 0.12));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.22);
}

.nav-ico {
  width: 18px;
  height: 18px;
  opacity: 0.9;
  flex-shrink: 0;
}

.sidebar-foot {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.35);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(45, 212, 191, 0.18);
  color: #5eead4;
  font-weight: 700;
  font-size: 0.8rem;
}

.user-meta strong {
  display: block;
  font-size: 0.84rem;
  color: #f1f5f9;
}

.user-meta span {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(244, 247, 251, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-title h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.topbar-title p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.content {
  padding: 22px;
  width: min(1120px, 100%);
  margin: 0 auto;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

/* ---------- Cards / stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card h1, .card h2 {
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

.card h1 { font-size: 1.28rem; }
.card h2 { font-size: 1.02rem; color: var(--ink-soft); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

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

.stat {
  position: relative;
  overflow: hidden;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--brand-soft);
  pointer-events: none;
}

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

.stat .value {
  margin-top: 6px;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover td { background: var(--surface-2); }

/* ---------- Forms / buttons ---------- */
label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input, select, textarea {
  width: 100%;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 12px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(14, 165, 164, 0.18);
}

.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn, button, input[type=submit] {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--brand), #0ea5a4);
  color: #fff;
  font-weight: 650;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.9rem;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.2);
  transition: transform 0.15s var(--ease), filter 0.15s var(--ease), box-shadow 0.15s var(--ease);
  text-decoration: none;
}

.btn:hover, button:hover, input[type=submit]:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn:active, button:active { transform: translateY(0); }

.btn.secondary, button.secondary {
  background: #fff;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.btn.danger, button.danger {
  background: linear-gradient(135deg, #fb7185, #e11d48);
  box-shadow: 0 8px 18px rgba(225, 29, 72, 0.18);
}

.btn.small, button.small {
  padding: 7px 12px;
  font-size: 0.8rem;
  box-shadow: none;
}

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-2);
}

.badge.on {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: rgba(5, 150, 105, 0.2);
}

.badge.off {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(225, 29, 72, 0.18);
}

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  border: 1px solid;
  font-size: 0.92rem;
}

.flash.ok {
  background: var(--ok-soft);
  border-color: rgba(5, 150, 105, 0.25);
  color: #065f46;
}

.flash.error {
  background: var(--danger-soft);
  border-color: rgba(225, 29, 72, 0.22);
  color: #9f1239;
}

.file-row form { display: inline; }

/* ---------- Login (CSS-only ambient motion) ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: #07131f;
  color: #e2e8f0;
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.login-bg .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  will-change: transform;
  transform: translateZ(0);
  animation: drift 18s ease-in-out infinite alternate;
}

.login-bg .orb.a {
  width: 42vw;
  height: 42vw;
  max-width: 520px;
  max-height: 520px;
  left: -8%;
  top: -12%;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.55), transparent 70%);
}

.login-bg .orb.b {
  width: 38vw;
  height: 38vw;
  max-width: 460px;
  max-height: 460px;
  right: -10%;
  bottom: -16%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.45), transparent 70%);
  animation-duration: 22s;
  animation-delay: -4s;
}

.login-bg .orb.c {
  width: 28vw;
  height: 28vw;
  max-width: 340px;
  max-height: 340px;
  left: 40%;
  top: 55%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.28), transparent 70%);
  animation-duration: 26s;
  animation-delay: -8s;
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
  animation: gridshift 40s linear infinite;
  will-change: transform;
  transform: translateZ(0);
  opacity: 0.7;
}

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(4%, -3%, 0) scale(1.06); }
  100% { transform: translate3d(-3%, 4%, 0) scale(0.98); }
}

@keyframes gridshift {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(48px, 48px, 0); }
}

@keyframes floatcard {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -6px, 0); }
}

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

.login-shell {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  animation: floatcard 7s ease-in-out infinite;
  will-change: transform;
}

.login-card {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  padding: 28px 26px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
}

.login-card .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #99f6e4;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.22);
  margin-bottom: 14px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #f8fafc, #99f6e4, #7dd3fc, #f8fafc);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sheen 8s linear infinite;
}

.login-card .lead {
  margin: 0 0 18px;
  color: #94a3b8;
  font-size: 0.92rem;
}

.login-card label { color: #cbd5e1; }
.login-card input {
  background: rgba(2, 6, 23, 0.55);
  border-color: rgba(148, 163, 184, 0.28);
  color: #f8fafc;
}

.login-card input:focus {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

.login-card .btn-login {
  width: 100%;
  margin-top: 8px;
  border-radius: 14px;
  padding: 12px 16px;
}

.login-foot {
  margin-top: 14px;
  text-align: center;
  font-size: 0.78rem;
  color: #64748b;
}

.login-flash {
  position: relative;
  z-index: 2;
  width: min(440px, 100%);
  margin: 0 auto 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.22s var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.45);
    z-index: 30;
  }
  .sidebar-backdrop.show { display: block; }
}

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