/* ============ VARIABLES ============ */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============ LAYOUT ============ */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.logo-icon {
  font-size: 1.75rem;
}

.logo-img {
  height: 32px;
  width: auto;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

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

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

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ STATS ============ */
.stats-section {
  margin-bottom: 2rem;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  font-size: 2rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ============ ADD SECTION ============ */
.add-section {
  margin-bottom: 2rem;
}

.add-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.add-card h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

.add-form {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-group {
  flex: 1;
  min-width: 200px;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ============ ACCOUNTS ============ */
.accounts-section h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1rem;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.2s;
}

.account-card:hover {
  border-color: var(--primary);
}

.account-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.account-name {
  font-size: 1.125rem;
  font-weight: 600;
}

.account-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.account-score {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.score-badge {
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
}

.score-badge.grade-a { background: #22c55e20; color: #22c55e; }
.score-badge.grade-b { background: #84cc1620; color: #84cc16; }
.score-badge.grade-c { background: #f59e0b20; color: #f59e0b; }
.score-badge.grade-d { background: #f9731620; color: #f97316; }
.score-badge.grade-f { background: #ef444420; color: #ef4444; }

.account-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
}

.account-stat {
  text-align: center;
  flex: 1;
}

.account-stat-value {
  font-size: 1.25rem;
  font-weight: 600;
}

.account-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.account-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.account-actions .btn {
  flex: 1;
  min-width: 100px;
}

/* ============ LOADING ============ */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* ============ PRIORITY BADGES ============ */
.priority-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.priority-critical { background: #ef444430; color: #ef4444; }
.priority-high { background: #f59e0b30; color: #f59e0b; }
.priority-medium { background: #22c55e30; color: #22c55e; }
.priority-low { background: #64748b30; color: #64748b; }

/* ============ LOGIN PAGE ============ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-card input {
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  text-align: center;
}

.login-error {
  color: var(--danger);
  font-size: 0.875rem;
}

/* ============ ACCOUNT PAGE ============ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.75rem;
}

.score-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
}

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

.score-main {
  text-align: center;
}

.score-number {
  font-size: 4rem;
  font-weight: 700;
}

.score-grade {
  font-size: 1.5rem;
  margin-top: 0.5rem;
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.breakdown-item {
  background: var(--bg);
  padding: 1rem;
  border-radius: 8px;
}

.breakdown-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.breakdown-value {
  font-size: 1.25rem;
  font-weight: 600;
}

.breakdown-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
}

/* ============ RECOMMENDATIONS ============ */
.recommendations-section {
  margin-top: 2rem;
}

.recommendations-section h2 {
  margin-bottom: 1rem;
}

.recommendations-filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.recommendations-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recommendation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.recommendation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.recommendation-title {
  font-size: 1rem;
  font-weight: 600;
}

.recommendation-category {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.recommendation-body {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.recommendation-action {
  background: var(--bg);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.recommendation-action-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.recommendation-impact {
  font-size: 0.875rem;
  color: var(--success);
}

.recommendation-footer {
  display: flex;
  gap: 0.5rem;
}

/* ============ STATUS ============ */
.status-running {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .add-form {
    flex-direction: column;
  }

  .form-group {
    width: 100%;
  }

  .accounts-grid {
    grid-template-columns: 1fr;
  }

  .score-header {
    flex-direction: column;
    text-align: center;
  }
}

/* ============ FLOW STATS ============ */
.flow-stats-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.flow-stats-section h2 {
  margin-bottom: 1rem;
}

.flow-stats-header {
  margin-bottom: 1rem;
}

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

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.stats-table th,
.stats-table td {
  padding: 0.75rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.stats-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-table tbody tr:hover {
  background: var(--bg-hover);
}

.status-live {
  color: var(--success);
}

.status-draft {
  color: var(--text-muted);
}

.rate-good {
  color: var(--success);
  font-weight: 600;
}

.rate-ok {
  color: var(--warning);
}

.rate-bad {
  color: var(--danger);
}

.flow-stats-legend .rate-good,
.flow-stats-legend .rate-ok,
.flow-stats-legend .rate-bad {
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.7rem;
}

.flow-stats-legend .rate-good {
  background: rgba(34, 197, 94, 0.2);
}

.flow-stats-legend .rate-ok {
  background: rgba(245, 158, 11, 0.2);
}

.flow-stats-legend .rate-bad {
  background: rgba(239, 68, 68, 0.2);
}
