/*
 * Spiring MyAccount V3 – Design System
 * V2 colors + DM Sans + V1 top-nav layout + responsive
 */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css');

:root {
  /* Brand colors from V2 */
  --green: #1A7A4A;
  --green-light: #22A65E;
  --green-pale: #D1FAE5;
  --green-l: rgba(26,122,74,.10);

  --blue: #3B82F6;
  --blue-pale: #DBEAFE;
  --orange: #F59E0B;
  --orange-pale: #FEF3C7;
  --orange-l: rgba(245,158,11,.10);
  --red: #EF4444;
  --red-pale: #FEE2E2;
  --teal: #01A6C9;
  --teal-l: rgba(1,166,201,.10);
  --purple: #8B5CF6;
  --purple-pale: #EDE9FE;

  /* Surfaces */
  --bg: #F0F2F5;
  --white: #FFFFFF;
  --header-bg: #0F1A14;
  --t1: #111827;
  --t2: #6B7280;
  --t3: #9CA3AF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --surface2: #F9FAFB;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --radius: 12px;
  --radius-sm: 8px;

  /* Layout */
  --px: 20px;
  --px-d: 40px;
  --max: 1040px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--t1);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ═══ SITE HEADER (dark, top) ═══════════════════════════════ */
.site-header {
  position: sticky; top: 0; z-index: 500;
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.site-header-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 0 var(--px);
  height: 60px;
  display: flex; align-items: center;
}
@media (min-width: 768px) {
  .site-header-inner { padding: 0 var(--px-d); }
}

/* Logo */
.site-logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.site-logo-icon {
  height: 28px; flex-shrink: 0;
}
.site-logo-icon img { height: 100%; width: auto; display: block; }
.site-logo-text { font-size: 16px; font-weight: 700; color: white; }
.site-logo-sub { font-size: 9px; font-weight: 600; color: #6B7280; letter-spacing: .15em; }

/* Header nav */
.header-nav {
  display: flex; align-items: center;
  margin-left: 32px; gap: 4px;
}
.header-nav a {
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,.55);
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.header-nav a:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.06); }
.header-nav a.active { color: #6EE7A0; background: rgba(26,122,74,.15); font-weight: 600; }

/* User area */
.user-area {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}
.user-av {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--white);
  flex-shrink: 0;
}
.user-dropdown { position: relative; }
.user-dropdown-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,.8);
  cursor: pointer; padding: 4px 0;
}
.user-dropdown-toggle .caret {
  font-size: 10px; opacity: .6; transition: transform .2s;
}
.user-dropdown-toggle.open .caret { transform: rotate(180deg); }
.user-dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 160px; z-index: 600;
  overflow: hidden;
}
.user-dropdown-menu.open { display: block; }
.user-dropdown-menu a {
  display: block; padding: 10px 16px;
  font-size: 13px; color: var(--t1); transition: background .1s;
}
.user-dropdown-menu a:hover { background: var(--surface2); }
.user-dropdown-menu a + a { border-top: 1px solid var(--border); }

.user-name-inline { display: none; }
@media (min-width: 480px) { .user-name-inline { display: flex; } }

/* ═══ PAGE HEADER ═══════════════════════════════════════════ */
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 20px var(--px);
}
.page-header-inner {
  max-width: var(--max); margin: 0 auto;
  display: flex; justify-content: space-between;
  align-items: center; flex-wrap: wrap; gap: 12px;
}
@media (min-width: 768px) {
  .page-header { padding: 20px var(--px-d); }
}
.page-title { font-size: 20px; font-weight: 700; color: var(--t1); }
.page-subtitle { font-size: 13px; color: var(--t2); margin-top: 2px; }

.system-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-pale); border: 1px solid rgba(26,122,74,.2);
  border-radius: 20px; padding: 6px 14px;
  font-size: 12px; font-weight: 600; color: var(--green);
}

/* ═══ PAGE BODY ═════════════════════════════════════════════ */
.page {
  max-width: var(--max); margin: 0 auto;
  padding: 24px var(--px) 60px;
}
@media (min-width: 768px) {
  .page { padding: 32px var(--px-d) 48px; }
}

/* ═══ CARDS ═════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px; font-weight: 600; color: var(--t1); margin-bottom: 14px;
}
.card-eyebrow {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--t3); margin-bottom: 6px;
}

/* ═══ GRIDS ═════════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ═══ BADGES ════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green { background: var(--green-pale); color: var(--green); }
.badge-blue { background: var(--blue-pale); color: #1E40AF; }
.badge-amber { background: var(--orange-pale); color: #92400E; }
.badge-red { background: var(--red-pale); color: #991B1B; }
.badge-purple { background: var(--purple-pale); color: #4C1D95; }

/* ═══ BUTTONS ═══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity .15s; font-family: inherit;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--green); color: white; border: none; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: var(--white); color: var(--t1); border: 1.5px solid var(--border-strong); }
.btn-ghost:hover { border-color: var(--t2); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; }

/* ═══ STATUS DOT ════════════════════════════════════════════ */
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
}
.status-dot.online { background: var(--green); animation: pulse 2s infinite; }
.status-dot.warning { background: var(--orange); animation: pulse 2s infinite; }
.status-dot.offline { background: var(--red); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* ═══ FIELD ROWS ════════════════════════════════════════════ */
.frow {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.frow:first-child { border-top: 1px solid var(--border); }
.flabel {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--t3);
  min-width: 120px; flex-shrink: 0; padding-top: 2px;
}
.fvalue { font-size: 14px; color: var(--t1); }
.fvalue.muted { color: var(--t2); }
.fvalue.masked { letter-spacing: 2px; color: var(--t2); font-size: 13px; }
.fedit { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--green); cursor: pointer; flex-shrink: 0; }
.fedit:hover { opacity: .7; }

