/* ==========================================
   ArbiMax Components v2.0 - Reference-based Design System
   Unified glassmorphism patterns and interactive states
   ========================================== */

/* ==========================================
   LAYOUT FOUNDATION
   ========================================== */
.am-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: var(--am-space-lg);
  padding-right: var(--am-space-lg);
}

@media (max-width: 768px) {
  .am-container {
    padding-left: var(--am-space-md);
    padding-right: var(--am-space-md);
  }
}

.am-stack {
  display: flex;
  flex-direction: column;
}

.am-stack-sm { gap: var(--am-space-sm); }
.am-stack-md { gap: var(--am-space-md); }
.am-stack-lg { gap: var(--am-space-lg); }
.am-stack-xl { gap: var(--am-space-xl); }
.am-stack-2xl { gap: var(--am-space-2xl); }

.am-grid {
  display: grid;
  gap: var(--am-space-lg);
}

/* ==========================================
   GLASSMORPHISM SURFACES (Core Pattern)
   ========================================== */
.am-glass {
  background: var(--am-surface-1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--am-border-subtle);
  border-radius: var(--am-radius-xl);
}

.am-glass-strong {
  background: var(--am-surface-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-xl);
}

/* ==========================================
   CARD COMPONENTS (Reference-based padding)
   ========================================== */
.am-card {
  background: var(--am-surface-1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--am-border-subtle);
  border-radius: var(--am-radius-xl);
  padding: var(--am-space-lg);
  transition: all var(--am-duration-normal) var(--am-ease);
}

.am-card:hover {
  border-color: var(--am-border);
  transform: translateY(-1px);
}

.am-card-lg {
  padding: var(--am-space-xl);
  border-radius: var(--am-radius-2xl);
}

.am-card-compact {
  padding: var(--am-space-md);
}

/* Card variants */
.am-card-accent {
  border-color: var(--am-border-accent);
  background: var(--am-accent-bg);
}

.am-card-profit {
  border-color: var(--am-profit-border);
  background: var(--am-profit-bg);
}

.am-card-loss {
  border-color: var(--am-loss-border);
  background: var(--am-loss-bg);
}

/* ==========================================
   MODAL COMPONENTS
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity var(--am-duration-normal) var(--am-ease);
}

.modal-overlay.show {
  opacity: 1;
}

.modal-content {
  background: var(--am-surface-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-xl);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform var(--am-duration-normal) var(--am-ease);
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: var(--am-space-lg);
  border-bottom: 1px solid var(--am-border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: var(--am-space-lg);
}

.modal-footer {
  padding: var(--am-space-lg);
  border-top: 1px solid var(--am-border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: var(--am-space-md);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--am-text-muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--am-radius-md);
  transition: all var(--am-duration-fast) var(--am-ease);
}

.modal-close:hover {
  background: var(--am-hover-bg);
  color: var(--am-text);
}

.form-group {
  margin-bottom: var(--am-space-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--am-space-sm);
  color: var(--am-text);
  font-weight: var(--am-font-weight-medium);
  font-size: var(--am-text-sm);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: var(--am-space-md);
  background: var(--am-surface-1);
  border: 1px solid var(--am-border-subtle);
  border-radius: var(--am-radius-md);
  color: var(--am-text);
  font-family: inherit;
  font-size: var(--am-text-base);
  transition: all var(--am-duration-fast) var(--am-ease);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--am-accent);
  box-shadow: 0 0 0 3px var(--am-accent-dim);
}

.form-group input[type="checkbox"] {
  width: auto;
  margin-right: var(--am-space-sm);
}

.form-group small {
  color: var(--am-text-muted);
  font-size: var(--am-text-xs);
}

/* ==========================================
   BUTTONS (Reference-based hierarchy)
   ========================================== */
