/* ── EC Brand tokens ─────────────────────────────────────────────────────────── */
:root {
  --ec-orange:      #FF6F42;
  --ec-orange-tint: #FFF0EB;
  --ec-navy:        #1a1a1a;
  --body-text:      #1a1f2e;
  --secondary-text: #6b7280;
  --light-bg:       #f7f8fa;
  --border:         #eaecf0;
  --white:          #ffffff;
  --green:          #10b981;
  --green-light:    #ecfdf5;
  --amber:          #f59e0b;
  --amber-light:    #fffbeb;
  --red:            #ef4444;
  --red-light:      #fef2f2;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--light-bg);
  color: var(--body-text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
header {
  background: var(--ec-navy);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  text-decoration: none;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
}

.header-title {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.header-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-nav a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}

.header-nav a:hover { color: #fff; }

.header-user {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
}

/* ── Main layout ─────────────────────────────────────────────────────────────── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Hero metric ─────────────────────────────────────────────────────────────── */
.hero {
  background: var(--ec-navy);
  border-radius: 12px;
  padding: 32px 40px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 48px;
  margin-bottom: 24px;
}

.hero-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ec-orange);
  margin-bottom: 8px;
}

.hero-title {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 16px;
}

.hero-numbers {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.hero-current {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
}

.hero-vs {
  font-size: 14px;
  color: rgba(255,255,255,0.4);
}

.hero-target {
  font-size: 32px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
}

.hero-progress-wrap {
  flex: 1;
}

.hero-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

.hero-progress-bar {
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.hero-progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--ec-orange);
  transition: width 0.6s ease;
}

.hero-delta {
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
}

.hero-delta.on-target  { color: var(--green); }
.hero-delta.near-target { color: var(--amber); }
.hero-delta.off-target  { color: var(--red); }

/* ── Period selector ─────────────────────────────────────────────────────────── */
.period-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  width: fit-content;
}

.period-btn {
  padding: 6px 16px;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--secondary-text);
  cursor: pointer;
  transition: all 0.15s;
}

.period-btn:hover { background: var(--light-bg); color: var(--body-text); }

.period-btn.active {
  background: var(--ec-orange);
  color: #fff;
}

/* ── Section grid ────────────────────────────────────────────────────────────── */
.sections-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

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

.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--secondary-text);
}

.card-link {
  font-size: 12px;
  color: var(--ec-orange);
  text-decoration: none;
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Metric rows ─────────────────────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.metrics.three-col { grid-template-columns: repeat(3, 1fr); }
.metrics.one-col   { grid-template-columns: 1fr; }

.metric {
  padding: 12px;
  background: var(--light-bg);
  border-radius: 8px;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary-text);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--body-text);
  line-height: 1;
}

.metric-value.large { font-size: 30px; }

.metric-change {
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
}

.metric-change.up    { color: var(--green); }
.metric-change.down  { color: var(--red); }
.metric-change.flat  { color: var(--secondary-text); }

.metric-sub {
  font-size: 11px;
  color: var(--secondary-text);
  margin-top: 2px;
}

/* ── No-data state ───────────────────────────────────────────────────────────── */
.no-data {
  color: var(--secondary-text);
  font-size: 13px;
  font-style: italic;
  padding: 12px 0;
}

/* ── Article list ────────────────────────────────────────────────────────────── */
.article-list { display: flex; flex-direction: column; gap: 10px; }

.article-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--light-bg);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.article-rating {
  font-size: 16px;
  flex-shrink: 0;
}

.article-info { flex: 1; width: 0; min-width: 0; overflow: hidden; }

.article-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--body-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-meta {
  font-size: 11px;
  color: var(--secondary-text);
  margin-top: 2px;
}

.article-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  width: 160px;
  gap: 3px;
}

.article-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--ec-orange);
}

.article-stats {
  font-size: 11px;
  color: var(--secondary-text);
  white-space: nowrap;
}

.provisional-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--secondary-text);
  background: var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.2px;
  vertical-align: middle;
}

/* ── Newsletter list ─────────────────────────────────────────────────────────── */
.nl-list { display: flex; flex-direction: column; gap: 8px; }

.nl-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--light-bg);
  border-radius: 6px;
  font-size: 13px;
}

.nl-name { color: var(--body-text); font-weight: 500; }
.nl-count { font-weight: 700; color: var(--body-text); }

/* ── Chart container ─────────────────────────────────────────────────────────── */
.chart-wrap {
  height: 140px;
  margin-top: 16px;
}

/* ── Status indicators ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green  { background: var(--green-light); color: var(--green); }
.badge-amber  { background: var(--amber-light); color: var(--amber); }
.badge-red    { background: var(--red-light);   color: var(--red);   }

/* ── Loading state ───────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  color: var(--secondary-text);
  font-size: 13px;
}

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light-bg);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 22px;
  font-weight: 700;
  color: var(--body-text);
  margin-bottom: 4px;
}

.login-desc {
  font-size: 14px;
  color: var(--secondary-text);
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--body-text);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus { border-color: var(--ec-orange); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--ec-orange);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 8px;
}

.btn-primary:hover    { background: #e55a2b; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.form-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

.form-info {
  color: var(--secondary-text);
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
}

.otp-hint {
  background: var(--ec-orange-tint);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ec-orange);
  margin-bottom: 16px;
  font-weight: 500;
}

/* ── Admin layout ────────────────────────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.card-form .form-group { margin-bottom: 14px; }

.btn-secondary {
  padding: 8px 16px;
  background: var(--white);
  color: var(--body-text);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover { border-color: var(--ec-orange); color: var(--ec-orange); }

.btn-danger {
  padding: 4px 10px;
  background: none;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

.user-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--light-bg);
  border-radius: 6px;
  font-size: 13px;
}

.sync-status-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sync-status-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--light-bg);
  color: var(--secondary-text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sync-status-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.sync-status-table tr:last-child td { border-bottom: none; }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--secondary-text);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab-btn:hover  { color: var(--body-text); }
.tab-btn.active { color: var(--ec-orange); border-bottom-color: var(--ec-orange); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Drag & drop upload ───────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--light-bg);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--ec-orange);
  background: var(--ec-orange-tint);
}

.drop-zone input[type="file"] {
  display: none;
}

.drop-zone-icon  { font-size: 28px; margin-bottom: 8px; }
.drop-zone-title { font-weight: 600; font-size: 14px; color: var(--body-text); margin-bottom: 4px; }
.drop-zone-sub   { font-size: 12px; color: var(--secondary-text); }
.drop-zone-file  { margin-top: 8px; font-size: 12px; color: var(--ec-orange); font-weight: 500; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  header { padding: 0 16px; }
  main   { padding: 16px; }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    padding: 24px;
  }

  .hero-current { font-size: 40px; }

  .sections-grid { grid-template-columns: 1fr; }
  .admin-grid    { grid-template-columns: 1fr; }
  .metrics       { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr; }
}
