:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --border: #334155;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* AUTHENTICATION VIEW */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  padding: 2.25rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.auth-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.auth-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

input, select {
  background-color: #0f172a;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.7rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

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

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--primary-hover);
}

.auth-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.25rem;
  text-align: center;
}

.otp-instruction {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.4;
  text-align: center;
}

.otp-dev-notice {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--primary);
  color: #bfdbfe;
  padding: 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 1rem;
}

.text-primary {
  color: var(--primary);
}

/* NAVBAR: home ,broker, ,bot,terminal, */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.5rem;
}

.nav-links li a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.95rem;
  text-transform: lowercase;
  font-weight: 500;
  transition: color 0.2s, background-color 0.2s;
}

.nav-links li.active a, .nav-links li a:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

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

/* MAIN CONTAINER & BROKER TABLE */
.main-container {
  max-width: 1200px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
}

.table-card-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.table-card-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.btn-add-broker {
  padding: 0.55rem 1.25rem;
  font-size: 0.875rem;
}

.table-wrapper {
  overflow-x: auto;
}

.broker-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.broker-table th {
  background-color: #162032;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: lowercase;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.broker-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.broker-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: lowercase;
}

.status-active {
  background: var(--success-bg);
  color: var(--success);
}

.status-deactive {
  background: var(--danger-bg);
  color: var(--danger);
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-action {
  padding: 0.3rem 0.65rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.btn-action.logged-in {
  color: var(--success);
  border-color: var(--success);
}

.portfolio-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.portfolio-link:hover {
  text-decoration: underline;
}

/* MODAL */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

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

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.65rem 1.15rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.log-list {
  max-height: 250px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.log-entry {
  background: #0f172a;
  padding: 0.5rem;
  border-radius: 4px;
  border-left: 3px solid var(--primary);
}
