:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

/* ===== AUTH ===== */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  padding: 20px;
}

.auth-wrap { width: 100%; max-width: 420px; }

.auth-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 25px 60px rgba(30, 27, 75, 0.3);
}

.auth-brand { text-align: center; margin-bottom: 28px; }

.auth-brand h1 { font-size: 1.6rem; font-weight: 800; margin-top: 14px; }
.auth-brand p { color: var(--text-muted); margin-top: 4px; font-size: 0.9rem; }

.brand-logo {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.brand-logo.large { margin: 0 auto; width: 64px; height: 64px; font-size: 1.7rem; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-hint {
  text-align: center; margin-top: 22px;
  font-size: 0.8rem; color: var(--text-muted);
}
.auth-hint code {
  background: var(--primary-light); color: var(--primary-dark);
  padding: 2px 8px; border-radius: 6px; font-weight: 600;
}

/* ===== APP SHELL ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-title { font-weight: 800; font-size: 1.05rem; }
.brand-sub { font-size: 0.75rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.nav-link i { width: 20px; text-align: center; font-size: 1rem; }
.nav-link:hover { background: var(--primary-light); color: var(--primary-dark); }
.nav-link.active { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,0.35); }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem;
}
.user-name { font-weight: 700; font-size: 0.9rem; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

.logout-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  color: var(--danger); font-weight: 600; font-size: 0.88rem;
  transition: background 0.15s;
}
.logout-btn:hover { background: #fef2f2; }

/* ===== MAIN ===== */
.main-content { flex: 1; padding: 28px 32px; max-width: 1200px; }

.page-head { margin-bottom: 24px; }
.page-title { font-size: 1.6rem; font-weight: 800; }
.page-sub { color: var(--text-muted); margin-top: 4px; }

/* ===== FLASH ===== */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-radius: 12px;
  margin-bottom: 20px; font-weight: 600; font-size: 0.9rem;
}
.flash-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.indigo { background: #eef2ff; color: #6366f1; }
.stat-icon.green { background: #ecfdf5; color: #10b981; }
.stat-icon.amber { background: #fffbeb; color: #f59e0b; }
.stat-icon.rose { background: #fff1f2; color: #f43f5e; }
.stat-icon.cyan { background: #ecfeff; color: #06b6d4; }
.stat-icon.white { background: rgba(255,255,255,0.25); color: #fff; }

.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 1.35rem; font-weight: 800; margin-top: 2px; }

.stat-card.highlight {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 8px 24px rgba(99,102,241,0.3);
}
.stat-card.highlight .stat-label { color: rgba(255,255,255,0.8); }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.card-head h2 { font-size: 1.1rem; font-weight: 700; }
.card-head h2 i { color: var(--primary); margin-right: 8px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.max-w-md { max-width: 480px; }

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

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; font-size: 0.88rem; }
th {
  color: var(--text-muted); font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}
td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: #f8fafc; }

.text-right { text-align: right; }
.td-strong { font-weight: 700; }
.td-sub { font-size: 0.78rem; color: var(--text-muted); }
.empty { text-align: center; color: var(--text-muted); padding: 28px; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  background: var(--primary-light); color: var(--primary-dark);
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }

.count-chip {
  background: var(--primary-light); color: var(--primary-dark);
  padding: 4px 12px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700;
}

/* ===== FORMS ===== */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; align-items: end;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--text); }

.field input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.input-icon { position: relative; }
.input-icon i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.9rem;
}
.input-icon input { padding-left: 40px; width: 100%; }

.muted { color: var(--text-muted); font-size: 0.82rem; }
.mb { margin-bottom: 16px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border: none; border-radius: 10px;
  font-size: 0.9rem; font-weight: 700;
  font-family: inherit; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; border-radius: 8px; }

/* ===== SUMMARY ===== */
.summary-list { display: flex; flex-direction: column; }
.summary-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.summary-row:last-child { border-bottom: none; }
.summary-label { color: var(--text-muted); font-weight: 600; }
.summary-label i { margin-right: 8px; color: var(--primary); width: 18px; }
.summary-value { font-weight: 600; }
.summary-value.strong { font-weight: 800; color: var(--primary-dark); font-size: 1.05rem; }

/* ===== FILTER ===== */
.filter-card { padding: 18px 20px; }

.filter-form {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
}
.filter-form .field { min-width: 140px; }
.filter-form .btn { height: 42px; }

.select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.filter-total {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--primary-light);
  border-radius: 10px;
  color: var(--primary-dark);
  font-size: 0.9rem;
}
.filter-total strong { font-size: 1.05rem; }

.mb { margin-bottom: 16px; }

/* ===== CALCULATOR PAGE ===== */
.calc-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .calc-layout { grid-template-columns: 1fr; }
}

.calc-panel { position: sticky; top: 24px; }

.calc-form { display: flex; flex-direction: column; gap: 16px; }

.calc-field { display: flex; flex-direction: column; gap: 6px; }
.calc-field label {
  font-size: 0.82rem; font-weight: 700; color: var(--text);
}
.calc-field label i { margin-right: 6px; color: var(--primary); width: 14px; }
.calc-inputs { display: flex; gap: 8px; }
.calc-inputs .select { flex: 1; }

.calc-submit { margin-top: 6px; padding: 14px; font-size: 1rem; }

.calc-investor-info {
  display: flex; align-items: center; gap: 12px;
  margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.calc-investor-avatar {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
}
.calc-investor-name { font-weight: 700; font-size: 0.95rem; }
.calc-investor-pct { font-size: 0.8rem; color: var(--text-muted); }
.calc-investor-pct strong { color: var(--primary-dark); }

.calc-result-panel { display: flex; flex-direction: column; gap: 24px; }

.calc-result-card {
  background: linear-gradient(160deg, #ffffff, #f8f7ff);
  border: 1px solid var(--border);
  padding: 28px;
}

.calc-result-period {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--primary-dark);
  font-size: 1rem; margin-bottom: 24px;
}
.calc-result-period i { font-size: 1.2rem; }
.calc-result-count {
  margin-left: auto;
  font-size: 0.78rem; font-weight: 600;
  background: var(--primary-light); color: var(--primary-dark);
  padding: 4px 12px; border-radius: 999px;
}

.calc-big-number { text-align: center; margin-bottom: 24px; }
.calc-big-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.calc-big-value { font-size: 2.4rem; font-weight: 800; color: var(--text); }

.calc-divider {
  display: flex; align-items: center; gap: 14px; margin-bottom: 24px;
}
.calc-divider-line { flex: 1; height: 1px; background: var(--border); }
.calc-divider-pct {
  font-size: 0.82rem; font-weight: 700; color: var(--text-muted);
  white-space: nowrap;
}

.calc-result-share {
  text-align: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(99,102,241,0.3);
  margin-bottom: 24px;
}
.calc-share-label { font-size: 0.85rem; color: rgba(255,255,255,0.85); font-weight: 600; }
.calc-share-value { font-size: 2.2rem; font-weight: 800; margin-top: 4px; }

.calc-breakdown {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.calc-breakdown-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
.calc-breakdown-row:last-child { border-bottom: none; }
.calc-breakdown-row span:first-child { color: var(--text-muted); }
.calc-breakdown-row span:last-child { font-weight: 700; }
.calc-breakdown-row.result {
  background: var(--primary-light);
  font-size: 0.95rem;
}
.calc-breakdown-row.result span:first-child { color: var(--primary-dark); font-weight: 700; }
.calc-breakdown-row.result span:last-child { color: var(--primary-dark); font-weight: 800; }

.calc-result-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.calc-result-empty i {
  font-size: 2.5rem; color: #d1d5db; margin-bottom: 16px;
}
.calc-result-empty p { font-size: 0.95rem; line-height: 1.6; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 18px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

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

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 1.05rem; font-weight: 700; }
.modal-head h2 i { color: var(--primary); margin-right: 8px; }

.modal-close {
  background: #f1f5f9; border: none; border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 1rem; transition: all 0.15s;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }

.modal form { padding: 24px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap;
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .main-content { padding: 20px; }
}