/* ═══ PAYMENT ROWS ══════════════════════════════════════════ */
.pay-list { margin-bottom: 24px; }
.pay-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.pay-row:first-child { border-top: 1px solid var(--border); }
.pay-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.pay-title { font-size: 14px; font-weight: 500; color: var(--t1); }
.pay-sub { font-size: 12px; color: var(--t2); margin-top: 2px; }
.pay-right { margin-left: auto; text-align: right; }
.pay-amt { font-size: 15px; font-weight: 700; }
.pay-status { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }

/* ═══ ALERTS ════════════════════════════════════════════════ */
.alert {
  border-radius: var(--radius-sm); padding: 12px 16px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 12px; line-height: 1.5;
}
.alert-info { background: var(--surface2); border: 1px solid var(--border); color: var(--t2); }
.alert-warning { background: var(--orange-pale); border: 1px solid #FCD34D; color: #92400E; }
.alert-success { background: var(--green-pale); border: 1px solid rgba(26,122,74,.2); color: var(--green); }
.alert i { flex-shrink: 0; margin-top: 1px; }

/* ═══ PROGRESS BAR ══════════════════════════════════════════ */
.progress-track {
  height: 8px; background: #F3F4F6; border-radius: 8px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 8px; transition: width .6s; }
.progress-fill.green { background: var(--green); }
.progress-fill.amber { background: var(--orange); }
.progress-fill.red { background: var(--red); }

/* ═══ PLAN TAGS ═════════════════════════════════════════════ */
.plan-tag { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.plan-tag.eco { background: #D1FAE5; color: #065F46; }
.plan-tag.core { background: #DBEAFE; color: #1E40AF; }
.plan-tag.max { background: #EDE9FE; color: #4C1D95; }

/* ═══ UTILS ═════════════════════════════════════════════════ */
.mono { font-family: 'DM Mono', monospace; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-t2 { color: var(--t2); }
.text-t3 { color: var(--t3); }
.text-green { color: var(--green); }

/* ═══ MOBILE NAV TOGGLE ═════════════════════════════════════ */
.mobile-nav-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  color: rgba(255,255,255,.8); font-size: 18px;
  cursor: pointer; margin-left: 12px;
  border-radius: var(--radius-sm);
}
.mobile-nav-toggle:hover { background: rgba(255,255,255,.06); }

@media (max-width: 640px) {
  .header-nav { display: none; }
  .header-nav.open {
    display: flex; flex-direction: column;
    position: absolute; top: 60px; left: 0; right: 0;
    background: var(--header-bg);
    border-bottom: 1px solid rgba(255,255,255,.06);
    padding: 8px 16px 16px;
    gap: 2px; z-index: 499;
  }
  .header-nav.open a {
    padding: 10px 12px;
    font-size: 14px;
  }
  .mobile-nav-toggle { display: flex; }
  .page-header { padding: 16px var(--px); }
  .page { padding: 16px var(--px) 48px; }
  .card { padding: 16px; }
}

/* ═══ TABLES ════════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--t3);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.data-table td {
  padding: 12px 14px; font-size: 13px; color: var(--t1);
  border-bottom: 1px solid #F9FAFB;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #FAFAFA; }

/* ═══ FORM FIELDS ═══════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label {
  font-size: 12px; font-weight: 600; color: var(--t2);
  margin-bottom: 6px; display: block;
}
.form-input {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--t1);
}
.form-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-pale); }
.form-input[readonly] { background: var(--surface2); color: var(--t2); }
.form-select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--t1); background: white;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ═══ MODAL ═════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white; border-radius: 16px;
  width: 500px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
}
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--t1); }
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; color: var(--t2);
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ═══ NAV DIVIDER (admin separator) ════════════════════════ */
.nav-divider {
  display: block; width: 1px; height: 20px;
  background: rgba(255,255,255,.12); margin: 0 8px; flex-shrink: 0;
}
.header-nav a.admin-link { color: rgba(245,158,11,.5); }
.header-nav a.admin-link:hover { color: rgba(245,158,11,.8); background: rgba(245,158,11,.08); }
.header-nav a.admin-link.active { color: #F59E0B; background: rgba(245,158,11,.12); }
