/* Pulse Admin — dashboard demo */
:root {
  --bg: #0b0f14;
  --bg-elevated: #111820;
  --surface: #161d27;
  --surface-2: #1c2532;
  --border: rgba(255, 255, 255, 0.07);
  --text: #e8edf4;
  --muted: #7d8da6;
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", monospace;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 12px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.15rem 0.4rem;
  background: var(--bg);
  border-radius: 4px;
}

/* Hidden fix */
[hidden] {
  display: none !important;
}

.view[hidden] {
  display: none !important;
}

.notif-panel[hidden],
.sidebar-overlay[hidden] {
  display: none !important;
}

/* App layout */
.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.4s var(--ease);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.25rem 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
}

.sidebar__logo {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
  font-size: 0.85rem;
  color: white;
}

.sidebar__nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
  text-align: left;
}

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

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.is-active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
}

.nav-item__badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  background: var(--warn);
  color: #1a1408;
  border-radius: 999px;
}

.sidebar__foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar__back {
  font-size: 0.8rem;
  color: var(--muted);
  transition: color 0.25s;
}

.sidebar__back:hover {
  color: var(--accent);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.35s;
}

.sidebar-overlay.is-open {
  opacity: 1;
}

/* Main area */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar — always visible */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: rgba(11, 15, 20, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar__menu {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 0.5rem;
}

.topbar__menu span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.topbar__search {
  flex: 1;
  max-width: 360px;
}

.topbar__search input {
  width: 100%;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.25s;
}

.topbar__search input:focus {
  outline: none;
  border-color: var(--accent);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.notif-wrap {
  position: relative;
}

.topbar__icon {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.25s;
}

.topbar__icon svg {
  width: 18px;
  height: 18px;
}

.topbar__icon:hover {
  border-color: var(--accent);
}

.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-elevated);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  z-index: 60;
  animation: dropIn 0.3s var(--ease);
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.notif-panel__title {
  padding: 0.85rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.notif-panel ul {
  max-height: 280px;
  overflow-y: auto;
}

.notif-panel li {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.notif-panel li:hover {
  background: var(--surface-2);
}

.notif-panel p {
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
}

.notif-panel time {
  font-size: 0.72rem;
  color: var(--muted);
}

.user-menu__btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
}

.user-menu__avatar {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  color: white;
}

/* Content */
.content {
  flex: 1;
  padding: 1.5rem;
}

.view {
  animation: viewIn 0.4s var(--ease);
}

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

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-head h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.page-head__sub {
  font-size: 0.88rem;
  color: var(--muted);
}

.period-select {
  padding: 0.5rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
}

.link {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
}

.link:hover {
  text-decoration: underline;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stats--4 {
  grid-template-columns: repeat(4, 1fr);
}

.stat-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.3s var(--ease), border-color 0.3s;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(59, 130, 246, 0.25);
}

.stat-card__icon {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.stat-card__label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--mono);
  margin-bottom: 0.35rem;
}

.stat-card--compact .stat-card__value {
  font-size: 1.25rem;
}

.stat-card__change {
  font-size: 0.72rem;
  color: var(--muted);
}

.stat-card__change.is-up {
  color: var(--success);
}

/* Grid & cards */
.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.card--narrow {
  max-width: 480px;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card__head h2 {
  font-size: 1rem;
  font-weight: 600;
}

.card__meta {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Charts */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 180px;
  padding-top: 0.5rem;
}

.chart--tall {
  height: 220px;
}

.chart-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar__fill {
  width: 100%;
  max-width: 40px;
  height: var(--h);
  border-radius: 6px 6px 2px 2px;
  animation: barGrow 0.8s var(--ease) backwards;
  animation-delay: var(--delay);
  opacity: 0.9;
  transition: opacity 0.25s;
}

.chart-bar:hover .chart-bar__fill {
  opacity: 1;
}

@keyframes barGrow {
  from { height: 0; }
  to { height: var(--h); }
}

.chart-bar__label {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

/* Donut */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.5rem 0;
}

.donut {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 22%;
  background: var(--surface);
  border-radius: 50%;
}

.donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--mono);
}

.donut-legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  text-transform: capitalize;
}

.donut-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.donut-legend strong {
  margin-left: auto;
  color: var(--text);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

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

.table th {
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.table tbody tr {
  transition: background 0.2s;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: capitalize;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}

.badge--pending {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warn);
}

.badge--processing {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.badge--shipped {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
}

.badge--delivered {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.badge--in-stock {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.badge--low-stock {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warn);
}

.badge--out-of-stock {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.text-warn { color: var(--warn); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }

.status-select {
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.status-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Toolbar tabs */
.toolbar {
  margin-bottom: 1rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tab {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.tab:hover {
  color: var(--text);
  background: var(--surface);
}

.tab.is-active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
}

/* Customers */
.customers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.customer-card {
  padding: 1.25rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: transform 0.3s var(--ease), border-color 0.3s;
}

.customer-card:hover {
  transform: translateY(-3px);
  border-color: rgba(59, 130, 246, 0.2);
}

.customer-card__avatar {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  color: white;
  margin-bottom: 0.75rem;
}

.customer-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.customer-card p {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.customer-card__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
}

.customer-card__meta strong {
  color: var(--success);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  transition: transform 0.2s, background 0.2s;
}

.btn--primary {
  background: var(--accent);
  color: white;
}

.btn--primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

/* Settings form */
.settings-form .form-row {
  margin-bottom: 1rem;
}

.settings-form label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.settings-form input,
.settings-form select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.settings-form input:focus,
.settings-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row--check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-row--check label {
  margin: 0;
  color: var(--text);
}

.form-msg {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  min-height: 1.2rem;
}

.form-msg--ok {
  color: var(--success);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.4s;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 1100px) {
  .stats,
  .stats--4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .topbar__menu {
    display: flex;
  }

  .topbar__search {
    max-width: none;
  }

  .stats,
  .stats--4 {
    grid-template-columns: 1fr;
  }

  .donut-wrap {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .view,
  .chart-bar__fill {
    animation: none;
  }
}