.am-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--am-space-sm);
  padding: var(--am-space-md) var(--am-space-lg);
  border: none;
  border-radius: var(--am-radius-lg);
  font-family: var(--am-font-ui);
  font-weight: var(--am-font-weight-medium);
  font-size: var(--am-text-base);
  cursor: pointer;
  transition: all var(--am-duration-normal) var(--am-ease);
  text-decoration: none;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.am-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary Button - Reference White */
.am-btn-primary {
  background: var(--am-cta);
  color: var(--am-cta-text);
  font-weight: var(--am-font-weight-bold);
  box-shadow: var(--am-glow-white);
}

.am-btn-primary:hover {
  box-shadow: var(--am-glow-white-strong);
  transform: translateY(-2px);
}

.am-btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--am-glow-white);
}

/* Secondary Button - Ghost style */
.am-btn-secondary {
  background: var(--am-hover-bg);
  color: var(--am-text);
  border: 1px solid var(--am-border);
}

.am-btn-secondary:hover {
  background: var(--am-active-bg);
  border-color: var(--am-border-strong);
}

/* Danger Button - Red themed */
.am-btn-danger {
  background: var(--am-loss-bg);
  color: var(--am-loss);
  border: 1px solid var(--am-loss-border);
}

.am-btn-danger:hover {
  background: var(--am-loss);
  color: var(--am-cta);
  box-shadow: var(--am-glow-loss);
}

/* Button sizes */
.am-btn-sm {
  padding: var(--am-space-sm) var(--am-space-md);
  font-size: var(--am-text-sm);
  border-radius: var(--am-radius-md);
}

.am-btn-lg {
  padding: var(--am-space-lg) var(--am-space-xl);
  font-size: var(--am-text-lg);
  border-radius: var(--am-radius-full);
}

/* ==========================================
   INPUT COMPONENTS (Reference-styled)
   ========================================== */
.am-input {
  width: 100%;
  padding: var(--am-space-md) var(--am-space-lg);
  background: rgba(5, 5, 8, 0.6);
  color: var(--am-text);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-lg);
  font-size: var(--am-text-base);
  font-family: var(--am-font-ui);
  transition: all var(--am-duration-normal) var(--am-ease);
  outline: none;
}

.am-input::placeholder {
  color: var(--am-text-faint);
}

.am-input:focus {
  background: rgba(0, 0, 0, 0.8);
  border-color: var(--am-border-strong);
  box-shadow: var(--am-focus-ring);
}

.am-input-mono {
  font-family: var(--am-font-mono);
  direction: ltr;
  text-align: left;
}

/* Input with icon */
.am-input-group {
  position: relative;
}

.am-input-icon {
  position: absolute;
  top: 50%;
  right: var(--am-space-lg);
  transform: translateY(-50%);
  color: var(--am-text-faint);
  transition: color var(--am-duration-normal) var(--am-ease);
  pointer-events: none;
}

.am-input-group:focus-within .am-input-icon {
  color: var(--am-accent);
}

.am-input-with-icon {
  padding-right: calc(var(--am-space-lg) * 2.5);
}

/* ==========================================
   NAVIGATION COMPONENTS (Reference patterns)
   ========================================== */
.am-nav-item {
  display: flex;
  align-items: center;
  gap: var(--am-space-md);
  padding: var(--am-space-md) var(--am-space-lg);
  color: var(--am-text-muted);
  text-decoration: none;
  border-radius: var(--am-radius-md);
  transition: all var(--am-duration-normal) var(--am-ease);
  position: relative;
}

.am-nav-item:hover {
  color: var(--am-text);
  background: var(--am-hover-bg);
}

.am-nav-item.active {
  background: var(--am-cta);
  color: var(--am-cta-text);
  font-weight: var(--am-font-weight-bold);
  box-shadow: var(--am-glow-white);
}

.am-nav-item.active:hover {
  transform: translateY(-1px);
}

/* ==========================================
   TABLE COMPONENTS (Reference data styling)
   ========================================== */
