/* ─── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #1c2128;
  --border:    #30363d;
  --border2:   #21262d;
  --text:      #e6edf3;
  --text2:     #8b949e;
  --text3:     #6e7681;
  --accent:    #2ea043;
  --accent2:   #238636;
  --blue:      #1f6feb;
  --blue2:     #388bfd;
  --amber:     #d29922;
  --red:       #da3633;
  --red2:      #f85149;
  --purple:    #8957e5;
  --teal:      #2aa198;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,0.4);
  --font:      'IBM Plex Sans', system-ui, sans-serif;
  --mono:      'IBM Plex Mono', 'Courier New', monospace;
  --nav-h:     56px;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--blue2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ─── NAV ───────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.5rem;
}
.nav-brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; flex-shrink: 0; }
.nav-logo {
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.nav-title { font-weight: 600; color: var(--text); font-size: 1rem; }
.nav-links { display: flex; gap: 0.25rem; flex: 1; }
.nav-link {
  padding: 0.35rem 0.75rem; border-radius: var(--radius);
  color: var(--text2); font-size: 0.875rem; text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover, .nav-link.active { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.nav-username { font-size: 0.875rem; color: var(--text2); }

/* ─── MAIN ───────────────────────────────────────────────────────────────────── */
.main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 600; }
.page-header p { color: var(--text2); margin-top: 0.25rem; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  font-family: var(--font); font-size: 0.875rem; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--accent2); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); }
.btn-blue     { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-blue:hover { background: var(--blue2); }
.btn-ghost    { background: transparent; color: var(--text2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger   { background: transparent; color: var(--red2); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-lg { padding: 0.65rem 1.4rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ─── CARDS ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
}
.card-header { margin-bottom: 1.25rem; }
.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 600; }
.card-header p { font-size: 0.85rem; color: var(--text2); margin-top: 0.2rem; }

/* ─── GRID ───────────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ─── STAT CARDS ─────────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
}
.stat-label { font-size: 0.78rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem; }
.stat-value { font-size: 1.6rem; font-weight: 600; font-family: var(--mono); line-height: 1.2; }
.stat-sub   { font-size: 0.8rem; color: var(--text2); margin-top: 0.3rem; }
.stat-green { color: var(--accent); }
.stat-red   { color: var(--red2); }
.stat-amber { color: var(--amber); }
.stat-blue  { color: var(--blue2); }

/* ─── FORMS ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
label {
  display: block; font-size: 0.82rem; font-weight: 500;
  color: var(--text2); margin-bottom: 0.35rem;
}
.label-hint { font-weight: 400; color: var(--text3); font-size: 0.78rem; }
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 0.55rem 0.8rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font); font-size: 0.9rem;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue2);
  box-shadow: 0 0 0 3px rgba(56,139,253,0.15);
}
input::placeholder { color: var(--text3); }
select option { background: var(--bg3); }
textarea { resize: vertical; min-height: 80px; }
.input-prefix { position: relative; }
.input-prefix span {
  position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
  color: var(--text2); font-size: 0.9rem; pointer-events: none;
}
.input-prefix input { padding-left: 1.8rem; }
.form-hint { font-size: 0.78rem; color: var(--text3); margin-top: 0.3rem; }
.form-section { margin-bottom: 1.75rem; }
.form-section-title {
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text2);
  border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 1rem;
}
.required { color: var(--red2); }

/* ─── TABLES ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--bg3); padding: 0.7rem 1rem;
  text-align: left; font-size: 0.78rem; font-weight: 600;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border2);
  font-size: 0.875rem; vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }
.td-mono { font-family: var(--mono); font-size: 0.82rem; }
.td-right { text-align: right; }

/* ─── BADGES ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-green  { background: rgba(46,160,67,0.15); color: var(--accent); }
.badge-red    { background: rgba(218,54,51,0.15); color: var(--red2); }
.badge-amber  { background: rgba(210,153,34,0.15); color: var(--amber); }
.badge-blue   { background: rgba(31,111,235,0.15); color: var(--blue2); }
.badge-purple { background: rgba(137,87,229,0.15); color: var(--purple); }

/* ─── FLASH MESSAGES ─────────────────────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; border-radius: var(--radius);
  margin-bottom: 1.25rem; font-size: 0.875rem; border: 1px solid;
}
.flash-success { background: rgba(46,160,67,0.12); border-color: var(--accent); color: #3fb950; }
.flash-error   { background: rgba(218,54,51,0.12); border-color: var(--red); color: var(--red2); }
.flash-info    { background: rgba(31,111,235,0.12); border-color: var(--blue); color: var(--blue2); }
.flash-close   { background: none; border: none; cursor: pointer; color: inherit; font-size: 1.1rem; line-height: 1; }

/* ─── VERDICT BANNER ─────────────────────────────────────────────────────────── */
.verdict-banner {
  border-radius: var(--radius-lg); padding: 1.5rem 2rem;
  text-align: center; border: 2px solid;
}
.verdict-undervalued { background: rgba(46,160,67,0.1); border-color: var(--accent); }
.verdict-overvalued  { background: rgba(218,54,51,0.1); border-color: var(--red2); }
.verdict-fair        { background: rgba(210,153,34,0.1); border-color: var(--amber); }
.verdict-banner .v-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); }
.verdict-banner .v-value { font-size: 2.2rem; font-weight: 700; font-family: var(--mono); margin: 0.25rem 0; }
.verdict-banner .v-tag   { font-size: 1rem; font-weight: 600; }

/* ─── PROGRESS BAR ───────────────────────────────────────────────────────────── */
.progress { background: var(--bg3); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; transition: width 0.5s; }
.progress-green  { background: var(--accent); }
.progress-amber  { background: var(--amber); }
.progress-red    { background: var(--red2); }
.progress-blue   { background: var(--blue2); }

/* ─── SCORE RING ─────────────────────────────────────────────────────────────── */
.score-ring { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.score-circle {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 1.3rem; font-weight: 700;
  border: 4px solid;
}

/* ─── TABS ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: 0.6rem 1rem; background: none; border: none;
  color: var(--text2); font-family: var(--font); font-size: 0.875rem; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--blue2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── CHART CONTAINER ────────────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap-tall { position: relative; height: 360px; }

/* ─── AUTH PAGES ─────────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 1rem;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-logo {
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  margin-bottom: 2rem;
}
.auth-logo-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent2); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; color: #fff;
}
.auth-logo-text { font-size: 1.4rem; font-weight: 700; }
.auth-title { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.25rem; }
.auth-sub { font-size: 0.85rem; color: var(--text2); margin-bottom: 1.5rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: 0.85rem; color: var(--text2); }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3.5rem 1rem;
  color: var(--text2);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state h3 { font-size: 1rem; color: var(--text); margin-bottom: 0.4rem; }
.empty-state p  { font-size: 0.875rem; margin-bottom: 1.25rem; }

/* ─── BREAKDOWN TABLE ────────────────────────────────────────────────────────── */
.breakdown-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.65rem 0; border-bottom: 1px solid var(--border2);
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label { font-size: 0.875rem; color: var(--text2); }
.breakdown-value { font-family: var(--mono); font-size: 0.9rem; font-weight: 500; }

/* ─── FOOTER ─────────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border); margin-top: 4rem;
  padding: 1.25rem 1.5rem;
}
.footer-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: space-between;
  font-size: 0.8rem; color: var(--text3);
}

/* ─── UTILITIES ──────────────────────────────────────────────────────────────── */
.text-green  { color: var(--accent) !important; }
.text-red    { color: var(--red2) !important; }
.text-amber  { color: var(--amber) !important; }
.text-blue   { color: var(--blue2) !important; }
.text-muted  { color: var(--text2); }
.text-mono   { font-family: var(--mono); }
.text-sm     { font-size: 0.82rem; }
.text-xs     { font-size: 0.75rem; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.fw-600      { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.hidden { display: none; }
