/* ============================================================
   THE MF PEAK — KPI TRACKER DESIGN SYSTEM
   ============================================================ */

:root {
  --navy:   #07101F;
  --navy2:  #0D1B2E;
  --navy3:  #142338;
  --gold:   #C9A84C;
  --gold2:  #E8C96A;
  --gold3:  #F5E6C5;
  --white:  #EDF2FA;
  --muted:  #5A7094;
  --muted2: #8AA0BC;
  --red:    #E63946;
  --green:  #27AE60;
  --orange: #E67E22;
  --blue:   #2980B9;
  --nav-h:  60px;
  --targets-h: 88px;
}

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--navy);
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(201,168,76,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,168,76,0.04) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

#app { position: relative; z-index: 1; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── NAVBAR ─────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--navy2);
  border-bottom: 1px solid rgba(201,168,76,0.2);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
}

.nav-brand a {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.nav-logo {
  font-family: 'Bebas Neue', cursive;
  font-size: 1.2rem;
  color: var(--gold);
  letter-spacing: 0.06em;
}
.nav-module {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--muted2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted2);
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--white); background: rgba(255,255,255,0.06); }
.nav-link.active { color: var(--gold); background: rgba(201,168,76,0.1); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.nav-name {
  font-size: 0.8rem;
  color: var(--muted2);
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.btn-primary {
  background: var(--gold);
  color: var(--navy);
}
.btn-primary:hover { background: var(--gold2); }
.btn-primary:disabled { background: var(--muted); color: var(--navy2); cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--muted2);
  border: 1px solid rgba(255,255,255,0.12);
}
.btn-ghost:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }

.btn-logout {
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  border: 1px solid rgba(90,112,148,0.4);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  transition: all 0.15s;
}
.btn-logout:hover { color: var(--red); border-color: var(--red); }

/* ── ANNUAL TARGETS HEADER ──────────────────────────────────── */
.targets-header {
  position: sticky;
  top: var(--nav-h);
  z-index: 90;
  background: var(--navy2);
  border-bottom: 1px solid rgba(201,168,76,0.15);
  padding: 0.65rem 1.5rem;
}

.targets-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: var(--gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.targets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.target-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(201,168,76,0.12);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.target-values {
  font-family: 'Bebas Neue', cursive;
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--white);
}
.target-current { color: var(--gold2); }
.target-sep, .target-total { color: var(--muted); font-size: 0.9rem; }

.target-name {
  font-size: 0.68rem;
  color: var(--muted2);
  margin: 0.2rem 0 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-bar {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.target-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold2));
  border-radius: 2px;
  transition: width 0.6s ease;
  min-width: 2px;
}

/* ── PAGE LAYOUT ─────────────────────────────────────────────── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 2rem;
  color: var(--white);
  letter-spacing: 0.04em;
  line-height: 1;
}

.page-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted2);
  letter-spacing: 0.06em;
  margin-top: 0.3rem;
}

/* Gold divider */
.gold-divider {
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), transparent);
  margin: 0.5rem 0 1rem;
  border-radius: 2px;
}

/* ── DATE RANGE TOGGLE ──────────────────────────────────────── */
.range-toggle {
  display: flex;
  gap: 0.25rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 3px;
}

.range-btn {
  padding: 0.3rem 0.75rem;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--muted2);
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.15s;
}
.range-btn:hover { color: var(--white); }
.range-btn.active {
  background: rgba(201,168,76,0.18);
  color: var(--gold);
}

/* ── KPI GRID ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

/* ── KPI TILE ────────────────────────────────────────────────── */
.kpi-tile {
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
}
.kpi-tile:hover {
  border-color: rgba(201,168,76,0.25);
  transform: translateY(-1px);
}

.tile-status-bar {
  height: 3px;
  width: 100%;
}
.kpi-tile.on-target .tile-status-bar { background: var(--green); }
.kpi-tile.behind .tile-status-bar    { background: var(--red); }
.kpi-tile.no-data .tile-status-bar   { background: rgba(255,255,255,0.1); }

.tile-body {
  padding: 0.9rem 1rem 0.75rem;
}

.tile-value {
  font-family: 'Bebas Neue', cursive;
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--white);
}
.kpi-tile.on-target .tile-value { color: var(--white); }
.kpi-tile.behind .tile-value    { color: var(--red); }
.kpi-tile.no-data .tile-value   { color: var(--muted); }

.tile-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--muted2);
  letter-spacing: 0.08em;
  margin: 0.3rem 0 0.2rem;
  line-height: 1.35;
}

.tile-target {
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.6rem;
}
.tile-target.on_target { color: var(--green); }
.tile-target.behind    { color: var(--red); }
.tile-target.no_data   { color: var(--muted); }

.tile-sparkline {
  opacity: 0.8;
}
.tile-sparkline svg { display: block; }