.am-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--am-surface-1);
  backdrop-filter: blur(12px);
  border: 1px solid var(--am-border-subtle);
  border-radius: var(--am-radius-2xl);
  overflow: hidden;
}

.am-table th {
  background: var(--am-table-header-bg);
  color: var(--am-text-faint);
  font-weight: var(--am-font-weight-medium);
  font-size: var(--am-text-sm);
  padding: var(--am-space-lg);
  text-align: right;
  border-bottom: 1px solid var(--am-table-border);
  position: sticky;
  top: 0;
}

.am-table th:first-child {
  border-top-right-radius: var(--am-radius-2xl);
}

.am-table th:last-child {
  border-top-left-radius: var(--am-radius-2xl);
}

.am-table td {
  padding: var(--am-space-lg);
  border-bottom: 1px solid var(--am-table-border);
  transition: background-color var(--am-duration-normal) var(--am-ease);
}

.am-table tr:hover td {
  background: var(--am-table-hover);
}

.am-table tr:last-child td:first-child {
  border-bottom-right-radius: var(--am-radius-2xl);
}

.am-table tr:last-child td:last-child {
  border-bottom-left-radius: var(--am-radius-2xl);
}

/* Data-specific table styles */
.am-table-data {
  font-family: var(--am-font-mono);
  direction: ltr;
  text-align: left;
}

/* ==========================================
   BADGE COMPONENTS (Semantic colors)
   ========================================== */
.am-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--am-space-xs) var(--am-space-sm);
  font-size: var(--am-text-xs);
  font-weight: var(--am-font-weight-bold);
  border-radius: var(--am-radius-sm);
  border: 1px solid transparent;
}

.am-badge-profit {
  background: var(--am-profit-bg);
  color: var(--am-profit);
  border-color: var(--am-profit-border);
}

.am-badge-loss {
  background: var(--am-loss-bg);
  color: var(--am-loss);
  border-color: var(--am-loss-border);
}

.am-badge-accent {
  background: var(--am-accent-bg);
  color: var(--am-accent);
  border-color: var(--am-accent-border);
}

.am-badge-mono {
  font-family: var(--am-font-mono);
}

/* ==========================================
   ALERT COMPONENTS (Reference feedback)
   ========================================== */
.am-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--am-space-md);
  padding: var(--am-space-lg);
  border-radius: var(--am-radius-lg);
  border-right: 4px solid;
  background: var(--am-surface-2);
  backdrop-filter: blur(12px);
}

.am-alert-success {
  border-right-color: var(--am-profit);
  background: var(--am-profit-bg);
}

.am-alert-error {
  border-right-color: var(--am-loss);
  background: var(--am-loss-bg);
}

.am-alert-info {
  border-right-color: var(--am-accent);
  background: var(--am-accent-bg);
}

.am-alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: var(--am-space-xs);
}

/* ==========================================
   MODAL COMPONENTS (Full-screen overlay)
   ========================================== */
#am-modal-root,
#am-modal-layer-root {
  position: fixed;
  inset: 0;
  z-index: 99995;
  pointer-events: auto;
}

.am-modal-layer {
  position: fixed;
  inset: 0;
  z-index: 99996;
  pointer-events: auto;
}

.am-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99996;
  pointer-events: auto;
}

.am-modal-wrap {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--am-space-lg);
  z-index: 99997;
  pointer-events: auto;
}

.am-modal {
  pointer-events: auto;
  width: min(560px, 100%);
  max-height: 90vh;
  background: rgba(21, 18, 33, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-2xl);
  padding: var(--am-space-xl);
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  z-index: 99998;
}

/* Modal overlay for ledger/detail views */
.am-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99992;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--am-space-lg);
  pointer-events: auto;
}

.am-modal-overlay .am-modal {
  z-index: 99993;
  pointer-events: auto;
}

/* Modal size variants */
.am-modal-sm {
  max-width: 400px;
}

