:root {
  --bg-deep: #05080a;
  --bg-base: #080d11;
  --bg-elevated: #0b1117;
  --bg-surface: #101820;
  --bg-card: #0d141c;
  --bg-card-hover: #111a24;
  --bg-input: #0a1016;

  --surface: #101820;
  --surface-2: #0d141c;
  --surface-3: #151d27;

  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.09);
  --border-focus: rgba(45, 212, 191, 0.28);

  --text: #ffffff;
  --muted: #94a3b8;
  --text-muted: #64748b;

  --primary: #2dd4bf;
  --primary-2: #5eead4;
  --primary-hover: #5eead4;
  --primary-soft: rgba(45, 212, 191, 0.12);
  --primary-muted: rgba(45, 212, 191, 0.06);
  --primary-border: rgba(45, 212, 191, 0.28);

  --accent: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.1);
  --accent-glow: rgba(167, 139, 250, 0.08);

  --cyan: #38bdf8;
  --green: #4ade80;
  --gold: #fbbf24;
  --orange: #fb923c;
  --blue: #60a5fa;
  --pink: #f472b6;
  --purple: #a78bfa;
  --teal: #2dd4bf;
  --violet: #c084fc;

  --success: #4ade80;
  --danger: #f87171;
  --warning: #fbbf24;

  --cyan-glow: rgba(56, 189, 248, 0.08);
  --green-glow: rgba(74, 222, 128, 0.1);
  --gold-glow: rgba(251, 191, 36, 0.1);
  --orange-glow: rgba(251, 146, 60, 0.08);
  --blue-glow: rgba(96, 165, 250, 0.08);
  --pink-glow: rgba(244, 114, 182, 0.08);

  --radius: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --sidebar-width: 240px;
  --topbar-height: 70px;

  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;

  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.28);
  --shadow-glow: 0 0 40px rgba(45, 212, 191, 0.04);
  --focus-ring: 0 0 0 2px rgba(45, 212, 191, 0.22);
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Manrope", "Inter", sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body.app-shell {
  display: flex;
  min-height: 100vh;
}

::selection {
  background: rgba(45, 212, 191, 0.25);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-2); }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  padding: var(--space-3) var(--space-2);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-1) var(--space-2);
}

.brand-logo {
  width: 40px;
  height: 40px;
  display: block;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.brand-tagline {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  background: linear-gradient(135deg, #f0f3f8 0%, #2dd4bf 45%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(45, 212, 191, 0.15);
  filter: drop-shadow(0 0 12px rgba(45, 212, 191, 0.12));
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-4);
  overflow-y: auto;
  padding: 0 2px;
}

.sidebar-footer {
  padding-top: var(--space-2);
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.sidebar-logout {
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.72;
  transition: opacity var(--transition), color var(--transition);
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-deep);
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: rgba(5, 8, 10, 0.72);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-search {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.topbar-search::placeholder { color: var(--text-muted); }

.topbar-search:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: var(--focus-ring);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-left: var(--space-2);
  margin-left: var(--space-1);
  border-left: 1px solid var(--border);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.2), rgba(167, 139, 250, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.user-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.user-email {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.refresh-pill {
  font-size: 0.72rem;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ── Nav tabs ── */
.main-tabs {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: transparent;
  border: none;
  padding: 0;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition), box-shadow var(--transition);
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn:hover .nav-icon { opacity: 1; color: var(--primary); }

.tab-btn.active {
  color: var(--text);
  background: rgba(45, 212, 191, 0.12);
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.18), 0 0 24px rgba(45, 212, 191, 0.05);
}

.tab-btn.active .nav-icon {
  opacity: 1;
  color: var(--primary);
}

/* ── Layout ── */
.container {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-5);
}

.container-wide { max-width: 1520px; }

.tab-panel {
  display: none;
  animation: fadeIn var(--transition) ease;
}

.tab-panel.active { display: block; }

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

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  margin: 0 0 var(--space-1);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
}

.page-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

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

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 72px;
  pointer-events: none;
  opacity: 1;
}

.stat-card.glow-teal::before {
  background: radial-gradient(ellipse 80% 100% at 50% -20%, rgba(45, 212, 191, 0.14), transparent 70%);
}

.stat-card.glow-purple::before {
  background: radial-gradient(ellipse 80% 100% at 50% -20%, rgba(167, 139, 250, 0.14), transparent 70%);
}

.stat-card.glow-orange::before {
  background: radial-gradient(ellipse 80% 100% at 50% -20%, rgba(251, 146, 60, 0.13), transparent 70%);
}

.stat-card.glow-violet::before {
  background: radial-gradient(ellipse 80% 100% at 50% -20%, rgba(192, 132, 252, 0.13), transparent 70%);
}

.stat-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-glow);
}