/* ── SECTION HEADERS ─────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
}
.section-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 1.1rem;
  color: var(--gold);
  letter-spacing: 0.06em;
}
.section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(201,168,76,0.3), transparent);
}

/* ── TREND CHART ─────────────────────────────────────────────── */
.trend-chart-wrap {
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.trend-chart-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--muted2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* ── SUBMIT FORM ─────────────────────────────────────────────── */
.submit-wrap {
  max-width: 640px;
  margin: 0 auto;
}

.submit-card {
  background: var(--navy2);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 12px;
  padding: 2rem;
}

.submit-week-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.kpi-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.kpi-input-row:last-of-type { border-bottom: none; }

.kpi-input-label {
  flex: 1;
  min-width: 0;
}
.kpi-input-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--white);
  line-height: 1.2;
}
.kpi-input-target {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--muted2);
  margin-top: 0.15rem;
}

.kpi-input-field {
  width: 110px;
  flex-shrink: 0;
}
.kpi-input-field input {
  width: 100%;
  padding: 0.45rem 0.65rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: var(--white);
  font-size: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  outline: none;
  transition: border-color 0.15s;
}
.kpi-input-field input:focus {
  border-color: rgba(201,168,76,0.4);
}
.kpi-input-field input.ok    { border-color: var(--green); }
.kpi-input-field input.warn  { border-color: var(--red); }

.kpi-input-status {
  width: 20px;
  flex-shrink: 0;
  text-align: center;
  font-size: 1rem;
}

.note-section {
  margin-top: 1.25rem;
}
.note-label {
  font-size: 0.8rem;
  color: var(--muted2);
  margin-bottom: 0.4rem;
}
.note-section textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--white);
  font-size: 0.85rem;
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: border-color 0.15s;
}
.note-section textarea:focus { border-color: rgba(201,168,76,0.3); }

.submit-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

.submit-banner {
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}
.submit-banner.editing {
  background: rgba(41,128,185,0.12);
  border: 1px solid rgba(41,128,185,0.3);
  color: var(--blue);
}
.submit-banner.readonly {
  background: rgba(230,57,70,0.1);
  border: 1px solid rgba(230,57,70,0.25);
  color: var(--red);
}

/* Confirmation screen */
.submit-confirm {
  text-align: center;
  padding: 2.5rem 1rem;
}
.submit-confirm-icon { font-size: 3rem; margin-bottom: 1rem; }
.submit-confirm h2 {
  font-family: 'Bebas Neue', cursive;
  font-size: 1.8rem;
  color: var(--green);
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.submit-confirm p { color: var(--muted2); font-size: 0.9rem; }

/* ── HISTORY TABLE ───────────────────────────────────────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
}
.history-table th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.history-table td {
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.history-table tr:hover td { background: rgba(255,255,255,0.02); }

.val-cell {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.4rem;
}
.status-dot.on-target { background: var(--green); }
.status-dot.behind    { background: var(--red); }

/* ── LOGIN PAGE ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--navy2);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 14px;
  padding: 2.5rem;
  text-align: center;
}
.login-brand {
  margin-bottom: 2rem;
}
.login-brand-name {
  font-family: 'Bebas Neue', cursive;
  font-size: 1.8rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  line-height: 1;
}
.login-brand-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--muted2);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}
.login-tagline {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--muted2);
  margin-bottom: 1.75rem;
  line-height: 1.4;
}
.login-input-wrap {
  margin-bottom: 1rem;
}
.login-input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--white);
  font-size: 0.9rem;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}
.login-input:focus { border-color: rgba(201,168,76,0.5); }
.login-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.15s;
}
.login-btn:hover { background: var(--gold2); }
.login-btn:disabled { background: var(--muted); cursor: not-allowed; }
.login-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 1rem;
}
.login-sent {
  padding: 1rem;
  background: rgba(39,174,96,0.1);
  border: 1px solid rgba(39,174,96,0.25);
  border-radius: 8px;
  color: var(--green);
  font-size: 0.85rem;
  margin-top: 1rem;
  display: none;
}

/* ── LOADING & EMPTY STATES ─────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  gap: 0.75rem;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(201,168,76,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }

.error-msg {
  background: rgba(230,57,70,0.1);
  border: 1px solid rgba(230,57,70,0.25);
  border-radius: 8px;
  color: var(--red);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  margin: 1rem 0;
}

/* ── DIRECTORY TABLE ─────────────────────────────────────────── */
.dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.dir-card {
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.dir-card:hover { border-color: rgba(201,168,76,0.3); }
.dir-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(201,168,76,0.12);
  border: 1px solid rgba(201,168,76,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', cursive;
  font-size: 1rem;
  color: var(--gold);
  flex-shrink: 0;
}
.dir-info { min-width: 0; }
.dir-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dir-role {
  font-size: 0.72rem;
  color: var(--muted2);
  margin-top: 0.15rem;
}
.dir-dept {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--gold);
  margin-top: 0.1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .targets-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 640px) {
  .navbar { padding: 0 1rem; gap: 0.75rem; }
  .nav-links { display: none; }
  .targets-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .targets-header { padding: 0.5rem 1rem; }
  .main-content { padding: 1.25rem 1rem 2.5rem; }
  .page-header { flex-direction: column; gap: 0.75rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .tile-value { font-size: 1.9rem; }
  .submit-card { padding: 1.25rem; }
  .kpi-input-field { width: 90px; }
  .history-table th:nth-child(4),
  .history-table td:nth-child(4) { display: none; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .targets-grid { grid-template-columns: 1fr 1fr; }
}
