/*
 * AlphaESS Portal — My Reward Points (v2)
 * 参考真实 portal.alphaess.com 视觉规范：
 *   - 左侧导航 + 顶部搜索栏 + 右上用户/区域/语言/铃铛
 *   - 主色 AlphaESS 黄
 *   - 辅色 绿（正常 / 数据强调）
 *   - 卡片：白底 + 浅灰背景 + 大圆角
 */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css');

:root {
  /* AlphaESS brand */
  --y: #F5C516;          /* primary yellow (按钮/logo accent) */
  --y-dark: #E5B30D;     /* hover */
  --y-pale: #FEF7D6;     /* tag bg */
  --y-l: rgba(245,197,22,.12);

  --g: #22C55E;          /* success green (Normal / 装机/自给) */
  --g-dark: #16A34A;
  --g-pale: #DCFCE7;
  --g-l: rgba(34,197,94,.12);

  --r: #EF4444;          /* error red (Fault) */
  --r-pale: #FEE2E2;

  --o: #F59E0B;          /* warn orange (装机功率/Protection) */
  --o-pale: #FFEDD5;

  --b: #3B82F6;          /* info blue */
  --b-pale: #DBEAFE;

  --p: #8B5CF6;
  --p-pale: #EDE9FE;

  /* Surfaces */
  --bg: #F4F5F7;
  --white: #FFFFFF;
  --surface2: #F9FAFB;

  /* Text */
  --t1: #1F2937;
  --t2: #6B7280;
  --t3: #9CA3AF;

  --border: #E5E7EB;
  --border-soft: #F3F4F6;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.10);

  /* Geometry */
  --radius: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --sidebar-w: 240px;
  --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--t1);
  line-height: 1.5;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ═══════════════════════════════════════════════════════════
   LAYOUT — sidebar + main
   ═══════════════════════════════════════════════════════════ */
.app {
  display: flex; min-height: 100vh;
}

/* ═══ SIDEBAR ═══════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  height: var(--header-h);
  padding: 0 24px;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--y), var(--y-dark));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 18px;
  flex-shrink: 0; margin-right: 10px;
  box-shadow: 0 2px 6px rgba(245,197,22,.4);
}
.sidebar-logo-text {
  font-size: 16px; font-weight: 700; color: var(--t1);
  line-height: 1.1;
}
.sidebar-logo-sub {
  font-size: 10px; color: var(--t3); margin-top: 2px;
  letter-spacing: .04em;
}

.sidebar-nav {
  padding: 12px 12px;
  flex: 1;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
  color: var(--t2); font-size: 13px; font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--surface2); color: var(--t1); }
.sidebar-nav a.active {
  background: var(--y-l); color: var(--y-dark); font-weight: 600;
}
.sidebar-nav a.active i { color: var(--y-dark); }
.sidebar-nav a i {
  width: 16px; text-align: center; font-size: 14px; color: var(--t3);
}
.sidebar-nav .nav-divider {
  height: 1px; background: var(--border); margin: 12px 14px;
}
.sidebar-nav .nav-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--t3); font-weight: 600;
  padding: 14px 14px 8px;
}

/* ═══ MAIN AREA ═════════════════════════════════════════════ */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

/* ═══ TOP HEADER ════════════════════════════════════════════ */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex; align-items: center; gap: 24px;
  position: sticky; top: 0; z-index: 100;
}
.search-box {
  flex: 1; max-width: 600px;
  position: relative;
}
.search-box i {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--t3); font-size: 14px;
}
.search-box input {
  width: 100%; height: 40px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 999px;
  padding: 0 16px 0 44px;
  font-size: 13px; color: var(--t1);
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
.search-box input::placeholder { color: var(--t3); }
.search-box input:focus {
  outline: none; border-color: var(--y); background: white;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex; align-items: center; gap: 8px;
}
.tb-btn {
  height: 40px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 10px; color: var(--t2);
  font-size: 13px; transition: background .15s;
}
.tb-btn:hover { background: var(--surface2); color: var(--t1); }
.tb-btn i { font-size: 16px; }
.tb-icon {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; color: var(--t2);
  position: relative; transition: background .15s;
}
.tb-icon:hover { background: var(--surface2); color: var(--t1); }
.tb-icon i { font-size: 16px; }
.tb-icon .dot {
  position: absolute; top: 8px; right: 10px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--r); border: 2px solid white;
}

