:root {
  --brand: #0c4349;
  --brand-light: #14616a;
  --brand-soft: rgba(12, 67, 73, 0.08);
  --brand-100: rgba(255, 255, 255, 0.1);
  --brand-200: rgba(255, 255, 255, 0.2);
  --brand-text: #ffffff;
  --bg-slate-50: #f8fafc;
  --bg-slate-100: #f1f5f9;
  --text-slate-900: #0f172a;
  --text-slate-700: #334155;
  --text-slate-600: #475569;
  --text-slate-500: #64748b;
  --text-slate-400: #94a3b8;
  --border-slate-200: #e2e8f0;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
  background-color: var(--bg-slate-50);
  color: var(--text-slate-900);
  font-family: 'Cairo', sans-serif;
}

.traders-page-wrap {
  max-width: 1440px;
  margin: 0 auto;
}

/* Header */
.app-header {
  background-color: var(--brand);
  color: white;
  padding: 1rem 0;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 10;
}

.app-header .container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .app-header .container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon-wrapper {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 0.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.header-brand p {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: none;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
  text-decoration: none;
}

.nav-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.nav-btn-primary {
  background-color: white;
  color: var(--brand);
  border: none;
  box-shadow: var(--shadow-sm);
}

.nav-btn-primary:hover {
  background-color: #f1f5f9;
}

/* Main Content Layout */
.main-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .main-container {
    flex-direction: row;
  }
}

.sidebar {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .sidebar {
    width: 33.333333%;
  }
}

@media (min-width: 1280px) {
  .sidebar {
    width: 25%;
  }
}

.content-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .content-area {
    width: 66.666667%;
  }
}

@media (min-width: 1280px) {
  .content-area {
    width: 75%;
  }
}

/* Cards */
.card {
  background-color: white;
  border-radius: 0.5rem;
  border: 1px solid var(--border-slate-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.card-description {
  font-size: 0.875rem;
  color: var(--text-slate-500);
  margin-top: 0.25rem;
}

.card-content {
  padding: 1.25rem 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-slate-200);
}

/* Form Elements */
.input-group {
  margin-bottom: 1rem;
}

.input-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-slate-600);
  margin-bottom: 0.25rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-slate-200);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-slate-900);
  background-color: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(12, 67, 73, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
  border: none;
  gap: 0.5rem;
}

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

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

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

.btn-outline:hover {
  background-color: var(--bg-slate-50);
}

