/* FinLens Main Stylesheet */
:root {
  --bg: #0b0f1a;
  --surface: #111827;
  --surface2: #1a2235;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #f0f4ff;
  --muted: #8896b3;
  --accent: #4fffb0;
  --accent2: #3de0ff;
  --accent3: #ff6b6b;
  --amber: #ffc147;
  --purple: #a78bfa;
  --fd: 'DM Serif Display', serif;
  --fb: 'Outfit', sans-serif;
  --fm: 'DM Mono', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--fb);
  font-size: 15px;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: linear-gradient(rgba(79,255,176,0.025) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(79,255,176,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout */
.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-mark svg {
  width: 18px;
  height: 18px;
  color: #071b0f;
}

.logo-name {
  font-family: var(--fd);
  font-size: 18px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  font-family: var(--fm);
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 10px 18px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  border-left: 2px solid transparent;
  cursor: pointer;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(79,255,176,0.06);
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(79,255,176,0.2), rgba(61,224,255,0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--fd);
  font-size: 13px;
  color: var(--accent);
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--fm);
}

.btn-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 5px;
  transition: color .15s;
}

.btn-logout:hover {
  color: var(--accent3);
}

/* Main */
.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(11,15,26,.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--fd);
  font-size: 20px;
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-family: var(--fm);
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: all 0.2s ease;
  border-radius: 12px 0 0 12px;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.stat-card:hover::before {
  background: var(--accent);
  box-shadow: 0 0 15px rgba(79,255,176,0.3);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  font-family: var(--fm);
}

.stat-value.green {
  color: var(--accent);
}

.stat-value.red {
  color: var(--accent3);
}

.stat-value.amber {
  color: var(--amber);
}

.stat-value.blue {
  color: var(--accent2);
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-family: var(--fm);
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-family: var(--fm);
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 500;
}

.badge-green {
  background: rgba(79,255,176,0.1);
  color: var(--accent);
  border: 1px solid rgba(79,255,176,0.2);
}

.badge-red {
  background: rgba(255,107,107,0.1);
  color: var(--accent3);
  border: 1px solid rgba(255,107,107,0.2);
}

.badge-amber {
  background: rgba(255,193,71,0.1);
  color: var(--amber);
  border: 1px solid rgba(255,193,71,0.2);
}

.badge-blue {
  background: rgba(61,224,255,0.1);
  color: var(--accent2);
  border: 1px solid rgba(61,224,255,0.2);
}

.badge-muted {
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  border: 1px solid var(--border2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 9px;
  font-family: var(--fb);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
}

.btn-primary {
  background: var(--accent);
  color: #071b0f;
}

.btn-primary:hover {
  background: #6fffbe;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: rgba(255,107,107,0.1);
  color: var(--accent3);
  border: 1px solid rgba(255,107,107,0.2);
}

.btn-danger:hover {
  background: rgba(255,107,107,0.2);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--fb);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

.form-control:focus {
  border-color: var(--accent);
}

.form-control::placeholder {
  color: var(--muted);
}

select.form-control option {
  background: var(--surface);
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-family: var(--fd);
  font-size: 20px;
  margin-bottom: 20px;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.alert-success {
  background: rgba(79,255,176,0.08);
  border: 1px solid rgba(79,255,176,0.2);
  color: var(--accent);
}

.alert-error {
  background: rgba(255,107,107,0.08);
  border: 1px solid rgba(255,107,107,0.2);
  color: var(--accent3);
}

.alert-warning {
  background: rgba(255,193,71,0.08);
  border: 1px solid rgba(255,193,71,0.2);
  color: var(--amber);
}

/* Misc */
.section-label {
  font-size: 11px;
  font-family: var(--fm);
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state svg {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  opacity: .4;
}

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

.fade-up {
  animation: fadeUp .35s ease forwards;
  opacity: 0;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
}

.mobile-menu-toggle:hover {
  background: var(--surface2);
}

/* Score Progress Bars */
.score-bar {
  width: 60px;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  margin-left: 8px;
}

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.score-bar-fill.green {
  background: var(--accent);
}

.score-bar-fill.amber {
  background: var(--amber);
}

.score-bar-fill.red {
  background: var(--accent3);
}

/* Chart Container */
.chart-container {
  position: relative;
  height: 300px;
  margin: 20px 0;
}

.chart-small {
  height: 200px;
}

/* Circular Score Indicator */
.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent) 0deg,
    var(--accent) calc(var(--score) * 3.6deg),
    var(--surface2) calc(var(--score) * 3.6deg)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 auto;
}

.score-circle::before {
  content: '';
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--surface);
}

.score-circle span {
  position: relative;
  font-family: var(--fm);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

/* Analysis Cards Grid */
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.analysis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.analysis-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.analysis-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.analysis-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.analysis-card-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.analysis-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

/* Summary Stats */
.summary-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.summary-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.summary-stat-label {
  color: var(--muted);
  font-family: var(--fm);
}

.summary-stat-value {
  color: var(--text);
  font-weight: 600;
  font-family: var(--fm);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  
  .analysis-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: block;
  }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .main {
    margin-left: 0;
  }
  
  .topbar {
    padding: 12px 16px;
  }
  
  .page-content {
    padding: 16px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .stat-card {
    padding: 12px;
  }
  
  .stat-value {
    font-size: 20px;
  }
  
  .analysis-grid {
    grid-template-columns: 1fr;
  }
  
  .summary-stats {
    gap: 8px;
  }
  
  .summary-stat {
    padding: 6px 12px;
    font-size: 11px;
  }
  
  .chart-container {
    height: 250px;
  }
  
  .score-circle {
    width: 100px;
    height: 100px;
  }
  
  .score-circle::before {
    width: 75px;
    height: 75px;
  }
  
  .score-circle span {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .card {
    padding: 16px;
  }
  
  .table-wrap {
    border-radius: 8px;
    overflow: hidden;
  }
  
  thead th,
  tbody td {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .topbar-title {
    font-size: 16px;
  }
  
  .chart-container {
    height: 200px;
  }
}

/* Touch-friendly targets */
@media (max-width: 768px) {
  .btn,
  .nav-item,
  .stat-card,
  .analysis-card {
    min-height: 44px;
  }
  
  .nav-item {
    padding: 12px 18px;
  }
}