.stat-label,
.stat-card .label {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-2);
}

.stat-value,
.stat-card .value {
  position: relative;
  z-index: 1;
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.stat-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
}

.stat-change {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

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

/* ── Overview toolbar ── */
.overview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.sub-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.sub-tab {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.sub-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.sub-tab.active {
  color: var(--bg-deep);
  background: var(--primary);
  border-color: transparent;
  box-shadow: 0 0 24px rgba(45, 212, 191, 0.15);
}

.toolbar-search input {
  width: 220px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.toolbar-search input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

/* ── Chart ── */
.chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.chart-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--muted);
}

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

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  height: 260px;
  cursor: crosshair;
}

.chart-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tooltip {
  position: absolute;
  z-index: 20;
  min-width: 160px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(13, 20, 28, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.chart-tip-time {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.chart-tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.6;
}

.chart-tip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-tip-label {
  flex: 1;
  color: var(--muted);
}

.chart-tip-value {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.chart-crosshair {
  stroke: rgba(45, 212, 191, 0.35);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  pointer-events: none;
}

.chart-grid line {
  stroke: rgba(255, 255, 255, 0.04);
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

.chart-axis-label,
text.chart-axis-label {
  fill: #94a3b8;
  font-size: 11px;
  font-family: var(--font);
}

.chart-line {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  opacity: 0.08;
}

/* ── Rank panels ── */
.rank-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.rank-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  min-height: 280px;
  transition: background var(--transition), box-shadow var(--transition);
}

.rank-panel:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-glow);
}

.rank-title {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.rank-row:last-child { border-bottom: none; }

.rank-row-main {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.rank-index {
  width: 24px;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
}

.rank-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-value {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.rank-value .resource-online {
  font-size: 0.76rem;
  font-weight: 500;
}

.rank-empty {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: var(--space-4) 0;
  text-align: center;
}

/* ── Panels ── */
.glass-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.panel {
  border-radius: var(--radius);
  padding: var(--space-4);
}

.panel-send { max-width: 680px; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}

.panel-desc {
  margin: 6px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

/* ── Orders ── */
.order-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.order-filter.active {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.orders-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: calc(100vh - 320px);
  overflow: auto;
}

.order-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  transition: background var(--transition), border-color var(--transition);
}

.order-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.order-card.status-completed { border-left: 2px solid var(--green); }
.order-card.status-failed { border-left: 2px solid var(--danger); }
.order-card.status-collecting,
.order-card.status-aggregating,
.order-card.status-delivering { border-left: 2px solid var(--orange); }

.order-card-top {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  margin-bottom: var(--space-2);
}

.order-item-visual {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border);
}

.order-item-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.order-item-visual .fallback {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--muted);
}

.order-card-main { flex: 1; min-width: 0; }

.order-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.order-card-title h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.order-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.order-meta-row strong { color: var(--text); }

.order-progress-wrap { margin-bottom: 10px; }

.order-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.order-progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.order-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: width 0.5s ease;
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.35);
}

.order-progress-fill.failed { background: var(--danger); box-shadow: none; }

.order-phase-box {
  margin: 10px 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-muted);
  border: 1px solid var(--primary-soft);
}

.order-phase-title {
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.order-phase-detail,
.order-phase-activity,
.order-receipts,
.order-missing {
  font-size: 0.8rem;
  color: var(--muted);
}

.order-missing { color: var(--orange); }

.order-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-1);
  margin-top: var(--space-2);
}

.order-stat {
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.order-stat .label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.order-stat .value {
  font-size: 0.9rem;
  font-weight: 600;
}

.order-contribs {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.order-contribs summary {
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--muted);
  user-select: none;
}

.contrib-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.contrib-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
}

.contrib-pill.completed,
.contrib-pill.received { border-color: rgba(74, 222, 128, 0.3); background: var(--green-glow); }
.contrib-pill.sent { border-color: rgba(96, 165, 250, 0.3); }
.contrib-pill.failed { border-color: rgba(248, 113, 113, 0.3); }
.contrib-pill.dispatched { border-color: rgba(251, 191, 36, 0.3); }