.am-modal-md {
  max-width: 600px;
}

.am-modal-lg {
  max-width: 800px;
}

.am-modal-xl {
  max-width: 1000px;
}

/* Modal structure */
.am-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--am-space-md);
  border-bottom: 1px solid var(--am-border-subtle);
  margin-bottom: var(--am-space-lg);
}

.am-modal-body {
  padding: var(--am-space-md) 0;
}

.am-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--am-space-sm);
  padding-top: var(--am-space-md);
  border-top: 1px solid var(--am-border-subtle);
  margin-top: var(--am-space-lg);
}

body.modal-open {
  overflow: hidden;
}

/* ==========================================
   LOGIN LAYOUT & LOGO
   ========================================== */
.am-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--am-space-8) var(--am-space-6);
  position: relative;
  z-index: 1;
}

.am-login-card {
  width: min(520px, 92vw);
  background: rgba(21, 18, 33, 0.92);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-2xl);
  padding: var(--am-space-7);
  box-shadow: var(--am-shadow-xl);
  backdrop-filter: blur(16px);
}

.am-login-header {
  display: grid;
  gap: var(--am-space-4);
  margin-bottom: var(--am-space-6);
  justify-items: center;
}

.am-login-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--am-space-3);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(106, 174, 255, 0.15), rgba(0,0,0,0.05));
  box-shadow: 0 12px 40px rgba(106, 174, 255, 0.2);
}

.am-login-logo {
  width: 150px;
  max-width: 180px;
  height: auto;
  filter: drop-shadow(0 0 18px rgba(106, 174, 255, 0.35));
  animation: am-login-pulse 6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .am-login-logo {
    animation: none;
  }
}

@keyframes am-login-pulse {
  0% { transform: scale(1); opacity: 0.96; }
  50% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 0.96; }
}

.am-login-form {
  display: grid;
  gap: var(--am-space-4);
}

.am-turnstile-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--am-space-2) 0;
}

.dir-ltr {
  direction: ltr;
  text-align: left;
}

/* ==========================================
   TOAST STYLING
   ========================================== */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 260px;
  max-width: 90vw;
  padding: 12px 18px;
  border-radius: var(--am-radius-lg);
  background: rgba(21, 18, 33, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--am-text, #fff);
  box-shadow: var(--am-shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10002;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#toast.success { border-left: 4px solid var(--am-profit, #10B981); }
#toast.warn { border-left: 4px solid var(--am-accent, #6AAEFF); }
#toast.danger { border-left: 4px solid var(--am-loss, #EF4444); }

/* ==========================================
   UTILITY COMPONENTS
   ========================================== */
.am-loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--am-border);
  border-top-color: var(--am-accent);
  border-radius: 50%;
  animation: am-spin 1s linear infinite;
}

@keyframes am-spin {
  to { transform: rotate(360deg); }
}

.am-pulse {
  animation: am-pulse 2s infinite;
}

@keyframes am-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==========================================
   TYPOGRAPHY COMPONENTS (Reference hierarchy)
   ========================================== */
.am-title-hero {
  font-size: var(--am-text-6xl);
  font-weight: var(--am-font-weight-bold);
  line-height: var(--am-line-tight);
  background: linear-gradient(135deg, var(--am-text), var(--am-accent));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--am-text);
}

.am-title-page {
  font-size: var(--am-text-4xl);
  font-weight: var(--am-font-weight-bold);
  line-height: var(--am-line-tight);
  color: var(--am-text);
}

.am-title-section {
  font-size: var(--am-text-3xl);
  font-weight: var(--am-font-weight-semibold);
  line-height: var(--am-line-tight);
  color: var(--am-text);
}

.am-title-card {
  font-size: var(--am-text-2xl);
  font-weight: var(--am-font-weight-semibold);
  line-height: var(--am-line-tight);
  color: var(--am-text);
}

