/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* === Header === */
.header,
.site-header {
  background: var(--gray-900);
  color: white;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
.header .brand,
.site-header .brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header .brand:hover,
.site-header .brand:hover {
  text-decoration: none;
}
.site-nav {
  display: flex;
  gap: 1.5rem;
}
.site-nav a {
  color: var(--gray-300);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}
.site-nav a:hover {
  color: white;
  text-decoration: none;
}

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--gray-400);
  font-size: 0.8rem;
  margin-top: 3rem;
  border-top: 1px solid var(--gray-200);
}

/* === Admin Nav === */
.admin-nav {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
  overflow-x: auto;
}
.admin-nav a {
  padding: 0.75rem 1rem;
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.admin-nav a:hover {
  color: var(--primary);
  text-decoration: none;
}
.admin-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* === Main Content === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.container-narrow {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* === Flash Messages === */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.flash-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #bbf7d0;
}
.flash-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}
.flash-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid #fde68a;
}

/* === Cards === */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-header {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--gray-800);
}

/* === Stats Cards === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: 1.25rem;
  text-align: center;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
}
.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* === Tables === */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
th a {
  color: inherit;
}
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tr:hover {
  background: var(--gray-50);
}

/* === Badges === */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-active {
  background: var(--success-light);
  color: var(--success);
}
.badge-pending {
  background: var(--warning-light);
  color: var(--warning);
}
.badge-suspended {
  background: var(--danger-light);
  color: var(--danger);
}
.badge-latest {
  background: var(--primary-light);
  color: var(--primary);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.5;
}
.btn:hover {
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  background: #15803d;
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #b91c1c;
}
.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover {
  background: #b45309;
}
.btn-outline {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}
.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

/* === Forms === */
.form-group {
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.15s ease;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-textarea {
  resize: vertical;
  min-height: 80px;
}
.form-inline {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-inline .form-group {
  margin-bottom: 0;
}

/* === Portfolio Display === */
.portfolio-total {
  text-align: center;
  padding: 2rem 1rem;
}
.portfolio-total .amount {
  font-size: 3rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.1;
}
.portfolio-total .currency-label {
  font-size: 1rem;
  color: var(--gray-500);
  margin-top: 0.5rem;
}

/* === Device Info Card === */
.device-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.device-info .info-item {
  display: flex;
  flex-direction: column;
}
.device-info .info-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.device-info .info-value {
  font-size: 0.9rem;
  color: var(--gray-800);
  font-weight: 500;
  margin-top: 0.125rem;
}

/* === Hero Section === */
.hero {
  text-align: center;
  padding: 4rem 1rem;
  background: linear-gradient(135deg, var(--gray-900), var(--gray-800));
  color: white;
  margin: -1.5rem -1.5rem 2rem -1.5rem;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
}
.hero p {
  font-size: 1.125rem;
  color: var(--gray-300);
  max-width: 600px;
  margin: 0 auto;
}

/* === Features Grid === */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.feature-card {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.feature-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--gray-800);
}
.feature-card p {
  font-size: 0.875rem;
  color: var(--gray-600);
}

/* === Steps === */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
  text-align: center;
}
.step {
  padding: 1.5rem;
}
.step .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.step h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.step p {
  font-size: 0.875rem;
  color: var(--gray-600);
}

/* === Frame Mockup === */
.frame-mockup {
  width: 100%;
  max-width: 400px;
  height: 250px;
  margin: 2rem auto;
  background: var(--gray-100);
  border: 3px solid var(--gray-300);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 1.25rem;
  font-weight: 500;
}

/* === Token Display === */
.token-display {
  background: var(--warning-light);
  border: 2px solid var(--warning);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  text-align: center;
}
.token-display .token-value {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gray-900);
}
.token-display .token-warning {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 0.5rem;
  font-weight: 600;
}

/* === Actions Row === */
.actions-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

/* === Login Form === */
.login-card {
  max-width: 400px;
  margin: 4rem auto;
}
.login-card h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

/* === Section Headers === */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--gray-400);
  font-size: 0.8rem;
  margin-top: 3rem;
  border-top: 1px solid var(--gray-200);
}

/* === Utilities === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mono { font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.hidden { display: none !important; }

/* === Responsive === */
@media (max-width: 768px) {
  .container { padding: 1rem; }
  .hero { padding: 2.5rem 1rem; margin: -1rem -1rem 1.5rem -1rem; }
  .hero h1 { font-size: 1.75rem; }
  .portfolio-total .amount { font-size: 2rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-nav { padding: 0 0.5rem; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .actions-row { flex-direction: column; }
  .actions-row .btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.5rem; }
  table { font-size: 0.8rem; }
  th, td { padding: 0.5rem; }
}