.orders-empty {
  text-align: center;
  padding: var(--space-5) var(--space-3);
  color: var(--muted);
}

.badge.collecting,
.badge.aggregating,
.badge.delivering,
.badge.planning {
  background: var(--gold-glow);
  color: var(--gold);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--muted);
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse 2s ease infinite;
}

.status-pill.completed .dot { background: var(--green); animation: none; }
.status-pill.failed .dot { background: var(--danger); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ── Forms ── */
.search-row { margin-bottom: var(--space-2); }
.search-row.compact { margin-bottom: 0; min-width: 240px; }
.search-row input { width: 100%; }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.send-grid {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.send-form label { display: block; }

.field-autocomplete { position: relative; }

.ac-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  max-height: 260px;
  overflow: auto;
  box-shadow: var(--shadow-soft);
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  transition: background var(--transition);
}

.ac-item:hover,
.ac-item.active { background: var(--primary-soft); }

.ac-item img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  flex-shrink: 0;
}

.ac-item-text { min-width: 0; }
.ac-item-name { font-weight: 600; }
.ac-item-meta { font-size: 0.76rem; color: var(--muted); }

input, select, button { font: inherit; }

input, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder { color: var(--text-muted); }

input:focus, select:focus {
  border-color: var(--border-focus);
  background: var(--bg-elevated);
  box-shadow: var(--focus-ring);
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.btn.primary {
  background: var(--primary);
  color: var(--bg-deep);
}

.btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 24px rgba(45, 212, 191, 0.2);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn.ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-strong);
}

.btn.small { padding: 7px 12px; font-size: 0.82rem; }
.btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.25); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.form-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.item-preview {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.item-preview-image-wrap {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.item-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.item-preview-fallback {
  font-size: 1.4rem;
  color: var(--muted);
  font-weight: 600;
}

.item-preview-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.item-preview-category {
  margin-top: 4px;
  font-size: 0.84rem;
}

.distribution-preview {
  margin-bottom: var(--space-2);
  padding: var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.distribution-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.88rem;
}

.dist-allocations {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
}

.dist-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.dist-row .amount {
  color: var(--success);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Resources ── */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-2);
  max-height: calc(100vh - 320px);
  overflow: auto;
}

.resource-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.resource-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-glow);
}

.resource-card-image {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.resource-card-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.resource-card-image .fallback {
  font-size: 1.4rem;
  color: var(--muted);
}

.resource-card-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.25;
  word-break: break-word;
}

.resource-card-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.resource-main-count {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  line-height: 1.35;
}

.resource-main-count strong { color: var(--text); }

.resource-acc {
  font-size: 0.76rem;
}

.resource-card-stats strong { color: var(--text); }

.resource-online {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.table-scroll { max-height: calc(100vh - 340px); overflow: auto; }

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

th, td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: lowercase;
}

.badge.online { background: var(--green-glow); color: var(--green); }
.badge.offline { background: rgba(255, 255, 255, 0.04); color: var(--muted); }
.badge.completed { background: var(--green-glow); color: var(--green); }
.badge.processing { background: var(--gold-glow); color: var(--gold); }
.badge.failed { background: rgba(248, 113, 113, 0.1); color: var(--danger); }
.badge.pending { background: var(--accent-glow); color: var(--accent); }
.badge.ok { background: var(--green-glow); color: var(--green); }
.badge.warn { background: var(--gold-glow); color: var(--gold); }

.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--danger); font-size: 0.88rem; }
.success { color: var(--success); font-size: 0.88rem; }
.hidden { display: none !important; }

.inline-check,
.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
  cursor: pointer;
}