.am-text-body {
  font-size: var(--am-text-base);
  line-height: var(--am-line-normal);
  color: var(--am-text);
}

.am-text-small {
  font-size: var(--am-text-sm);
  line-height: var(--am-line-normal);
  color: var(--am-text-muted);
}

.am-text-xs {
  font-size: var(--am-text-xs);
  line-height: var(--am-line-normal);
  color: var(--am-text-dim);
}

/* Semantic text colors */
.am-text-profit { color: var(--am-profit); }
.am-text-loss { color: var(--am-loss); }
.am-text-accent { color: var(--am-accent); }
.am-text-muted { color: var(--am-text-muted); }
.am-text-dim { color: var(--am-text-dim); }

/* Font utilities */
.am-mono { font-family: var(--am-font-mono); }
.am-ui { font-family: var(--am-font-ui); }

.am-num {
  direction: ltr;
  display: inline-block;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-variant-numeric: tabular-nums;
}

/* ==========================================
   BUTTON COMPONENTS
   ========================================== */
.am-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--am-space-sm);
  padding: var(--am-space-sm) var(--am-space-lg);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-md);
  font-size: var(--am-text-base);
  font-weight: var(--am-font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--am-duration-normal) var(--am-ease);
  background: transparent;
  color: var(--am-text);
  min-height: 40px;
}

.am-btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--am-shadow-md);
}

.am-btn:active {
  transform: translateY(0);
}

.am-btn.is-primary {
  background: var(--am-cta);
  color: var(--am-bg);
  border-color: var(--am-cta);
}

.am-btn.is-ghost {
  background: transparent;
  border-color: var(--am-border);
}

.am-btn.is-ghost:hover {
  background: var(--am-surface-1);
  border-color: var(--am-border-light);
}

.am-btn.is-danger {
  background: var(--am-loss);
  color: var(--am-text);
  border-color: var(--am-loss);
}

.am-btn.is-small {
  padding: var(--am-space-xs) var(--am-space-md);
  font-size: var(--am-text-sm);
  min-height: 32px;
}

.am-btn.is-large {
  padding: var(--am-space-lg) var(--am-space-2xl);
  font-size: var(--am-text-lg);
  min-height: 48px;
}

.am-btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================
   FORM COMPONENTS
   ========================================== */
.am-field {
  margin-bottom: var(--am-space-lg);
}

.am-label {
  display: block;
  font-size: var(--am-text-sm);
  font-weight: var(--am-font-weight-medium);
  margin-bottom: var(--am-space-sm);
  color: var(--am-text);
}

.am-input,
.am-select,
.am-textarea {
  width: 100%;
  padding: var(--am-space-sm) var(--am-space-md);
  background: var(--am-surface-1);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-md);
  color: var(--am-text);
  font-size: var(--am-text-base);
  transition: all var(--am-duration-normal) var(--am-ease);
}

.am-input:focus,
.am-select:focus,
.am-textarea:focus {
  outline: none;
  border-color: var(--am-accent);
  box-shadow: 0 0 0 3px rgba(106, 174, 255, 0.15);
}

.am-input::placeholder,
.am-textarea::placeholder {
  color: var(--am-text-muted);
}

.am-textarea {
  min-height: 100px;
  resize: vertical;
}

.am-field.is-error .am-input,
.am-field.is-error .am-select,
.am-field.is-error .am-textarea {
  border-color: var(--am-loss);
}

/* ==========================================
   TABLE COMPONENTS
   ========================================== */
.am-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--am-surface-1);
  border-radius: var(--am-radius-lg);
  overflow: hidden;
}

.am-table th,
.am-table td {
  padding: var(--am-space-md);
  text-align: right;
  border-bottom: 1px solid var(--am-border);
}

