:root {
  --bg: #0b0d11;
  --panel: #13171f;
  --panel-hover: #181e28;
  --border: #232936;
  --text: #f0f2f5;
  --muted: #8e95a2;
  --brand-red: #e0292b;
  --brand-yellow: #f5a623;
  --brand-black: #0b0d11;
  --accent: #e0292b;
  --accent-gold: #f5a623;
  --success: #2ecc71;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Sidebar */
:root {
  --sidebar-width: 68px;
  --neon: #00e5ff;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #0f1218;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  gap: 1.5rem;
  z-index: 20;
}

.sidebar-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #ffffff;
  padding: 2px;
  object-fit: contain;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  align-items: center;
}

.sidebar-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  width: 52px;
  padding: 0.6rem 0.25rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sidebar-glow {
  display: none;
}

.sidebar-link.active {
  color: var(--neon);
}

.sidebar-link.active .sidebar-glow {
  display: block;
  position: absolute;
  top: 4px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 6px 2px var(--neon), 0 0 14px 4px rgba(0, 229, 255, 0.6);
}

.main-wrapper {
  margin-left: var(--sidebar-width);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.feedback-status {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 0.5rem 0;
}

/* Header & Branding */
.topbar {
  padding: 1rem 2rem;
  background: #0f1218;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #ffffff;
  padding: 2px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.brand-info h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
}

.user-profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.28rem 0.65rem;
  border-radius: 20px;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--brand-yellow);
}

.header-user-name {
  color: var(--text);
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px rgba(46, 204, 113, 0.6);
  transition: background 0.2s ease;
}

.status-dot.offline {
  background: var(--brand-red);
  box-shadow: 0 0 6px rgba(224, 41, 43, 0.6);
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-refresh:hover {
  background: var(--panel-hover);
  border-color: var(--brand-yellow);
  color: var(--brand-yellow);
}

.btn-refresh:active {
  transform: scale(0.97);
}

/* Export Dropdown */
.export-dropdown {
  position: relative;
  display: inline-block;
}

.btn-export-main {
  border-color: rgba(245, 166, 35, 0.35);
  color: var(--brand-yellow);
}

.btn-export-main:hover {
  background: rgba(245, 166, 35, 0.1);
  border-color: var(--brand-yellow);
}

.chevron-icon {
  margin-left: 0.15rem;
  transition: transform 0.2s ease;
}

.export-dropdown.open .chevron-icon {
  transform: rotate(180deg);
}

.export-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: #13171f;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  padding: 0.4rem 0;
  animation: fadeIn 0.15s ease-out;
}

.export-dropdown.open .export-menu {
  display: block;
}

.export-menu-header {
  padding: 0.4rem 0.85rem;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.export-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.export-menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.export-item-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.export-item-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.export-item-text strong {
  font-size: 0.82rem;
  color: var(--text);
}

.export-item-text small {
  font-size: 0.72rem;
  color: var(--muted);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Layout */
.content {
  padding: 2rem;
  max-width: 1040px;
  margin: 0 auto;
}

/* Timeframe Filter Toolbar */
.time-filter-section {
  margin-bottom: 1.25rem;
}

.time-filter-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
}

.time-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.time-filter-label svg {
  color: var(--brand-yellow);
}

/* Stat Cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand-red);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:nth-child(2) {
  border-top-color: var(--brand-yellow);
}

.card:nth-child(3) {
  border-top-color: var(--brand-red);
}

.card:nth-child(4) {
  border-top-color: var(--brand-yellow);
}

.card:nth-child(5) {
  border-top-color: var(--brand-red);
}

.card:hover {
  transform: translateY(-2px);
  border-color: #384152;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.card-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-icon-red {
  background: rgba(224, 41, 43, 0.12);
  color: var(--brand-red);
}

.card-icon-yellow {
  background: rgba(245, 166, 35, 0.12);
  color: var(--brand-yellow);
}

.card-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.card-subtext {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 400;
}

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.35rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-left: 3px solid var(--brand-red);
  padding-left: 0.5rem;
}

.quick-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.action-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-group {
  display: inline-flex;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.btn-chip {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-chip:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.btn-chip.active {
  background: #1c222e;
  color: var(--brand-yellow);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-chip-export {
  border: 1px solid rgba(245, 166, 35, 0.35);
  color: var(--brand-yellow);
  background: rgba(245, 166, 35, 0.08);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-chip-export:hover {
  background: rgba(245, 166, 35, 0.18);
  border-color: var(--brand-yellow);
  color: var(--text);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.chart-panel {
  margin-bottom: 0;
}

.chart-panel:nth-child(2) h2 {
  border-left-color: var(--brand-yellow);
}

.chart-container {
  position: relative;
  height: 240px;
  max-width: 100%;
  margin: 0 auto;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Users Panel & Role Badges */
.users-panel {
  margin-top: 1.5rem;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-admin {
  background: rgba(245, 166, 35, 0.15);
  color: var(--brand-yellow);
  border: 1px solid rgba(245, 166, 35, 0.35);
}

.role-viewer {
  background: rgba(79, 140, 255, 0.12);
  color: #4f8cff;
  border: 1px solid rgba(79, 140, 255, 0.3);
}

/* Login Page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.5rem;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.login-note {
  margin: -0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.btn-ms-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  background: #ffffff;
  color: #1b1b1b;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-ms-signin:hover {
  opacity: 0.9;
}

.btn-ms-signin:active {
  transform: scale(0.98);
}

.btn-ms-signin:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.login-divider span {
  padding: 0 0.75rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-form label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.login-form input {
  background: #0b0d11;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}

.login-form input:focus {
  outline: none;
  border-color: var(--brand-yellow);
}

.login-submit {
  justify-content: center;
  margin-top: 0.3rem;
}

/* Error Banner */
.error-banner {
  background: #331517;
  border: 1px solid #6e2023;
  color: #fca5a5;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}