.btn-danger-outline {
  background-color: transparent;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.btn-danger-outline:hover {
  background-color: #fef2f2;
}

.btn-success {
  background-color: #10b981;
  color: white;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-full {
  width: 100%;
}

/* Status Messages */
.status {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  display: none;
}

.status.info {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

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

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

/* Sidebar Specifics */
.trader-accounts-card {
  border-top: 4px solid var(--brand);
}

.trader-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  transition: background-color 0.2s, border-color 0.2s;
}

.trader-card:hover {
  background-color: var(--bg-slate-100);
  border-color: var(--border-slate-200);
}

.trader-card-name {
  font-weight: 600;
  color: var(--text-slate-700);
}

.trader-card-meta {
  font-size: 0.75rem;
  color: var(--text-slate-500);
  margin-top: 0.125rem;
}

.trader-card-actions {
  display: flex;
  gap: 0.5rem;
}

.mini-btn {
  padding: 0.25rem;
  border-radius: 0.25rem;
  color: var(--text-slate-400);
  transition: color 0.2s;
}

.mini-btn:hover {
  color: var(--brand);
}

.mini-btn.danger:hover {
  color: #dc2626;
}

/* Toolbar */
.toolbar-card {
  padding: 0.75rem;
}

.toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.filter-group {
  display: flex;
  gap: 0.75rem;
  flex: 1;
  min-width: 300px;
}

/* Summary Card */
.summary-card {
  background: linear-gradient(to right, var(--brand), var(--brand-light));
  color: white;
  border: none;
  position: relative;
  overflow: hidden;
}

.summary-card-bg-circle {
  position: absolute;
  top: 0;
  right: 0;
  width: 16rem;
  height: 16rem;
  background-color: white;
  opacity: 0.05;
  border-radius: 9999px;
  transform: translate(25%, -50%);
  filter: blur(24px);
}

.summary-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .summary-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.summary-text h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.summary-text p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.summary-pill {
  background-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.summary-pill-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.25rem;
}

.summary-pill-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.summary-pill-highlight {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

.summary-pill-highlight .summary-pill-value {
  color: #6ee7b7;
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
}

.stat-icon {
  padding: 0.75rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.blue { background-color: #eff6ff; color: #2563eb; }
.stat-icon.indigo { background-color: #eef2ff; color: #4f46e5; }
.stat-icon.emerald { background-color: #ecfdf5; color: #059669; }
.stat-icon.amber { background-color: #fffbeb; color: #d97706; }

.stat-info .stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-slate-500);
}

.stat-info .stat-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-slate-800);
}

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

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

thead {
  background-color: rgba(241, 245, 249, 0.5);
}

th {
  text-align: right;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-slate-600);
  border-bottom: 1px solid var(--border-slate-200);
}

td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-slate-600);
  border-bottom: 1px solid #f1f5f9;
}

tr:hover td {
  background-color: var(--bg-slate-50);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.badge-outline {
  background-color: transparent;
  border-color: var(--border-slate-200);
}

.badge-blue { background-color: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-emerald { background-color: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge-amber { background-color: #fffbeb; color: #b45309; border-color: #fde68a; }

.amount-positive { color: #dc2626; font-weight: 600; font-family: monospace; }
.amount-negative { color: #059669; font-weight: 600; font-family: monospace; }
.balance-cell { font-weight: 700; color: var(--text-slate-800); background-color: rgba(248, 250, 252, 0.5); font-family: monospace; }

.empty-ledger {
  padding: 3rem;
  text-align: center;
  color: var(--text-slate-400);
}

.note-box {
  background-color: #fefce8;
  border: 1px solid #fef08a;
  border-radius: 0.5rem;
  padding: 1rem;
  color: #854d0e;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Mobile Cards */
.mobile-ledger-cards {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.ledger-mobile-card {
  background-color: white;
  border: 1px solid var(--border-slate-200);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.ledger-mobile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ledger-mobile-index {
  font-weight: 700;
  color: var(--brand);
}

.ledger-mobile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.ledger-mobile-item {
  background-color: #f8fafc;
  border: 1px solid var(--border-slate-200);
  border-radius: 0.75rem;
  padding: 0.625rem 0.75rem;
}

.ledger-mobile-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-slate-500);
  margin-bottom: 0.25rem;
}

.ledger-mobile-item strong {
  display: block;
  font-size: 0.875rem;
  color: var(--text-slate-800);
}

.ledger-mobile-item.full {
  grid-column: span 2;
}

/* Print Utilities */
.print-header { display: none; }
.screen-only { display: block; }

@media (max-width: 640px) {
  .ledger-table-wrapper { display: none; }
  .mobile-ledger-cards { display: flex; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: white; }
  .app-header, .sidebar, .toolbar-card, .quick-actions, .note-box, .screen-only, .mobile-ledger-cards { display: none !important; }
  .main-container { padding: 0; display: block; width: 100%; max-width: none; }
  .content-area { width: 100%; }
  .card { border: none; box-shadow: none; }
  .print-header { display: block; border-bottom: 2px solid #000; margin-bottom: 1rem; padding-bottom: 0.5rem; }
  .print-header h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
  .print-header p { font-size: 0.875rem; margin: 0.25rem 0; }
  .ledger-table-wrapper { display: block !important; border: 1px solid #000; }
  table { border-collapse: collapse; }
  th, td { border: 1px solid #000; padding: 4px 6px; font-size: 10px; }
  th { background-color: #eee !important; color: black !important; }
  .badge { border: 1px solid #000; background: transparent !important; color: black !important; }
}