.am-table th {
  background: var(--am-surface-2);
  font-weight: var(--am-font-weight-semibold);
  font-size: var(--am-text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.am-table tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.am-table tr:last-child td {
  border-bottom: none;
}

/* ==========================================
   BADGE COMPONENTS
   ========================================== */
.am-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--am-space-xs) var(--am-space-sm);
  font-size: var(--am-text-xs);
  font-weight: var(--am-font-weight-medium);
  border-radius: var(--am-radius-full);
  background: var(--am-surface-2);
  color: var(--am-text);
  border: 1px solid var(--am-border);
}

.am-badge.is-profit {
  background: rgba(16, 185, 129, 0.1);
  color: var(--am-profit);
  border-color: var(--am-profit);
}

.am-badge.is-loss {
  background: rgba(239, 68, 68, 0.1);
  color: var(--am-loss);
  border-color: var(--am-loss);
}

.am-badge.is-neutral {
  background: var(--am-surface-1);
  color: var(--am-text-muted);
}

/* ==========================================
   FINANCIAL INDICATORS
   ========================================== */
.is-profit {
  color: var(--am-profit) !important;
}

.is-loss {
  color: var(--am-loss) !important;
}

/* ==========================================
   ALERT COMPONENTS
   ========================================== */
.am-alert {
  padding: var(--am-space-lg);
  border-radius: var(--am-radius-lg);
  background: var(--am-surface-1);
  border: 1px solid var(--am-border);
  margin-bottom: var(--am-space-lg);
}

.am-alert.is-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--am-profit);
  color: var(--am-profit);
}

.am-alert.is-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--am-loss);
  color: var(--am-loss);
}

/* ==========================================
   MODAL COMPONENTS
   ========================================== */
.am-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: var(--am-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--am-space-lg);
}

.am-modal {
  background: var(--am-surface-1);
  backdrop-filter: blur(12px);
  border: 1px solid var(--am-border-light);
  border-radius: var(--am-radius-xl);
  padding: var(--am-space-2xl);
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--am-shadow-xl);
}

/* ==========================================
   NAVIGATION COMPONENTS
   ========================================== */
.am-sidebar {
  background: var(--am-surface-1);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--am-border);
  padding: var(--am-space-lg);
}

.am-nav-item {
  display: flex;
  align-items: center;
  gap: var(--am-space-sm);
  padding: var(--am-space-sm) var(--am-space-md);
  border-radius: var(--am-radius-md);
  color: var(--am-text-muted);
  text-decoration: none;
  transition: all var(--am-duration-normal) var(--am-ease);
}

.am-nav-item:hover {
  background: var(--am-surface-2);
  color: var(--am-text);
  text-decoration: none;
}

.am-nav-item.is-active {
  background: var(--am-accent);
  color: var(--am-text);
}

/* ==========================================
   SPLASH COMPONENTS
   ========================================== */
.am-splash {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--am-bg-grad-from) 0%, var(--am-bg-grad-via) 50%, var(--am-bg-grad-to) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--am-z-modal);
}

/* ==========================================
   STATE CLASSES
   ========================================== */
.is-hidden {
  display: none !important;
}

.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.is-active {
  /* Context-dependent styling */
}

.is-open {
  /* Context-dependent styling */
}

/* ==========================================
   OPERATIONS CONTROL COMPONENTS
   ========================================== */
.am-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--am-space-lg);
  color: var(--am-text-muted);
  font-size: var(--am-text-sm);
}

