/* 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 layout */
.usd-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

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

.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;
}

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

.usd-search-wrap {
  flex: 1 1 200px;
  min-width: 160px;
  position: relative;
}

.usd-search-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  max-height: 280px;
  overflow-y: auto;
}

.usd-search-suggest-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
}

.usd-search-suggest-item:hover,
.usd-search-suggest-item:focus {
  background: #eff6ff;
  outline: none;
}

.usd-search-suggest-item strong {
  font-weight: 800;
  color: #2563eb;
  min-width: 52px;
}

.usd-search-suggest-item span {
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
}

.usd-sector-select {
  flex: 0 1 200px;
  min-width: 140px;
  max-width: 220px;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
  color: #0f172a;
}

.usd-filter-note {
  margin: 0;
  padding: 8px 18px 0;
  font-size: 12px;
  color: #64748b;
}

.usd-mock-row {
  display: flex;
  margin-bottom: 12px;
}

.usd-kpi-date {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
}

.usd-sym-cell {
  min-width: 120px;
}

.usd-sym-cell .usd-sym {
  display: inline;
  margin-right: 6px;
}

.usd-sector-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 6px;
  border-radius: 999px;
  margin-right: 4px;
  vertical-align: middle;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usd-unusual-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 2px 6px;
  border-radius: 999px;
  margin-right: 4px;
  vertical-align: middle;
}

.usd-unusual-badge--kpi {
  font-size: 10px;
  margin-left: 6px;
}

.usd-empty-row {
  text-align: center;
  padding: 24px;
  color: #94a3b8;
}

.usd-legend-del { border-radius: 2px; }
.usd-legend-del--high { background: #10b981; }
.usd-legend-del--mid { background: #fbbf24; }
.usd-legend-del--low { background: #f87171; }
.usd-legend-spec {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
}
.usd-legend-line {
  background: #0ea5e9;
  border-radius: 50%;
}

.usd-search {
  width: 100%;
  box-sizing: border-box;
  flex: 1 1 180px;
  min-width: 140px;
  padding: 9px 36px 9px 12px;
  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 right 12px center;
}

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

.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-table tbody tr.is-expanded + .usd-row-chart td {
  background: #f8fafc;
  box-shadow: inset 3px 0 0 #2563eb;
}

.usd-row-chart td {
  padding: 0 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.usd-chart-inline {
  padding: 4px 0 0;
}

.usd-chart-wrap--inline {
  min-height: 260px;
}

.usd-chart-legend--inline {
  margin-top: 10px;
  padding-top: 0;
}

.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-kpi-row {
    grid-template-columns: 1fr;
  }

  .usd-table-wrap {
    max-height: none;
  }
}

/* Logged-in workspace embed */
.kse-uin-page.is-workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kse-uin-page.is-workspace .kse-uin-ws-head h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 800;
  color: #0a2540;
}

.kse-uin-page.is-workspace .kse-uin-ws-section {
  padding-top: 0;
}

.kse-uin-page.is-workspace .kse-uin-ws-card {
  padding: 14px 16px 16px;
  margin: 0;
}

.kse-uin-page.is-workspace .kse-uin-ws-card .kse-section-inner.site-container {
  width: 100%;
  max-width: none;
  padding: 0;
}

.kse-uin-page.is-workspace .usd-root {
  min-height: 280px;
}

.kse-uin-page.is-workspace .usd-kpi-row {
  gap: 10px;
  margin-bottom: 16px;
}

.kse-uin-page.is-workspace .usd-kpi-card {
  padding: 14px 16px;
}

.kse-uin-page.is-workspace .usd-grid {
  gap: 14px;
}

.kse-uin-page.is-workspace .usd-panel {
  box-shadow: none;
}

.kse-uin-page.is-workspace .usd-table-wrap {
  max-height: none;
}

.kse-uin-page.is-workspace .usd-search,
.kse-uin-page.is-workspace .usd-sector-select {
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
}

.kse-uin-page.is-workspace .kse-screener-note {
  margin-top: 12px;
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .kse-uin-page.is-workspace .usd-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .kse-uin-page.is-workspace .kse-uin-ws-card {
    padding: 12px 12px 14px;
  }
}
