:root {
  /* Color Palette */
  --white: #FFFFFF;
  --black: #000000;
  --red: #FF0000;
  --red-hover: #cc0000;
  --grey-dark: #8E8E8E;
  --grey-light: #E5E5E5;
  --grey-bg: #F2F2F2;

  /* Theme Mapping */
  --bg-body: #F8F9FA;
  --bg-card: var(--white);
  --bg-sidebar: var(--white);

  --text-main: var(--black);
  --text-inverse: var(--black);
  --text-muted: #666666;

  --primary: var(--red);
  --primary-hover: var(--red-hover);
  --border-color: var(--grey-light);

  --shadow-card: none;
  --shadow-hover: none;

  --radius-card: 12px;
  --radius-btn: 8px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* --- Layout --- */
.view {
  min-height: 100vh;
  display: flex;
}

/* Dashboard Grid Layout */
.dashboard-view {
  display: flex;
  flex-direction: row;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
  border-right: 1px solid var(--border-color);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  padding: 0 12px;
}

.logo-icon.small svg {
  width: 32px;
  height: 32px;
}

.logo-icon.small path {
  stroke: var(--black);
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-name .highlight {
  color: var(--primary);
}

.logo-container {
  padding: 0 4px;
}

.sidebar-logo {
  max-width: 140px;
  height: auto;
  display: block;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-btn);
  color: #a0a0a0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.nav-item:hover {
  color: var(--primary);
  background-color: rgba(255, 0, 0, 0.05);
}

.nav-item.active {
  background-color: var(--primary);
  color: var(--white);
  box-shadow: none;
}

.nav-item svg {
  opacity: 0.8;
}

.nav-item.active svg {
  opacity: 1;
}

/* Main Content */
.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-body);
}

.topbar {
  background-color: var(--bg-card);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.meta-info {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.period-badge,
.update-badge {
  background: var(--bg-body);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.header-controls {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
}

.date-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-body);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.date-inputs input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  width: 110px;
  cursor: pointer;
}

.separator {
  color: var(--text-muted);
  font-size: 12px;
}

.account-select-wrapper select {
  border: 1px solid var(--border-color);
  background: var(--bg-body);
  border-radius: 6px;
  padding: 4px;
  font-size: 12px;
  width: 150px;
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.btn.primary {
  background-color: var(--primary);
  color: var(--white);
}

.btn.primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(255, 0, 0, 0.25);
  transform: translateY(-1px);
}

.btn.icon-btn {
  padding: 10px;
  background: var(--white);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff5f5;
}

.btn.text-btn {
  background: none;
  padding: 4px 8px;
  color: var(--primary);
  font-size: 12px;
}

.btn.text-btn:hover {
  text-decoration: underline;
}

/* Content Area */
.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.tab-panel {
  max-width: 1200px;
  margin: 0 auto;
}

/* --- Cards & Grid --- */
.grid {
  display: grid;
  gap: 24px;
  margin-bottom: 24px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  border-color: #d1d1d1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.big-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.sub-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Special Cards */
.highlight-card {
  background: var(--primary);
  color: var(--white);
  border: none;
}

.highlight-card .big-number {
  color: var(--white);
}

.highlight-card h3,
.highlight-card .sub-label {
  color: rgba(255, 255, 255, 0.8);
}

.highlight-card .icon-box {
  background: rgba(255, 255, 255, 0.1);
  padding: 8px;
  border-radius: 8px;
  color: var(--white);
}

.card-chart-bg {
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 150px;
  height: 100px;
  opacity: 0.2;
  pointer-events: none;
}

.kpi-card {
  justify-content: center;
  gap: 8px;
}

.kpi-card span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.kpi-card.warning strong {
  color: var(--red);
}

.chart {
  width: 100%;
  height: 250px;
  margin-top: auto;
}

.large-chart {
  height: 350px;
}

/* Lists */
.modern-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.list-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--bg-body);
  font-size: 14px;
}

.list-row:last-child {
  border-bottom: none;
}

.list-row div:first-child {
  font-weight: 500;
  color: var(--text-main);
}

.list-row div:last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Login Page */
.login-view {
  background-color: var(--black);
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.login-background {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.shape {
  position: absolute;
  filter: blur(80px);
  opacity: 0.4;
}

.shape-1 {
  top: -10%;
  left: -10%;
  width: 500px;
  height: 500px;
  background: var(--red);
  border-radius: 50%;
}

.shape-2 {
  bottom: -10%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: #333;
  border-radius: 50%;
}

.login-card {
  width: 100%;
  max-width: 400px;
  z-index: 10;
  padding: 40px;
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .logo-icon {
  margin: 0 auto 16px;
  width: 48px;
  height: 48px;
  background: var(--black);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.login-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-header p {
  margin: 0;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 20px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

.input-wrapper input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-btn);
  font-size: 14px;
  transition: var(--transition);
}

.input-wrapper input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.login-card button {
  width: 100%;
  margin-top: 8px;
  gap: 8px;
}

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

/* Utilities */
.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
}

.pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-body);
}

.mini-trend {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.mini-trend.positive {
  color: #10b981;
  background: #ecfdf5;
}

.mini-trend.negative {
  color: var(--red);
  background: #fef2f2;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-enter {
  animation: fadeInUp 0.5s ease-out forwards;
}

/* Loading Spinner */
.loader-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--grey-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .dashboard-view {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    padding: 12px;
    position: relative;
  }

  .sidebar-header {
    margin-bottom: 12px;
  }

  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    white-space: nowrap;
  }

  .dashboard-main {
    height: auto;
    overflow: visible;
  }

  .content-scroll {
    padding: 16px;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}