.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--y), var(--y-dark));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px;
  flex-shrink: 0; cursor: pointer;
}

/* ═══ PAGE CONTENT ══════════════════════════════════════════ */
.content {
  padding: 24px 32px;
  flex: 1;
}
.page-title-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-title {
  font-size: 22px; font-weight: 700; color: var(--t1);
}
.page-subtitle {
  font-size: 13px; color: var(--t2); margin-top: 4px;
}

/* Sub-tab nav within page */
.subtabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.subtabs a {
  padding: 12px 20px;
  font-size: 13px; font-weight: 500;
  color: var(--t2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.subtabs a:hover { color: var(--t1); }
.subtabs a.active {
  color: var(--y-dark); font-weight: 600;
  border-bottom-color: var(--y);
}

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

/* ═══ BUTTONS ═══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity .15s, background .15s; font-family: inherit;
  white-space: nowrap;
}
.btn:active { opacity: .85; }
.btn-primary {
  background: var(--y); color: #5C4500;
}
.btn-primary:hover { background: var(--y-dark); }
.btn-ghost {
  background: white; color: var(--t1);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--t2); background: var(--surface2); }
.btn-link { color: var(--y-dark); padding: 6px 0; font-weight: 600; }
.btn-link:hover { color: var(--t1); }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ═══ BADGES ════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge-yellow { background: var(--y-pale); color: #92590A; }
.badge-green { background: var(--g-pale); color: var(--g-dark); }
.badge-blue { background: var(--b-pale); color: #1E40AF; }
.badge-orange { background: var(--o-pale); color: #92400E; }
.badge-red { background: var(--r-pale); color: #991B1B; }
.badge-purple { background: var(--p-pale); color: #5B21B6; }
.badge-gray { background: var(--surface2); color: var(--t2); }

/* ═══ TIER PILL ═════════════════════════════════════════════ */
.tier-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 11px;
  padding: 4px 12px; border-radius: 999px;
  letter-spacing: .04em;
}
.tier-pill.t1 { background: linear-gradient(135deg, #FCD34D, #F59E0B); color: #78350F; }
.tier-pill.t2 { background: linear-gradient(135deg, #E5E7EB, #9CA3AF); color: #1F2937; }
.tier-pill.t3 { background: linear-gradient(135deg, #FCA5A5, #F87171); color: #7F1D1D; }
.tier-pill i { font-size: 10px; }

/* ═══ FORM ══════════════════════════════════════════════════ */
.form-input, .form-select {
  width: 100%; height: 40px;
  border: 1px solid var(--border); background: white;
  border-radius: 10px; padding: 0 14px;
  font-size: 13px; color: var(--t1); font-family: inherit;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--y);
  box-shadow: 0 0 0 3px var(--y-l);
}

/* ═══ TABLE ═════════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--t2); padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface2);
}
.data-table td {
  padding: 14px 16px; font-size: 13px; color: var(--t1);
  border-bottom: 1px solid var(--border-soft);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

/* ═══ MODAL ═════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-overlay { display: none; }
.modal-overlay.show { display: flex; }
.modal {
  background: white; border-radius: 18px;
  width: 480px; max-width: 92vw;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-header {
  padding: 20px 28px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--t1); }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--t2); font-size: 16px;
  background: var(--surface2); transition: background .15s;
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 24px 28px; }
.modal-footer {
  padding: 16px 28px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ═══ ALERT ═════════════════════════════════════════════════ */
.alert {
  border-radius: 12px; padding: 14px 18px;
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 13px; line-height: 1.6;
}
.alert i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-info { background: var(--b-pale); color: #1E40AF; }
.alert-warning { background: var(--o-pale); color: #92400E; }
.alert-success { background: var(--g-pale); color: var(--g-dark); }
.alert-soft { background: var(--surface2); color: var(--t2); border: 1px solid var(--border); }

/* ═══ UTILITIES ════════════════════════════════════════════ */
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.text-t2 { color: var(--t2); }
.text-t3 { color: var(--t3); }
.text-y { color: var(--y-dark); }
.text-g { color: var(--g-dark); }
.text-r { color: var(--r); }

/* ═══ RESPONSIVE ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 64px; }
  .sidebar-logo-text, .sidebar-logo-sub, .sidebar-nav a span, .sidebar-nav .nav-section { display: none; }
  .sidebar-nav a { justify-content: center; padding: 10px; }
  .sidebar-logo { padding: 0; justify-content: center; }
  .sidebar-logo-icon { margin-right: 0; }
  .content { padding: 20px; }
  .topbar { padding: 0 20px; }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .search-box { display: none; }
  .content { padding: 16px; }
}

/* ═══════════════════════════════════════════════════════════
   ADMIN-only additions
   ═══════════════════════════════════════════════════════════ */

/* Admin badge in topbar */
.admin-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  background: #1F2937; color: var(--y); text-transform: uppercase;
}

/* Role pill (in user area) */
.role-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  background: var(--p-pale); color: #5B21B6;
  text-transform: uppercase;
}
.role-pill.sku-admin { background: var(--y-pale); color: #92590A; }
.role-pill.ops-reviewer { background: var(--p-pale); color: #5B21B6; }
.role-pill.ops-submitter { background: var(--b-pale); color: #1E40AF; }
.role-pill.fulfillment { background: var(--g-pale); color: var(--g-dark); }
.role-pill.finance { background: var(--surface2); color: var(--t2); }

/* KPI row (admin dashboard style — denser) */
.kpi-grid-6 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1100px) { .kpi-grid-6 { grid-template-columns: repeat(2, 1fr); } }

/* Data toolbar */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: white; border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.toolbar-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* Inline form select (compact) */
.select-sm {
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: white; font-size: 12px; color: var(--t1); font-family: inherit;
  min-width: 120px;
}

/* Stat tile (compact) */
.stat-tile {
  background: white; border-radius: var(--radius);
  padding: 16px 20px; box-shadow: var(--shadow-sm);
}
.stat-tile-label { font-size: 11px; color: var(--t2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 6px; }
.stat-tile-val { font-size: 24px; font-weight: 700; color: var(--t1); letter-spacing: -.5px; }
.stat-tile-val.y { color: var(--y-dark); }
.stat-tile-val.g { color: var(--g-dark); }
.stat-tile-val.r { color: var(--r); }
.stat-tile-val.p { color: #6D28D9; }
.stat-tile-val.b { color: var(--b); }
.stat-tile-foot { font-size: 11px; color: var(--t3); margin-top: 4px; }

/* Approval timeline */
.approval-tl { padding: 6px 0; }
.approval-step {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
}
.approval-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 11px; color: white;
}
.approval-dot.done { background: var(--g-dark); }
.approval-dot.active { background: var(--o); animation: pulse 2s infinite; }
.approval-dot.pending { background: var(--border); color: var(--t3); }
.approval-dot.rejected { background: var(--r); }
.approval-content { flex: 1; }
.approval-title { font-size: 13px; font-weight: 600; color: var(--t1); }
.approval-sub { font-size: 12px; color: var(--t2); margin-top: 2px; }
.approval-time { font-size: 11px; color: var(--t3); }

/* Big progress bar */
.bp-bar {
  height: 16px; background: var(--border-soft);
  border-radius: 999px; overflow: hidden;
  position: relative; display: flex;
}
.bp-seg { height: 100%; transition: width .4s; }
.bp-seg.green { background: var(--g-dark); }
.bp-seg.purple { background: #8B5CF6; }
.bp-seg.orange { background: var(--o); }
.bp-seg.red { background: var(--r); }
