:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: rgba(30, 30, 50, 0.7);
  --accent-primary: #6366f1;
  --accent-secondary: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --glass-blur: blur(20px);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary), #16213e);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, var(--accent-glow) 0%, transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 40%);
  pointer-events: none;
  z-index: -1;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-title h1 {
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-title .icon {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
}

.year-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
}

.year-selector label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.year-selector select {
  appearance: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.year-selector select:hover,
.year-selector select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

/* Breadcrumb Navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
}

.breadcrumb-item {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-item:hover:not(.active) {
  color: var(--accent-secondary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 600;
}

.breadcrumb-separator {
  color: var(--text-muted);
}

/* Desktop layout */
.main-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 100px);
  overflow: hidden;
}

.panel {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-content {
  flex: 1;
  overflow: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.image-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.image-tab {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.image-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.image-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.image-wrapper {
  flex: 1;
  overflow: auto;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0.5rem;
  min-height: 0;
}

.financial-image {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
  cursor: zoom-in;
  transition: transform 0.3s ease;
  background: white;
}

.search-input {
  width: 100%;
  padding: 0.625rem 0.75rem 0.625rem 2.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.625rem center;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.table-wrapper {
  flex: 1;
  overflow: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  min-height: 0;
}

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

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  padding: 0.625rem 0.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th:hover {
  color: var(--accent-secondary);
  background: rgba(99, 102, 241, 0.1);
}

.data-table th.sorted-asc::after {
  content: ' ↑';
  color: var(--accent-primary);
}

.data-table th.sorted-desc::after {
  content: ' ↓';
  color: var(--accent-primary);
}

.data-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.08);
}

.data-table .amount {
  font-family: monospace;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.data-table .department {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.data-table .code {
  font-family: monospace;
  color: var(--accent-secondary);
  font-weight: 500;
}

.data-table tr.category-executive {
  border-left: 3px solid #0ea5e9;
}

.data-table tr.category-finance {
  border-left: 3px solid #14b8a6;
}

.data-table tr.category-operations {
  border-left: 3px solid #f59e0b;
}

.data-table tr.category-community {
  border-left: 3px solid #f43f5e;
}

.data-table tr.category-general {
  border-left: 3px solid #3b82f6;
}

.data-table tr.category-safety {
  border-left: 3px solid #ef4444;
}

.data-table tr.category-works {
  border-left: 3px solid #eab308;
}

.data-table tr.category-health {
  border-left: 3px solid #22c55e;
}

.data-table tr.category-culture {
  border-left: 3px solid #a855f7;
}

.data-table tr.category-conservation {
  border-left: 3px solid #10b981;
}

.data-table tr.category-debt {
  border-left: 3px solid #ec4899;
}

.data-table tr.category-capital {
  border-left: 3px solid #6366f1;
}

.data-table tr.category-total {
  background: rgba(99, 102, 241, 0.15);
  font-weight: 700;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  cursor: zoom-out;
}

.modal-overlay.active {
  display: flex;
}

.modal-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.5rem;
}

.stats-bar {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  color: var(--accent-secondary);
  font-weight: 600;
  font-family: monospace;
}

.stat-warning {
  color: #f87171;
  font-weight: 600;
  font-size: 0.75rem;
}

/* Tablet - side by side but tighter */
@media (max-width: 1024px) {
  .main-container {
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .data-table {
    font-size: 0.75rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.4rem;
  }
}

/* Tablet portrait and large phones - stack vertically */
@media (max-width: 768px) {

  html,
  body {
    overflow: auto;
    height: auto;
  }

  .header {
    padding: 0.75rem;
  }

  .header-title h1 {
    font-size: 1rem;
  }

  .main-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: calc(100vh - 60px);
    overflow: visible;
  }

  .panel {
    min-height: 45vh;
    max-height: 60vh;
  }

  .data-table .department {
    display: none;
  }

  .data-table th:nth-child(3),
  .data-table td:nth-child(3) {
    display: none;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .header-title {
    justify-content: center;
  }

  .year-selector {
    justify-content: center;
  }

  .main-container {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .panel {
    min-height: 40vh;
  }

  .panel-header {
    padding: 0.5rem 0.75rem;
  }

  .panel-title {
    font-size: 0.7rem;
  }

  .panel-content {
    padding: 0.5rem;
  }

  .image-tabs {
    gap: 0.25rem;
  }

  .image-tab {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
  }

  .search-input {
    padding: 0.5rem 0.5rem 0.5rem 2rem;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
  }

  .data-table {
    font-size: 0.7rem;
  }

  .data-table th {
    padding: 0.4rem 0.3rem;
    font-size: 0.65rem;
  }

  .data-table td {
    padding: 0.35rem 0.3rem;
  }

  .data-table .code {
    display: none;
  }

  .data-table th:nth-child(2),
  .data-table td:nth-child(2) {
    display: none;
  }

  .stats-bar {
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
  }
}