/* Loop Console — VoltPulse design tokens (mirrors app/lib/core/theme/app_colors.dart) */
:root {
  --primary: #5b3fe8;
  --primary-deep: #3a22c2;
  --primary-soft: #eae6ff;
  --bg: #f5f5fa;
  --surface: #ffffff;
  --surface-alt: #ecebf4;
  --ink: #17151f;
  --ink-soft: #5b5766;
  --ink-faint: #9c97ab;
  --line: #e6e4f0;
  --success: #00b884;
  --gold: #f0a500;
  --danger: #e03b3b;
  --scrim: rgba(23, 21, 31, 0.5);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --shadow-1: 0 1px 2px rgba(23, 21, 31, 0.06), 0 1px 3px rgba(23, 21, 31, 0.04);
  --shadow-2: 0 4px 16px rgba(23, 21, 31, 0.08);
  --shadow-3: 0 12px 32px rgba(58, 34, 194, 0.14);

  --font-body: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-head: "Barlow Condensed", "Barlow", -apple-system, sans-serif;

  --sidebar-w: 248px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: 0.2px;
  margin: 0;
  color: var(--ink);
}

a {
  color: var(--primary-deep);
  text-decoration: none;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

/* ---------- Boot / loading ---------- */
.app-loading {
  display: grid;
  place-items: center;
  height: 100vh;
}
.boot-spinner,
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Login ---------- */
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(
      1200px 600px at 20% -10%,
      rgba(91, 63, 232, 0.14),
      transparent 60%
    ),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 32px 28px;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.login-brand .logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 20px;
}
.login-brand h1 {
  font-size: 22px;
}
.login-brand span {
  color: var(--ink-faint);
  font-size: 13px;
  display: block;
  font-family: var(--font-body);
}

/* ---------- Forms ---------- */
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.input,
select.input,
textarea.input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: var(--r-sm);
  padding: 0 14px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
}
.input:focus,
select.input:focus,
textarea.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 63, 232, 0.15);
}
.input::placeholder {
  color: var(--ink-faint);
}

/* ---------- Buttons ---------- */
.btn {
  height: 46px;
  padding: 0 20px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s, filter 0.15s, background 0.15s;
}
.btn:hover {
  filter: brightness(1.05);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.block {
  width: 100%;
}
.btn.ghost {
  background: transparent;
  color: var(--primary-deep);
  border: 1.5px solid var(--primary-deep);
}
.btn.subtle {
  background: var(--surface-alt);
  color: var(--ink);
}
.btn.danger {
  background: var(--danger);
}
.btn.success {
  background: var(--success);
}
.btn.sm {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

/* ---------- App shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
}
.sidebar .brand .logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-head);
  font-weight: 700;
}
.sidebar .brand strong {
  font-family: var(--font-head);
  font-size: 19px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 14.5px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  flex-shrink: 0;
}
.nav-item:hover {
  background: var(--surface-alt);
  color: var(--ink);
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-deep);
}
.sidebar .spacer {
  flex: 1;
}
.sidebar .who {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.sidebar .who b {
  color: var(--ink);
  display: block;
  font-weight: 600;
}

.main {
  padding: 26px 32px 60px;
  max-width: 1180px;
  width: 100%;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 {
  font-size: 30px;
}
.page-head p {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Cards / layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  padding: 20px;
}
.card h3 {
  font-size: 17px;
  margin-bottom: 14px;
}
.grid {
  display: grid;
  gap: 16px;
}
.grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}
.row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.row.wrap {
  flex-wrap: wrap;
}
.row.end {
  justify-content: flex-end;
}
.mt {
  margin-top: 16px;
}
.mb {
  margin-bottom: 16px;
}

/* ---------- Stat tiles ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  padding: 18px 20px;
}
.stat .label {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat .label svg {
  width: 16px;
  height: 16px;
  stroke: var(--primary);
}
.stat .value {
  font-family: var(--font-head);
  font-size: 34px;
  font-weight: 700;
  margin-top: 8px;
  line-height: 1;
}
.stat .sub {
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 6px;
}
.stat .sub.up {
  color: var(--success);
}
.stat .sub.down {
  color: var(--danger);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 520px;
}
table.tbl th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
  font-weight: 600;
  white-space: nowrap;
}
table.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.tbl tr:last-child td {
  border-bottom: none;
}
table.tbl tr:hover td {
  background: rgba(91, 63, 232, 0.03);
}

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--ink-soft);
}
.pill.green {
  background: rgba(0, 184, 132, 0.14);
  color: #05815e;
}
.pill.red {
  background: rgba(224, 59, 59, 0.13);
  color: #b32020;
}
.pill.gold {
  background: rgba(240, 165, 0, 0.16);
  color: #97690a;
}
.pill.violet {
  background: var(--primary-soft);
  color: var(--primary-deep);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Avatar ---------- */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-deep);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ---------- Charts ---------- */
.chart svg {
  width: 100%;
  height: auto;
  display: block;
}
.chart .bar {
  transition: height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}
.legend .k {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .sw {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  font-size: 14px;
  min-width: 220px;
  animation: rise 0.3s ease both;
}
.toast.err {
  background: var(--danger);
}
.toast.ok {
  background: var(--success);
}

/* ---------- Modal ---------- */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 24px;
  animation: fade 0.2s ease both;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.modal h3 {
  font-size: 20px;
  margin-bottom: 12px;
}

/* ---------- States ---------- */
.empty,
.err-box {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-faint);
}
.err-box {
  color: var(--danger);
}
.center-load {
  display: grid;
  place-items: center;
  padding: 48px;
}

/* ---------- Animations (signature entrance) ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.stagger > * {
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.stagger > *:nth-child(1) {
  animation-delay: 0.02s;
}
.stagger > *:nth-child(2) {
  animation-delay: 0.07s;
}
.stagger > *:nth-child(3) {
  animation-delay: 0.12s;
}
.stagger > *:nth-child(4) {
  animation-delay: 0.17s;
}
.stagger > *:nth-child(5) {
  animation-delay: 0.22s;
}
.stagger > *:nth-child(6) {
  animation-delay: 0.27s;
}
.stagger > *:nth-child(7) {
  animation-delay: 0.32s;
}
.stagger > *:nth-child(8) {
  animation-delay: 0.37s;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: var(--sidebar-w);
  }
  .sidebar.open {
    transform: none;
    box-shadow: var(--shadow-3);
  }
  .main {
    padding: 18px 16px 60px;
  }
  .grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }
  .topbar-mobile {
    display: flex !important;
  }
}
.topbar-mobile {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.hamburger {
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
}
.hamburger svg {
  width: 22px;
  height: 22px;
  stroke: var(--ink);
}
.scrim-mobile {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 40;
}
.scrim-mobile.show {
  display: block;
}
