:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a8e;
  --accent: #3b82f6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background: var(--primary);
  color: white;
  padding: 12px 24px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-brand {
  color: white;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-links a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-links a:hover {
  color: white;
}

.nav-balance {
  font-weight: 700;
  font-size: 0.95rem;
  color: white;
  background: rgba(255,255,255,0.15);
  padding: 3px 10px;
  border-radius: 4px;
}

.nav-user {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
}

.nav-logout {
  display: inline;
}

.nav-logout .btn-outline {
  color: white;
  border-color: rgba(255,255,255,0.4);
}

.nav-logout .btn-outline:hover {
  border-color: white;
}

/* Container */
.container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}

.card h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  color: var(--primary);
}

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

.card-header h3 {
  margin-bottom: 0;
}

.interest-earned {
  color: var(--success);
  font-weight: 600;
}

.monthly-profit-line {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 10px 0 0;
}

.monthly-profit-line strong {
  color: var(--success);
  font-weight: 600;
}

/* Deposit & Withdrawal Row */
.deposit-withdraw-row.compact {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.dw-form {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
}

.dw-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.dw-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dw-form .btn {
  white-space: nowrap;
}

@media (max-width: 600px) {
  .deposit-withdraw-row.compact {
    flex-direction: column;
    gap: 6px;
  }

  .dw-form input {
    font-size: 0.8rem;
    padding: 6px 8px;
  }

  .dw-form .btn {
    font-size: 0.75rem;
    padding: 5px 10px;
  }
}

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

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

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

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

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

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

.action-buttons {
  display: flex;
  gap: 6px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-approved {
  background: #d1fae5;
  color: #065f46;
}

.badge-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.badge-deposit {
  background: #dbeafe;
  color: #1e40af;
}

.badge-withdrawal {
  background: #fce7f3;
  color: #9d174d;
}

.badge-admin {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-user {
  background: #e0f2fe;
  color: #0369a1;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Login Page */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  color: var(--primary);
  margin-bottom: 4px;
}

.login-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-card .form-group {
  text-align: left;
}

.auth-link {
  margin-top: 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.auth-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* Chart Section */
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 350px;
}

.chart-overlay {
  position: absolute;
  top: 50%;
  right: 15%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 58, 95, 0.75);
  backdrop-filter: blur(4px);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  pointer-events: none;
}

.chart-overlay span {
  color: rgba(255,255,255,0.6);
  font-weight: 500;
}

.chart-overlay strong {
  color: #4ade80;
  font-weight: 700;
  font-size: 0.95rem;
}

.chart-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 16px;
  margin-top: -8px;
}

/* What-If Tool */
.whatif-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 8px;
}

.whatif-label strong {
  color: var(--text);
  font-size: 1rem;
}

.whatif-slider-group {
  margin-bottom: 16px;
}

.whatif-slider-group input[type="range"] {
  width: 100%;
  cursor: pointer;
  accent-color: var(--accent);
}

.whatif-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.whatif-result-item {
  background: #eff6ff;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid #bfdbfe;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.whatif-result-item span {
  font-size: 0.85rem;
  color: #475569;
}

.whatif-result-item strong {
  font-size: 1.2rem;
  color: #1e40af;
}

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

.text-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.error-page {
  text-align: center;
  padding: 60px 0;
}

.error-page h2 {
  margin-bottom: 12px;
}

.error-page p {
  margin-bottom: 24px;
  color: var(--text-muted);
}

/* User Actions */
.user-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.change-password-form {
  display: flex;
  gap: 4px;
  align-items: center;
}

.change-password-form input {
  width: 130px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
}

.change-password-form input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Rate Config */
.rate-config-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rate-display {
  font-size: 1rem;
}

.rate-display strong {
  font-size: 1.3rem;
  color: var(--accent);
}

.rate-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rate-input-group label {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.rate-input-group input {
  width: 120px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.rate-input-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.rate-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

/* ========== Risk Control ========== */

.risk-control {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.risk-form {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.risk-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.risk-radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.risk-radio input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}

/* ========== Mobile Responsive ========== */

@media (max-width: 600px) {
  /* Navbar stacks on small screens */
  .navbar {
    padding: 10px 16px;
  }

  .nav-brand {
    font-size: 1.05rem;
  }

  .nav-links {
    gap: 8px;
    font-size: 0.82rem;
  }

  .nav-links a {
    font-size: 0.82rem;
  }

  .nav-user {
    display: none;
  }

  /* Container tighter padding */
  .container {
    padding: 16px 12px;
  }

  /* Cards less padding */
  .card {
    padding: 16px;
    margin-bottom: 14px;
  }

  /* Balance */
  .balance-amount {
    font-size: 1.8rem;
  }

  /* Buttons full width in forms */
  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .btn-block {
    padding: 12px;
  }

  /* Tables: smaller text, tighter cells */
  thead th {
    padding: 8px 6px;
    font-size: 0.72rem;
  }

  tbody td {
    padding: 10px 6px;
    font-size: 0.82rem;
  }

  .action-buttons {
    flex-direction: column;
    gap: 4px;
  }

  /* Card header stacks */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* What-If controls stack vertically */
  .whatif-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .whatif-slider-group {
    min-width: 0;
  }

  .whatif-input-group {
    width: 100%;
  }

  .whatif-input-group input {
    width: 100%;
    flex: 1;
  }

  /* Result boxes stay side by side on mobile */
  .whatif-results {
    grid-template-columns: 1fr 1fr;
  }

  /* Chart – full width, taller on mobile */
  .chart-section {
    padding: 10px 4px;
    margin-left: -12px;
    margin-right: -12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .chart-section h3 {
    font-size: 0.95rem;
    margin-bottom: 4px;
    padding: 0 8px;
  }

  .chart-subtitle {
    font-size: 0.75rem;
    margin-bottom: 6px;
    margin-top: 0;
    padding: 0 8px;
  }

  .chart-wrapper {
    height: 55vw;
    min-height: 220px;
  }

  .chart-section canvas {
    max-height: none;
  }

  /* Compact risk control on mobile */
  .risk-control {
    margin-top: 8px;
    padding-top: 8px;
  }

  .risk-label {
    font-size: 0.8rem;
  }

  .risk-radio {
    font-size: 0.8rem;
    gap: 3px;
  }

  /* Compact what-if on mobile */
  .whatif-section h3 {
    font-size: 0.95rem;
    margin-bottom: 6px;
  }

  .whatif-section > p {
    font-size: 0.8rem;
    margin-bottom: 8px;
  }

  /* Login */
  .login-wrapper {
    min-height: 50vh;
    padding: 0 8px;
  }

  .login-card {
    max-width: 100%;
  }

  .login-card h1 {
    font-size: 1.4rem;
  }

  /* Form actions stack */
  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  /* Page headings */
  h2 {
    font-size: 1.3rem;
    margin-bottom: 14px;
  }
}