.toggle-pill {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.toggle-pill:has(input:checked) {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

/* ── Auth ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(var(--space-3), env(safe-area-inset-top)) max(var(--space-3), env(safe-area-inset-right)) max(var(--space-3), env(safe-area-inset-bottom)) max(var(--space-3), env(safe-area-inset-left));
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-deep);
}

.auth-minimal { background: var(--bg-deep); }

.auth-card {
  position: relative;
  z-index: 1;
  padding: var(--space-2);
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  max-width: 360px;
  width: 100%;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(45, 212, 191, 0.08), transparent);
  pointer-events: none;
}

.auth-card-minimal { padding: var(--space-2); }

.auth-minimal input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-minimal input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

.auth-minimal input.invalid {
  border-color: var(--danger);
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.12); }

/* ── Responsive ── */
.mobile-only { display: none; }
.desktop-only { display: inline-flex; }

@media (max-width: 1400px) {
  .container { padding: var(--space-3) var(--space-3) var(--space-4); }
}

@media (max-width: 1200px) {
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .rank-grid { grid-template-columns: 1fr; }
  .panel-send { max-width: 100%; }
  .chart-wrap { height: 240px; }
}

@media (max-width: 900px) {
  :root {
    --topbar-height: 60px;
    --sidebar-width: 72px;
  }

  .sidebar {
    width: var(--sidebar-width);
    padding: var(--space-2) 10px;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }

  .brand-tagline { display: none; }

  .tab-btn {
    font-size: 0;
    justify-content: center;
    padding: 12px;
    min-height: 44px;
  }

  .sidebar-logout {
    font-size: 0;
    justify-content: center;
    min-height: 44px;
  }

  .app-main { margin-left: var(--sidebar-width); }

  .topbar { padding: 0 var(--space-2); gap: var(--space-2); }
  .container { padding: var(--space-3) var(--space-2) var(--space-4); }

  .page-head { margin-bottom: var(--space-3); }
  .stats-grid { margin-bottom: var(--space-3); }
  .chart-panel { padding: var(--space-3); margin-bottom: var(--space-3); }

  .order-filters { width: 100%; }
  .order-filters .btn { flex: 1 1 auto; min-width: 0; }

  .orders-feed { max-height: none; }
  .resources-grid { max-height: none; }
  .table-scroll { max-height: none; }

  .search-row.compact { min-width: 0; width: 100%; }
}

@media (max-width: 768px) {
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: var(--space-2); }
  .stat-value, .stat-card .value { font-size: 1.45rem; }

  .chart-header { flex-direction: column; align-items: flex-start; }
  .chart-wrap { height: 220px; max-width: 100%; }

  .rank-panel { padding: var(--space-3); min-height: 0; }
  .panel { padding: var(--space-3); }

  .order-card-top { flex-wrap: wrap; }
  .order-item-visual { width: 56px; height: 56px; }

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

  .resources-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  table { font-size: 0.82rem; }
  th, td { padding: 10px 8px; }

  .pager { flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 640px) {
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }

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

  .sidebar {
    inset: auto 0 0 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-right: none;
    border-top: 1px solid var(--border);
    background: rgba(8, 13, 17, 0.96);
    backdrop-filter: blur(16px);
  }

  .sidebar-brand,
  .sidebar-footer { display: none; }

  .sidebar-nav {
    flex-direction: row;
    margin-top: 0;
    width: 100%;
    justify-content: space-around;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar { display: none; }

  .tab-btn {
    flex: 1 1 0;
    min-width: 48px;
    max-width: 72px;
    min-height: 48px;
    padding: 10px;
  }

  .app-main {
    margin-left: 0;
    margin-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .topbar {
    height: auto;
    min-height: var(--topbar-height);
    padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  }

  .topbar-search-wrap { max-width: none; flex: 1; }
  .refresh-pill { display: none; }

  .container {
    padding: var(--space-2) max(12px, env(safe-area-inset-right)) var(--space-3) max(12px, env(safe-area-inset-left));
  }

  .page-title { font-size: 1.35rem; }
  .page-desc { font-size: 0.85rem; }

  .overview-toolbar { flex-direction: column; align-items: stretch; }
  .sub-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .sub-tab { flex-shrink: 0; }
  .toolbar-search input { width: 100%; }

  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; min-height: 44px; }

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

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .page-head .toggle-pill,
  .page-head .order-filters { align-self: flex-start; }

  .order-filters { gap: 6px; }
  .order-filters .btn { padding: 8px 10px; font-size: 0.78rem; }

  .resources-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .resource-card-image { height: 64px; }

  .accounts-table-hide-sm { display: none; }

  .chart-wrap { height: 200px; }

  .dist-row { flex-direction: column; align-items: flex-start; gap: 4px; }

  .distribution-summary { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 400px) {
  .resources-grid { grid-template-columns: 1fr; }
  .order-stats-grid { grid-template-columns: 1fr; }
  .stat-footer { flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (hover: none) and (pointer: coarse) {
  .tab-btn,
  .btn,
  .resource-card,
  .order-card,
  .ac-item {
    -webkit-tap-highlight-color: transparent;
  }

  .tab-btn { min-height: 48px; }
  input, select, .btn { min-height: 44px; }
}
