/* ARTEL Fintech - Admin Panel Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #E84E0F;
  --primary-hover: #D14509;
  --primary-light: rgba(232, 78, 15, 0.1);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --bg-white: #ffffff;
  --bg-light: #f8fafc;
  --bg-sidebar: #ffffff;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 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);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-main {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.title-badge {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border-radius: 4px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

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

.nav-item.active {
  background: var(--primary);
  color: white;
}

.nav-item svg {
  flex-shrink: 0;
}

.nav-item span {
  font-size: 14px;
  font-weight: 500;
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 16px;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #f97316;
  padding: 14px 16px 6px;
  margin-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.nav-group-label:first-child {
  border-top: none;
  margin-top: 0;
}

.sidebar-back {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.back-link-sidebar {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
  width: 100%;
}

.back-link-sidebar:hover {
  background: var(--bg-light);
  color: var(--primary);
}

.back-link-sidebar svg {
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.user-tariff {
  font-size: 10px;
  color: var(--primary);
  font-weight: 600;
}

.btn-logout {
  padding: 8px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--red);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: calc(100vw - var(--sidebar-width));
}

.section {
  animation: fadeIn 0.3s ease;
}

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

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.header-stats {
  display: flex;
  gap: 12px;
}

.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-badge .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-badge .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-badge.stat-green .stat-value { color: var(--green); }
.stat-badge.stat-yellow .stat-value { color: var(--yellow); }
.stat-badge.stat-red .stat-value { color: var(--red); }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 400px;
  padding: 10px 16px;
  background: var(--bg-white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: var(--text-primary);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-group select {
  padding: 10px 16px;
  font-size: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.filter-group select:focus {
  border-color: var(--primary);
}

/* Table */
.table-container {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

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

.data-table th {
  padding: 16px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 16px 20px;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.data-table tr:hover td {
  background: var(--bg-light);
}

/* User Cell */
.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-cell-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-cell-info {
  display: flex;
  flex-direction: column;
}

.user-cell-name {
  font-weight: 500;
  color: var(--text-primary);
}

.user-cell-email {
  font-size: 12px;
  color: var(--text-muted);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
}

.badge-free {
  background: var(--bg-light);
  color: var(--text-secondary);
}

.badge-pro {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
}

.badge-admin {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
  color: #9d174d;
}

.badge-active {
  background: #dcfce7;
  color: #166534;
}

.badge-blocked {
  background: #fef2f2;
  color: #dc2626;
}

.badge-token {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-no-token {
  background: var(--bg-light);
  color: var(--text-muted);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-action.btn-danger:hover {
  background: #fef2f2;
  color: var(--red);
}

.btn-action.btn-success:hover {
  background: #dcfce7;
  color: var(--green);
}

/* Table Empty */
.table-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.table-empty svg {
  margin-bottom: 16px;
}

.table-empty p {
  font-size: 14px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.stat-card-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.stat-card-info {
  display: flex;
  flex-direction: column;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Chart Section */
.chart-section {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.chart-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.chart-placeholder {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  border-radius: var(--radius);
  color: var(--text-muted);
}

/* Server Cards */
.server-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.server-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.server-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}

.server-card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.status-badge {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
}

.status-online {
  background: #dcfce7;
  color: #166534;
}

.status-offline {
  background: #fef2f2;
  color: #dc2626;
}

.server-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.server-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.server-stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.server-stat-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.action-btn.action-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--red);
}

.action-btn.action-danger:hover {
  background: #fee2e2;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.3s ease;
}

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

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  border: none;
  border-radius: 8px;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

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

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.modal-form input,
.modal-form select {
  padding: 10px 14px;
  font-size: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s ease;
}

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

.modal-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.modal-password-wrapper input {
  padding-right: 42px;
  flex: 1;
}
.modal-password-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-password-eye:hover {
  color: var(--text, #0f172a);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-primary {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-secondary {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--border);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  background: var(--text-primary);
  color: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.toast-success {
  background: var(--green);
}

.toast.toast-error {
  background: var(--red);
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 80px;
  }
  
  .sidebar-title,
  .nav-item span,
  .user-details {
    display: none;
  }
  
  .main-content {
    margin-left: 80px;
  }
  
  .sidebar-header {
    justify-content: center;
    padding: 16px;
  }
  
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  
  .sidebar-footer {
    flex-direction: column;
  }
  
  .user-info {
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 20px;
  }
  
  .section-header {
    flex-direction: column;
    gap: 16px;
  }
  
  .header-stats {
    width: 100%;
    justify-content: space-between;
  }
  
  .toolbar {
    flex-direction: column;
  }
  
  .search-box {
    max-width: none;
    width: 100%;
  }
  
  .filter-group {
    width: 100%;
  }
  
  .filter-group select {
    flex: 1;
  }
  
  .data-table {
    display: block;
    overflow-x: auto;
  }
}

/* ===== ECOSYSTEM MONITORING ===== */
.eco-header-right {
  display: flex; align-items: center; gap: 12px;
}
.eco-last-update {
  font-size: 12px; color: #94a3b8; white-space: nowrap;
}

.eco-summary {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 28px;
}
.eco-sum-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 16px 18px; text-align: center;
}
.eco-sum-value {
  display: block; font-size: 28px; font-weight: 700; color: #0f172a; line-height: 1.2;
}
.eco-sum-label {
  font-size: 12px; color: #94a3b8; margin-top: 4px; display: block;
}
.eco-sum-warn .eco-sum-value { color: #ef4444; }

.eco-group-title {
  font-size: 15px; font-weight: 600; color: #0f172a;
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid #f1f5f9;
}

.eco-services-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; margin-bottom: 28px;
}
.eco-svc-loading {
  font-size: 13px; color: #94a3b8; padding: 24px; text-align: center;
  grid-column: 1 / -1;
}

.eco-svc-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 16px 18px; transition: box-shadow .15s;
}
.eco-svc-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.eco-svc-card.offline { border-color: #fecaca; background: #fef2f2; }

.eco-svc-top {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.eco-svc-name {
  font-size: 14px; font-weight: 600; color: #0f172a;
}
.eco-svc-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}
.eco-svc-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,.4); }
.eco-svc-dot.offline { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,.4); }

.eco-svc-desc {
  font-size: 11px; color: #94a3b8; margin-bottom: 10px;
}

.eco-svc-metrics {
  display: flex; flex-direction: column; gap: 6px;
}
.eco-svc-metric {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
}
.eco-svc-metric-label { color: #64748b; }
.eco-svc-metric-value { font-weight: 600; color: #0f172a; }

.eco-mem-bar {
  height: 4px; background: #f1f5f9; border-radius: 2px; margin-top: 2px; overflow: hidden;
}
.eco-mem-fill {
  height: 100%; border-radius: 2px; background: #3b82f6; transition: width .3s;
}
.eco-mem-fill.warn { background: #f59e0b; }
.eco-mem-fill.danger { background: #ef4444; }

/* News stats grid */
.eco-news-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 28px;
}
.eco-news-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 14px 16px; text-align: center;
}
.eco-news-val {
  font-size: 22px; font-weight: 700; color: #0f172a; display: block;
}
.eco-news-lbl {
  font-size: 11px; color: #94a3b8; margin-top: 2px; display: block;
}

.eco-actions {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px;
}

@media (max-width: 768px) {
  .eco-summary { grid-template-columns: repeat(2, 1fr); }
  .eco-services-grid { grid-template-columns: 1fr; }
  .eco-news-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ==================== Portfolio Management ==================== */
/* ---- Portfolio Top Bar ---- */
.pf-top-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.pf-title { font-size: 22px; font-weight: 700; color: #0f172a; margin: 0; }
.pf-subtitle { font-size: 13px; color: #94a3b8; margin: 4px 0 0; }
.pf-top-right { display: flex; gap: 10px; }
.pf-btn-sync {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: 1px solid #e2e8f0; background: #fff;
  border-radius: 10px; font-size: 13px; font-weight: 600; color: #475569;
  cursor: pointer; transition: all 0.15s;
}
.pf-btn-sync:hover { border-color: #3b82f6; color: #3b82f6; background: #eff6ff; }
.pf-btn-add {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: none; background: linear-gradient(135deg, #f97316, #ea580c);
  border-radius: 10px; font-size: 13px; font-weight: 600; color: #fff;
  cursor: pointer; transition: all 0.15s; box-shadow: 0 2px 8px rgba(249,115,22,0.25);
}
.pf-btn-add:hover { box-shadow: 0 4px 16px rgba(249,115,22,0.35); transform: translateY(-1px); }

/* ---- Sync Panel ---- */
.pf-sync-panel {
  background: linear-gradient(135deg, #eff6ff, #f0f9ff); border: 1px solid #bfdbfe;
  border-radius: 12px; padding: 16px 20px; margin-bottom: 20px;
}
.pf-sync-inner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pf-sync-group { display: flex; align-items: center; gap: 8px; }
.pf-sync-group label { font-size: 13px; font-weight: 700; color: #1e40af; }
.pf-sync-select {
  padding: 8px 14px; border: 1px solid #93c5fd; border-radius: 8px;
  font-size: 13px; color: #1e293b; background: #fff; min-width: 220px;
}
.pf-btn-run {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border: none; background: #3b82f6; color: #fff;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.pf-btn-run:hover { background: #2563eb; }
.pf-btn-cancel {
  padding: 8px 14px; border: 1px solid #cbd5e1; background: #fff;
  border-radius: 8px; font-size: 13px; cursor: pointer; color: #64748b;
}
.pf-btn-cancel:hover { background: #f8fafc; }
.pf-sync-status { font-size: 13px; color: #16a34a; font-weight: 600; }

/* ---- Metrics Cards ---- */
.pf-metrics {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px;
}
.pf-metric {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 18px 16px; transition: all 0.2s;
}
.pf-metric:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.05); border-color: #cbd5e1; }
.pf-metric-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pf-metric.open .pf-metric-icon   { background: rgba(59,130,246,0.1); color: #3b82f6; }
.pf-metric.closed .pf-metric-icon { background: rgba(100,116,139,0.1); color: #64748b; }
.pf-metric.pnl .pf-metric-icon    { background: rgba(249,115,22,0.1); color: #f97316; }
.pf-metric.winrate .pf-metric-icon { background: rgba(34,197,94,0.1); color: #22c55e; }
.pf-metric.avgpnl .pf-metric-icon { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.pf-metric.bestdeal .pf-metric-icon { background: rgba(16,185,129,0.1); color: #10b981; }
.pf-metric.worstdeal .pf-metric-icon { background: rgba(239,68,68,0.1); color: #ef4444; }
.pf-metric-data { display: flex; flex-direction: column; }
.pf-metric-val {
  font-size: 22px; font-weight: 700; color: #0f172a;
  font-family: 'JetBrains Mono', monospace; line-height: 1.1;
}
.pf-metric-label { font-size: 12px; color: #94a3b8; margin-top: 3px; text-transform: uppercase; letter-spacing: 0.3px; }

/* ---- Tabs ---- */
.pf-tabs {
  display: flex; gap: 4px; margin-bottom: 16px; align-items: center;
  background: #f1f5f9; border-radius: 10px; padding: 4px; width: fit-content;
}
.pf-month-filter {
  padding: 6px 14px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 13px; color: #0f172a; background: #fff; cursor: pointer; outline: none;
  margin-left: 8px;
}
.pf-month-filter:focus { border-color: var(--primary); }
.pf-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 20px; border: none; background: transparent;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: #64748b;
  cursor: pointer; transition: all 0.15s;
}
.pf-tab:hover { color: #1e293b; }
.pf-tab.active { background: #fff; color: #0f172a; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.pf-tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: #e2e8f0; border-radius: 10px;
  font-size: 11px; font-weight: 700; font-family: 'JetBrains Mono', monospace;
}
.pf-tab.active .pf-tab-badge { background: #f97316; color: #fff; }

/* ---- Table ---- */
.pf-table-wrap {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; overflow: hidden;
}
.pf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pf-table thead th {
  background: #f8fafc; padding: 12px 14px; text-align: left;
  font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 2px solid #e2e8f0; white-space: nowrap;
}
.pf-table tbody td {
  padding: 14px; border-bottom: 1px solid #f1f5f9; color: #1e293b; vertical-align: middle;
}
.pf-table tbody tr { transition: background 0.1s; }
.pf-table tbody tr:hover { background: #fafbfd; }
.pf-table tbody tr:last-child td { border-bottom: none; }
.pf-table tbody tr.pf-row-closed { opacity: 0.7; }
.pf-table tbody tr.pf-row-closed:hover { opacity: 1; }

.pf-ticker {
  font-weight: 700; font-family: 'JetBrains Mono', monospace; color: #f97316; font-size: 14px;
}
.pf-dir {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 8px; font-size: 11px; font-weight: 700;
}
.pf-long { background: #dcfce7; color: #16a34a; }
.pf-short { background: #fee2e2; color: #dc2626; }
.pf-profit { color: #16a34a; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.pf-loss { color: #dc2626; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.pf-sl-tp {
  display: flex; flex-direction: column; gap: 2px; font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.pf-sl-val { color: #dc2626; }
.pf-tp-val { color: #16a34a; }
.pf-status {
  display: inline-block; padding: 3px 10px; border-radius: 8px; font-size: 11px; font-weight: 600;
}
.pf-status-open { background: #dbeafe; color: #2563eb; }
.pf-status-closed { background: #f1f5f9; color: #64748b; }
.pf-empty { text-align: center; color: #94a3b8; padding: 48px 16px; font-size: 14px; }

/* ---- Action buttons ---- */
.pf-actions { display: flex; gap: 5px; justify-content: center; }
.pf-action-btn {
  width: 30px; height: 30px; border: 1px solid #e2e8f0; background: #fff;
  border-radius: 8px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: all 0.15s; color: #94a3b8; font-size: 12px;
}
.pf-action-btn:hover { border-color: #f97316; color: #f97316; background: #fff7ed; }
.pf-action-btn.danger:hover { border-color: #dc2626; color: #dc2626; background: #fef2f2; }
.pf-action-btn.pf-visible { color: #16a34a; border-color: #bbf7d0; background: #f0fdf4; }
.pf-action-btn.pf-visible:hover { border-color: #16a34a; }
.pf-action-btn.pf-hidden { color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.pf-action-btn.pf-hidden:hover { border-color: #dc2626; }

/* ---- Form ---- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: #64748b; text-transform: uppercase; }
.form-input {
  padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; color: #1e293b; background: #fff; outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: #f97316; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.btn-secondary {
  padding: 10px 20px; border: 1px solid #e2e8f0; background: #fff;
  border-radius: 8px; font-size: 14px; cursor: pointer; color: #64748b;
}
.btn-secondary:hover { background: #f8fafc; }

@media (max-width: 1024px) {
  .pf-metrics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .pf-metrics { grid-template-columns: repeat(2, 1fr); }
  .pf-table-wrap { overflow-x: auto; }
  .pf-table { min-width: 800px; }
  .form-row { grid-template-columns: 1fr; }
  .pf-top-bar { flex-direction: column; align-items: flex-start; }
}

/* ==================== APR Constructor ==================== */
.apr-templates-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px;
}
.apr-tpl-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 24px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.apr-tpl-card:hover { border-color: #f97316; box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.apr-tpl-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.apr-tpl-name { font-size: 17px; font-weight: 600; color: #1e293b; }
.apr-tpl-badge {
  font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 20px;
  background: #dcfce7; color: #16a34a; white-space: nowrap;
}
.apr-tpl-badge.inactive { background: #f1f5f9; color: #94a3b8; }
.apr-tpl-desc { font-size: 13px; color: #64748b; margin-bottom: 16px; line-height: 1.5; }
.apr-tpl-stats { display: flex; gap: 16px; margin-bottom: 16px; }
.apr-tpl-stat { font-size: 12px; color: #94a3b8; }
.apr-tpl-stat b { color: #1e293b; font-weight: 600; }
.apr-tpl-actions { display: flex; gap: 8px; }
.apr-tpl-btn {
  padding: 6px 14px; border: 1px solid #e2e8f0; background: #fff; border-radius: 8px;
  font-size: 13px; cursor: pointer; color: #64748b; transition: all 0.15s; display: flex;
  align-items: center; gap: 4px;
}
.apr-tpl-btn:hover { border-color: #f97316; color: #f97316; }
.apr-tpl-btn.danger:hover { border-color: #dc2626; color: #dc2626; }

/* Editor */
.apr-editor-wrap {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 28px; margin-top: 20px;
}
.apr-editor-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.apr-editor-header h3 { font-size: 18px; font-weight: 600; color: #1e293b; margin: 0; }
.apr-editor-actions { display: flex; gap: 10px; }

/* Steps builder */
.apr-steps-builder { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }

.apr-step-card {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px;
  position: relative; transition: border-color 0.2s;
}
.apr-step-card:hover { border-color: #cbd5e1; }
.apr-step-card-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.apr-step-num {
  width: 32px; height: 32px; border-radius: 50%; background: #f97316; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.apr-step-title-input {
  flex: 1; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 15px;
  font-weight: 600; color: #1e293b; background: #fff; outline: none;
}
.apr-step-title-input:focus { border-color: #f97316; }
.apr-step-desc-input {
  width: 100%; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px;
  color: #64748b; background: #fff; outline: none; margin-bottom: 14px; box-sizing: border-box;
}
.apr-step-desc-input:focus { border-color: #f97316; }
.apr-step-remove {
  position: absolute; top: 12px; right: 12px; width: 28px; height: 28px;
  border: 1px solid #e2e8f0; background: #fff; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: #94a3b8; transition: all 0.15s;
}
.apr-step-remove:hover { border-color: #dc2626; color: #dc2626; }

/* Criteria inside step */
.apr-criteria-list { display: flex; flex-direction: column; gap: 8px; }
.apr-crit-row {
  display: grid; grid-template-columns: 1fr 120px 80px 32px; gap: 8px; align-items: center;
}
.apr-crit-label {
  padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px;
  color: #1e293b; background: #fff; outline: none;
}
.apr-crit-label:focus { border-color: #f97316; }
.apr-crit-dir {
  padding: 7px 8px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 12px;
  color: #1e293b; background: #fff; outline: none; cursor: pointer;
}
.apr-crit-weight {
  padding: 8px 8px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px;
  color: #1e293b; background: #fff; outline: none; text-align: center;
  font-family: 'JetBrains Mono', monospace;
}
.apr-crit-weight:focus { border-color: #f97316; }
.apr-crit-remove {
  width: 28px; height: 28px; border: none; background: transparent; cursor: pointer;
  color: #cbd5e1; display: flex; align-items: center; justify-content: center; transition: color 0.15s;
}
.apr-crit-remove:hover { color: #dc2626; }

.apr-add-crit-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px;
  border: 1px dashed #cbd5e1; background: transparent; border-radius: 8px; font-size: 12px;
  color: #94a3b8; cursor: pointer; transition: all 0.15s; margin-top: 8px;
}
.apr-add-crit-btn:hover { border-color: #f97316; color: #f97316; }

.apr-add-step-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 14px; border: 2px dashed #e2e8f0; background: transparent; border-radius: 12px;
  font-size: 14px; font-weight: 500; color: #94a3b8; cursor: pointer; transition: all 0.2s;
  margin-top: 16px;
}
.apr-add-step-btn:hover { border-color: #f97316; color: #f97316; background: #fffbf5; }

.apr-crit-header {
  display: grid; grid-template-columns: 1fr 120px 80px 32px; gap: 8px; margin-bottom: 6px;
  font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0 12px;
}

@media (max-width: 768px) {
  .apr-templates-grid { grid-template-columns: 1fr; }
  .apr-crit-row { grid-template-columns: 1fr; gap: 4px; }
  .apr-crit-header { display: none; }
  .apr-editor-header { flex-direction: column; gap: 12px; }
}

/* Staff metrics */
.staff-metrics {
  display: flex; gap: 16px; margin-bottom: 24px;
}
.staff-metric {
  flex: 1; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 20px 24px; display: flex; flex-direction: column; gap: 4px;
}
.staff-metric-val {
  font-size: 28px; font-weight: 700; color: #1e293b;
}
.staff-metric-label {
  font-size: 13px; color: #64748b;
}
.staff-metric-green .staff-metric-val { color: #16a34a; }
.staff-metric-red .staff-metric-val { color: #dc2626; }

/* Staff access checkboxes */
.staff-access-checks {
  display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px;
}
.check-label {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: #334155; cursor: pointer;
}
.check-label input { accent-color: #f97316; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* Signals */
.signals-counter { font-size: 13px; color: #64748b; font-weight: 500; background: #f1f5f9; padding: 4px 12px; border-radius: 6px; }
.signals-filters { display: flex; gap: 8px; margin-bottom: 20px; }
.sig-filter-btn {
  padding: 6px 16px; border-radius: 8px; border: 1px solid #e2e8f0; background: #fff;
  font-size: 13px; font-weight: 500; color: #64748b; cursor: pointer; transition: all .15s;
}
.sig-filter-btn:hover { border-color: #f97316; color: #f97316; }
.sig-filter-btn.active { background: #f97316; color: #fff; border-color: #f97316; }

.signals-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid #e2e8f0; }
.signals-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.signals-table th { background: #f8fafc; font-weight: 600; color: #475569; padding: 10px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid #e2e8f0; }
.signals-table td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.signals-table tbody tr:hover { background: #fffbeb; }
.sig-empty { text-align: center; padding: 40px 14px !important; color: #94a3b8; }

.sig-dir-long { color: #22c55e; font-weight: 600; }
.sig-dir-short { color: #ef4444; font-weight: 600; }
.sig-status { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.sig-status-active { background: #dcfce7; color: #16a34a; }
.sig-status-closed { background: #f1f5f9; color: #64748b; }
.sig-pnl-pos { color: #22c55e; font-weight: 600; }
.sig-pnl-neg { color: #ef4444; font-weight: 600; }
.sig-actions { display: flex; gap: 6px; }
.sig-action-btn {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid #e2e8f0; background: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.sig-action-btn:hover { background: #f1f5f9; border-color: #f97316; }
.sig-action-btn svg { width: 14px; height: 14px; }
.sig-action-btn.sig-del:hover { background: #fef2f2; border-color: #ef4444; }

/* Role badges */
.badge-role-admin { background: #7c3aed; color: #fff; }
.badge-role-analyst { background: #0ea5e9; color: #fff; }
.badge-role-manager { background: #f59e0b; color: #fff; }

.btn-promote { color: #0ea5e9 !important; }
.btn-promote:hover { background: rgba(14,165,233,.12) !important; }
.btn-demote { color: #94a3b8 !important; }
.btn-demote:hover { background: rgba(148,163,184,.12) !important; }

/* Role popup menu */
.role-popup-menu {
  z-index: 9999; background: #fff; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18); min-width: 180px; overflow: hidden;
}
.role-popup-title {
  padding: 10px 16px; font-size: 12px; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid #f1f5f9;
}
.role-popup-menu button {
  display: block; width: 100%; text-align: left; padding: 10px 16px;
  border: none; background: none; font-size: 14px; color: #334155; cursor: pointer;
}
.role-popup-menu button:hover { background: #f8fafc; color: #f97316; }

@media (max-width: 768px) {
  .staff-metrics { flex-direction: column; }
  .nav-group-label { padding: 10px 8px 2px; font-size: 9px; }
}

/* ==================== Company Portfolio Admin ==================== */
.cp-admin-grid { display: flex; flex-direction: column; gap: 16px; }

.cp-admin-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  overflow: hidden; transition: border-color 0.2s;
}
.cp-admin-card:hover { border-color: #cbd5e1; }

.cp-admin-card-header {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 24px; cursor: pointer; transition: background 0.15s;
}
.cp-admin-card-header:hover { background: #fafbfd; }

.cp-admin-card-info { flex: 1; min-width: 0; }
.cp-admin-card-name { font-size: 16px; font-weight: 600; color: #1e293b; margin-bottom: 6px; }
.cp-admin-card-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.cp-meta-tag {
  display: inline-block; padding: 2px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 500; background: #f1f5f9; color: #64748b;
}
.cp-meta-date { font-size: 11px; color: #94a3b8; padding: 2px 0; }

.cp-admin-card-metrics {
  display: flex; gap: 24px; flex-shrink: 0;
}
.cp-admin-metric { display: flex; flex-direction: column; align-items: flex-end; }
.cp-admin-metric-label { font-size: 11px; color: #94a3b8; }
.cp-admin-metric-val { font-size: 14px; font-weight: 600; color: #1e293b; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }

.cp-expand-arrow { flex-shrink: 0; color: #94a3b8; transition: transform 0.2s; }
.cp-expanded .cp-expand-arrow { transform: rotate(180deg); }

.cp-admin-card-body {
  display: none; padding: 0 24px 20px; border-top: 1px solid #f1f5f9;
}
.cp-expanded .cp-admin-card-body { display: block; }

.cp-admin-sectors { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cp-sector-tag {
  display: inline-block; padding: 3px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 500; background: #eff6ff; color: #3b82f6;
}
.cp-sector-tag-sm {
  display: inline-block; padding: 1px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 500; background: #f1f5f9; color: #64748b;
}

@media (max-width: 1024px) {
  .cp-admin-card-header { flex-direction: column; align-items: flex-start; }
  .cp-admin-card-metrics { flex-wrap: wrap; gap: 12px; }
  .cp-admin-metric { align-items: flex-start; }
}

/* Tariff badges */
.badge-tariff-investment { background: #dbeafe; color: #1d4ed8; }
.badge-tariff-extended { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.badge-tariff-mts { background: linear-gradient(135deg, #fce7f3, #fbcfe8); color: #9d174d; }
.badge-tariff-complex { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #166534; }
.badge-tariff-staff { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); color: #7c3aed; }

/* Tariff cell */
.tariff-cell { display: flex; flex-direction: column; gap: 6px; }
.tariff-select {
  padding: 4px 8px; font-size: 12px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg-white); color: var(--text-secondary);
  cursor: pointer; outline: none; max-width: 160px; transition: border-color 0.15s;
}
.tariff-select:focus { border-color: var(--primary); }
.tariff-select:hover { border-color: #94a3b8; }

