/* UIN Wise Settlement & Accumulation Dashboard — KseAlert website */

body.kse-uin-page {
  background: #f0f4f9;
}

.kse-uin-page .site-main {
  padding-bottom: 48px;
}

.usd-root {
  min-height: 360px;
}

.usd-loading,
.usd-empty {
  padding: 48px 16px;
  text-align: center;
  color: #64748b;
  font-size: 15px;
}

.usd-mock-badge {
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 4px 10px;
  border-radius: 999px;
  margin-left: auto;
}

/* KPI row */
.usd-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.usd-kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.usd-kpi-card--accent {
  border-top: 3px solid #059669;
}

.usd-kpi-card--warn {
  border-top: 3px solid #d97706;
}

.usd-kpi-card--blue {
  border-top: 3px solid #2563eb;
}

.usd-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 8px;
}

.usd-kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.usd-kpi-sub {
  margin-top: 6px;
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.usd-kpi-sub strong {
  color: #059669;
}

/* Main grid */
.usd-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 18px;
  align-items: start;
}

.usd-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.usd-panel-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.usd-panel-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}

.usd-panel-desc {
  margin: 0;
  font-size: 12px;
  color: #64748b;
}

/* Screener toolbar */
.usd-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.usd-search {
  flex: 1 1 180px;
  min-width: 140px;
  padding: 9px 12px 9px 36px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 13px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.156a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E") no-repeat 12px center;
}

.usd-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.usd-filter-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
}

.usd-filter-btn.is-active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

/* Sort chip row */
.usd-sort-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.usd-sort-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-right: 4px;
}

.usd-sort-chip {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
}

.usd-sort-chip.is-active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

/* Row badges — deviation & behavior */
.usd-row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.usd-dev-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.usd-dev-badge--up {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.usd-dev-badge--down {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.usd-behavior-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.usd-behavior-badge--spec {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.usd-behavior-badge--inst {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

/* Table */
.usd-table-wrap {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
}

.usd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.usd-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
}

.usd-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.usd-table th:hover {
  color: #0f172a;
}

.usd-table th.usd-sort-asc::after {
  content: " \25B2";
  font-size: 9px;
}

.usd-table th.usd-sort-desc::after {
  content: " \25BC";
  font-size: 9px;
}

.usd-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.usd-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.usd-table tbody tr:hover {
  background: #f8fafc;
}

.usd-table tbody tr.is-selected {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 #2563eb;
}

.usd-sym {
  font-weight: 800;
  color: #2563eb;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.35);
  text-underline-offset: 2px;
}

.usd-table tbody tr {
  cursor: pointer;
}

.usd-sym-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  margin-top: 2px;
}

.usd-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.usd-price {
  font-weight: 700;
  color: #0f172a;
}

/* Delivery bar in table */
.usd-del-cell {
  min-width: 120px;
}

.usd-del-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.usd-del-bar {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.usd-del-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.2s ease;
}

.usd-del-fill--high { background: linear-gradient(90deg, #059669, #10b981); }
.usd-del-fill--mid { background: linear-gradient(90deg, #d97706, #fbbf24); }
.usd-del-fill--low { background: linear-gradient(90deg, #dc2626, #f87171); }

.usd-del-pct {
  font-size: 12px;
  font-weight: 700;
  min-width: 42px;
  text-align: right;
}

.usd-del-pct--high { color: #059669; }
.usd-del-pct--mid { color: #d97706; }
.usd-del-pct--low { color: #dc2626; }

/* Chart panel */
.usd-chart-body {
  padding: 12px 16px 16px;
}

.usd-chart-title {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 12px;
}

.usd-chart-wrap {
  position: relative;
  background: #fafbfc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  min-height: 300px;
}

.usd-chart-wrap canvas {
  display: block;
  width: 100%;
}

.usd-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: #475569;
}

.usd-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.usd-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.usd-chart-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  max-width: 220px;
}

.usd-chart-tooltip strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
}

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

  .usd-kpi-row {
    grid-template-columns: 1fr;
  }

  .usd-table-wrap {
    max-height: 400px;
  }
}
