/**
 * FINANCIAL DASHBOARD
 * Clean, functional, information-dense
 */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --black: #000000;
  --white: #FFFFFF;
  --gray-50: #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #E5E5E5;
  --gray-300: #D4D4D4;
  --gray-400: #A3A3A3;
  --gray-500: #737373;
  --gray-600: #525252;
  --gray-700: #404040;
  --gray-800: #262626;
  --gray-900: #171717;

  --blue: #2563EB;
  --red: #DC2626;
  --green: #16A34A;

  --font-sans: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

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

html {
  font-size: 14px;
}

body {
  background: var(--white);
  color: var(--gray-900);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
}

/* Typography */
h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--black);
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 0.75rem;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-700);
}

h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

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

@media (max-width: 1024px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

/* Stats */
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  font-weight: 400;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-600);
}

.stat-value.large {
  font-size: 2rem;
  font-weight: 600;
  color: var(--gray-900);
}

.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-300);
}

th {
  text-align: left;
  padding: 0.75rem 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--gray-700);
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

th.sortable:hover {
  background: var(--gray-100);
  color: var(--blue);
}

th.sortable .sort-indicator {
  display: inline-block;
  margin-left: 0.25rem;
  opacity: 0.3;
  font-size: 0.625rem;
}

th.sortable .sort-indicator::after {
  content: '▼';
}

th.sortable.sort-asc .sort-indicator {
  opacity: 1;
}

th.sortable.sort-asc .sort-indicator::after {
  content: '▲';
}

th.sortable.sort-desc .sort-indicator {
  opacity: 1;
}

th.sortable.sort-desc .sort-indicator::after {
  content: '▼';
}

td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--gray-100);
}

tbody tr:hover {
  background: var(--gray-50);
}

td.date, td.amount {
  font-family: var(--font-mono);
  font-weight: 500;
}

td.amount {
  text-align: right;
}

td.amount.negative { color: var(--red); }
td.amount.positive { color: var(--green); }

/* Forms */
input, select {
  background: var(--white);
  border: 1px solid var(--gray-300);
  color: var(--gray-900);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
  border-radius: 4px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select {
  cursor: pointer;
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--gray-700);
}

/* Buttons */
button {
  background: var(--white);
  border: 1px solid var(--gray-300);
  color: var(--gray-900);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

button:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

button.primary {
  background: var(--gray-900);
  color: var(--white);
  border-color: var(--gray-900);
}

button.primary:hover {
  background: var(--gray-800);
  border-color: var(--gray-800);
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none; }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-top: 1px solid var(--gray-200);
  margin-top: 1rem;
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.pagination-controls {
  display: flex;
  gap: 0.5rem;
}

.pagination button {
  padding: 0.375rem 0.75rem;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Charts */
.chart-container {
  height: 300px;
  margin: 1rem 0;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* Tab system */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 1rem;
  margin-bottom: -1px;
}

.tab-btn:hover {
  background: var(--gray-50);
}

.tab-btn.primary {
  border-bottom-color: var(--gray-900);
  background: transparent;
  color: var(--gray-900);
}

.tab-content {
  display: none;
}

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

/* Editable cells */
.editable {
  cursor: pointer;
  position: relative;
}

.editable:hover {
  background: var(--gray-100);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--white);
  border: 1px solid var(--gray-300);
  padding: 1rem;
  border-radius: 4px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
  z-index: 1000;
}

.toast.success {
  border-color: var(--green);
  background: #F0FDF4;
}

.toast.error {
  border-color: var(--red);
  background: #FEF2F2;
}
