/* ==========================================================================
   YANDY Quota Workspace - Modern Clean White/Light Theme
   Inspired by PriceAI (priceai.cc) design language:
   - Clean slate-50/white backgrounds (#f8fafc, #ffffff)
   - Subtle borders (#e2e8f0, #eef1f1), soft modern shadows
   - Razor-sharp typography (Inter / SF Mono), high contrast dark slate text
   - Emerald teal (#059669) & Sky blue (#0284c7) FinTech accents
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --bg-card-hover: #f8fafc;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-strong: #059669;

  --text-main: #0f172a;
  --text-body: #1e293b;
  --text-sub: #475569;
  --text-dim: #64748b;
  --text-faint: #94a3b8;

  --primary: #059669;
  --primary-hover: #047857;
  --primary-bg: #ecfdf5;
  --primary-border: #a7f3d0;

  --cyan: #0284c7;
  --cyan-bg: #f0f9ff;
  --cyan-border: #bae6fd;

  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;

  --green: #10b981;
  --green-bg: #ecfdf5;
  --green-border: #a7f3d0;

  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;

  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;

  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --purple-border: #ddd6fe;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", Consolas, "JetBrains Mono", Menlo, monospace;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 14px 0 rgba(0, 0, 0, 0.06);
}

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

html, body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: block;
  width: 100%;
}

/* Main Container (Full Width with Max-Width) */
.main {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px 32px 48px 32px;
}

/* ==========================================================================
   Header Topbar
   ========================================================================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-img {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.2);
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-row h1 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.badge-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  font-weight: 600;
}

.brand-badge {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-card-alt);
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  font-weight: 500;
}

.header-titles p {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.clock-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-sub);
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
}

.clock-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.btn-action {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-body);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.btn-action:hover {
  background: var(--bg-card-alt);
  border-color: #cbd5e1;
  color: var(--text-main);
}

.btn-action.active,
.btn-action.btn-refresh {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

.btn-action.btn-refresh:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

/* ==========================================================================
   Hero KPIs (4 Clean Cards)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 132px;
  box-shadow: var(--shadow-md);
  transition: all 0.15s ease;
}

.kpi-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-lg);
}

.kpi-card.highlight {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(5, 150, 105, 0.1);
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.kpi-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 600;
}

.kpi-badge.cyan { background: var(--cyan-bg); color: var(--cyan); border: 1px solid var(--cyan-border); }
.kpi-badge.green { background: var(--green-bg); color: var(--primary); border: 1px solid var(--green-border); }
.kpi-badge.purple { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }
.kpi-badge.amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.kpi-subval {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 500;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  margin: 10px 0 8px 0;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.cyan { background: var(--cyan); }
.progress-fill.green { background: var(--primary); }
.progress-fill.purple { background: var(--purple); }
.progress-fill.amber { background: var(--amber); }
.progress-fill.red { background: var(--red); }

.kpi-footer {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   Two Column Layout (Ranking Table + Donut & Alerts)
   ========================================================================== */
.layout-split {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  margin-bottom: 24px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title .sub {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 400;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-input {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  width: 170px;
  transition: all 0.15s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.seg-control {
  display: flex;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}

.seg-btn.active {
  background: #ffffff;
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Key Usage Ranking Table (PriceAI White Table Aesthetics)
   ========================================================================== */
.table-scroll {
  overflow-x: auto;
  flex: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

thead th {
  background: #f8fafc;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-body);
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover td {
  background: #f8fafc;
}

/* Rank Badges */
.rank-badge {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  text-align: center;
  line-height: 22px;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--font-mono);
}

.rank-1 { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.rank-2 { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.rank-3 { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.rank-n { color: var(--text-faint); font-weight: 500; }

.user-cell {
  display: flex;
  align-items: center;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
}

.user-meta {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.bar-cell {
  width: 140px;
}

.share-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-track {
  flex: 1;
  height: 6px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
}

.share-fill {
  height: 100%;
  border-radius: 3px;
}

.share-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.num-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.status-pill {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 5px;
  font-weight: 600;
  display: inline-block;
}

.status-pill.active {
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.status-pill.idle {
  background: var(--bg-card-alt);
  color: var(--text-faint);
  border: 1px solid var(--border);
}

/* ==========================================================================
   Right Column (Donut Chart & Alerts)
   ========================================================================== */
.right-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Donut Chart */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
}

.donut-svg-box {
  width: 154px;
  height: 154px;
  position: relative;
}

.donut-svg-box svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-center-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-center-text .num {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.donut-center-text .lbl {
  font-size: 11px;
  color: var(--text-dim);
}

.donut-legend-list {
  width: 100%;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-color {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

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

.legend-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

/* Risk Alerts */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.alert-item {
  display: flex;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.alert-item.bad {
  border-color: var(--red-border);
  background: var(--red-bg);
}

.alert-item.warn {
  border-color: var(--amber-border);
  background: var(--amber-bg);
}

.alert-item.good {
  border-color: var(--green-border);
  background: var(--green-bg);
}

.alert-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.alert-item.bad .alert-icon { background: #fee2e2; color: var(--red); }
.alert-item.warn .alert-icon { background: #fef3c7; color: var(--amber); }
.alert-item.good .alert-icon { background: #d1fae5; color: var(--primary); }

.alert-content {
  display: flex;
  flex-direction: column;
}

.alert-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.alert-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ==========================================================================
   Account Cards Grid (10 Accounts)
   ========================================================================== */
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 26px 0 14px 0;
}

.section-heading h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.acc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.acc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.acc-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.acc-card.offline {
  border-color: var(--red-border);
  background: #fffcfc;
  opacity: 0.88;
}

.acc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.acc-id-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.acc-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-card-alt);
  color: var(--primary);
  font-weight: 700;
  font-size: 11px;
  font-family: var(--font-mono);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
}

.acc-email {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.acc-status {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 600;
}

.acc-status.good { background: var(--green-bg); color: var(--primary); border: 1px solid var(--green-border); }
.acc-status.bad { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.acc-status.warn { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }

.acc-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.acc-metric-col {
  display: flex;
  flex-direction: column;
}

.acc-metric-lbl {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
}

.acc-metric-val {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

.acc-metric-val.bad { color: var(--red); }
.acc-metric-val.warn { color: var(--amber); }

.acc-progress-track {
  width: 100%;
  height: 5px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 5px;
}

.acc-progress-fill {
  height: 100%;
  border-radius: 3px;
}

.acc-progress-fill.cyan { background: var(--cyan); }
.acc-progress-fill.green { background: var(--primary); }
.acc-progress-fill.red { background: var(--red); }

.acc-reset-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

.acc-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--text-dim);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .layout-split { grid-template-columns: 1fr; }
  .acc-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .main { padding: 14px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .top-actions { width: 100%; justify-content: space-between; }
  .kpi-grid { grid-template-columns: 1fr; }
  .acc-grid { grid-template-columns: 1fr; }
}