.am-loading:after {
  content: "⏳";
  margin-left: var(--am-space-xs);
  animation: spin 2s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.status-display {
  display: flex;
  align-items: center;
  gap: var(--am-space-md);
  padding: var(--am-space-lg);
  border-radius: var(--am-radius-md);
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.status-display .status-icon {
  font-size: 3rem;
  line-height: 1;
  flex-shrink: 0;
}

.status-display .status-content {
  flex: 1;
  min-width: 0;
}

.status-display .status-title {
  font-size: var(--am-text-lg);
  font-weight: var(--am-font-weight-bold);
  margin-bottom: var(--am-space-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-display .status-subtitle {
  font-size: var(--am-text-base);
  color: var(--am-text-muted);
  margin-bottom: var(--am-space-xs);
}

.status-display .status-detail {
  font-size: var(--am-text-sm);
  color: var(--am-text-dim);
}

/* Status variants */
.status-display.active {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.3);
}

.status-display.active .status-title {
  color: var(--am-loss);
}

.status-display.normal {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
  border-color: rgba(16, 185, 129, 0.3);
}

.status-display.normal .status-title {
  color: var(--am-profit);
}

.status-display.live {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.4);
}

.status-display.live .status-title {
  color: var(--am-loss);
}

.status-display.paper {
  background: linear-gradient(135deg, rgba(106, 174, 255, 0.1), rgba(106, 174, 255, 0.05));
  border-color: rgba(106, 174, 255, 0.3);
}

.status-display.paper .status-title {
  color: var(--am-accent);
}

.status-pills {
  display: flex;
  align-items: center;
  gap: var(--am-space-sm);
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--am-space-md);
}

.am-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--am-space-md);
  padding-bottom: var(--am-space-md);
  border-bottom: 1px solid var(--am-border-light);
}

.am-card-body {
  flex: 1;
}

.mode-info {
  padding: var(--am-space-md);
  background: var(--am-surface-2);
  border: 1px solid var(--am-border-light);
  border-radius: var(--am-radius-md);
}

/* ==========================================
   ADMIN PANEL TABS UX (Build: 20260129_2200)
   Premium hover, active, focus states
   ========================================== */
.admin-tab {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

/* Hover state - subtle glow + border highlight */
.admin-tab:hover:not(:disabled):not(.is-active) {
    background: rgba(106, 174, 255, 0.06);
    border-color: rgba(106, 174, 255, 0.2);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(106, 174, 255, 0.1);
}

/* Active state - soft blue gradient */
.admin-tab.is-active {
    background: linear-gradient(135deg, rgba(106, 174, 255, 0.15) 0%, rgba(134, 191, 255, 0.1) 100%);
    border-color: var(--am-accent, #6AAEFF);
    color: var(--am-accent, #6AAEFF);
    font-weight: 700;
    box-shadow: inset 0 2px 4px rgba(106, 174, 255, 0.15),
                0 4px 12px rgba(106, 174, 255, 0.12);
    cursor: default;
}

/* Focus-visible state - clear outline ring for keyboard navigation */
.admin-tab:focus-visible {
    outline: 2px solid var(--am-accent, #6AAEFF);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(106, 174, 255, 0.15);
}

/* Disabled/locked state */
.admin-tab:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

/* RTL support */
[dir="rtl"] .admin-tab {
    text-align: right;
}

/* Dark theme adjustments */
@media (prefers-color-scheme: dark) {
    .admin-tab:hover:not(:disabled):not(.is-active) {
        background: rgba(106, 174, 255, 0.1);
        border-color: rgba(106, 174, 255, 0.25);
    }
    
    .admin-tab.is-active {
        background: linear-gradient(135deg, rgba(106, 174, 255, 0.2) 0%, rgba(134, 191, 255, 0.15) 100%);
        box-shadow: inset 0 2px 4px rgba(106, 174, 255, 0.2),
                    0 4px 12px rgba(106, 174, 255, 0.15);
    }
}

/* ==========================================
   ADMIN PANEL MOUNT ROOTS (FIX BLANK RENDERS)
   Ensure admin tab containers are always visible
   Build: 20260129_1800_RENDER_FIX
   ========================================== */
#admin-tab-content,
#admin-root,
#admin-panel-root,
.admin-tab-container {
  display: block !important;
  min-height: 200px;
  width: 100%;
  position: relative;
}

/* Ensure nested admin containers inherit visibility */
#admin-tab-content > div[id^="admin-"],
#admin-root > div[id^="admin-"] {
  display: block;
  min-height: inherit;
}