:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #d8e0ec;
  --primary: #2457d6;
  --primary-dark: #163fa6;
  --accent: #12a87f;
  --green: #18a058;
  --red: #d92d20;
  --yellow: #f4b740;
  --blue: #2f80ed;
  --gray: #667085;
  --shadow: 0 16px 40px rgba(31, 45, 61, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark {
  --bg: #0f172a;
  --panel: #111c31;
  --panel-soft: #17223a;
  --text: #f8fafc;
  --muted: #a7b0c0;
  --line: #2d3a52;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 26px;
  letter-spacing: 0;
}

.login-field {
  display: grid;
  gap: 7px;
}

.login-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
}

.login-error {
  padding: 10px 12px;
  border: 1px solid rgba(217, 45, 32, 0.25);
  border-radius: 12px;
  background: rgba(217, 45, 32, 0.08);
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -22px -22px 22px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.84);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

body.dark .topbar {
  background: rgba(15, 23, 42, 0.84);
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 36px);
  letter-spacing: -0.04em;
}

h2 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.eyebrow {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.topbar-actions, .session-actions, .pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.session-actions {
  justify-content: flex-end;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 39px;
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.upload-time-pill {
  display: inline-flex;
  align-items: center;
  min-height: 39px;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(18, 168, 127, 0.08);
  border: 1px solid rgba(18, 168, 127, 0.25);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

button, .primary-btn, .ghost-btn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:hover, .primary-btn:hover, .ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 11px 15px;
  box-shadow: 0 10px 20px rgba(36, 87, 214, 0.18);
}

.primary-btn.accent {
  background: linear-gradient(135deg, #12a87f, #0f8d6d);
}

.ghost-btn, .pagination-controls button {
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 14px;
}

.refresh-btn {
  color: var(--primary);
}

main {
  display: grid;
  gap: 18px;
}

.section-card, .kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-card {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.status-pill, .badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.dash-hub-card {
  padding: 12px 14px;
}

.dash-hub {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.dash-heads {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 10px;
}

.dash-head {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 10px 10px 6px;
  min-height: 108px;
  max-height: 120px;
  display: grid;
  grid-template-rows: auto auto auto 28px;
  gap: 2px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.dash-head:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.dash-head.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(36, 87, 214, 0.14);
}

.dash-head-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dash-head-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
}

.dash-head-status .dash-head-icon { background: rgba(34, 197, 94, 0.14); color: var(--green); }
.dash-head-working .dash-head-icon { background: rgba(59, 130, 246, 0.14); color: var(--blue); }
.dash-head-oqt .dash-head-icon { background: rgba(249, 115, 22, 0.14); color: #c2410c; }
.dash-head-pqt .dash-head-icon { background: rgba(168, 85, 247, 0.14); color: #7e22ce; }

.dash-head-title {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.dash-head-value {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

.dash-head-delta {
  font-size: 10px;
  font-weight: 800;
}

.dash-head-delta.up { color: var(--green); }
.dash-head-delta.down { color: var(--red); }
.dash-head-delta.flat { color: var(--muted); }

.dash-head-spark {
  min-height: 28px;
  width: 100%;
}

.dash-expand {
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
  animation: dash-expand-in 0.28s ease;
}

.dash-expand[hidden] {
  display: none !important;
}

@keyframes dash-expand-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dash-expand-inner {
  padding: 14px;
}

.dash-expand-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.dash-expand-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.dash-expand-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dash-expand-grid.four-col {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dash-metric-card {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.dash-metric-card h4 {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.dash-metric-card strong {
  font-size: 20px;
  font-weight: 900;
}

.dash-metric-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.dash-chart-block {
  margin-top: 12px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.dash-chart-block h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 900;
  color: var(--muted);
}

.dash-chart-panel {
  min-height: 220px;
}

.dash-chart-panel.tall {
  min-height: 260px;
}

.dash-chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dash-hub-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.dash-hub-updated {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.dash-hub-empty {
  margin: 0;
  padding: 10px 14px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--green);
}

.status-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: status-live-pulse 1.4s ease-in-out infinite;
}

@keyframes status-live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.status-updated {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.status-refresh-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.status-refresh-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.danger-btn {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.35);
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.12);
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
}

.history-item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.history-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.history-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.history-metrics em {
  font-style: normal;
  color: var(--text);
  margin-right: 4px;
}

.history-total {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
}

.match-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.match-status.success {
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--green);
}

.match-status.warning {
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--yellow);
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 20px;
  text-align: center;
  border: 2px dashed #abc0e8;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(36, 87, 214, 0.06), transparent);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.drop-zone:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.drop-zone input {
  display: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 8px;
  border-radius: 16px;
  background: #e9efff;
  color: var(--primary);
  font-size: 30px;
  font-weight: 900;
}

.purchase-zone {
  border-color: rgba(18, 168, 127, 0.42);
  background: linear-gradient(180deg, rgba(18, 168, 127, 0.08), transparent);
}

.purchase-zone .drop-icon {
  background: rgba(18, 168, 127, 0.12);
  color: var(--accent);
}

.stkot-zone {
  border-color: rgba(47, 128, 237, 0.42);
  background: linear-gradient(180deg, rgba(47, 128, 237, 0.08), transparent);
}

.stkot-zone .drop-icon {
  background: rgba(47, 128, 237, 0.12);
  color: var(--blue);
}

.paste-box {
  display: grid;
  gap: 10px;
}

textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  outline: none;
  padding: 11px 12px;
}

textarea:focus, input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(36, 87, 214, 0.1);
}

textarea {
  min-height: 125px;
  resize: vertical;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 14px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: -18px;
  top: -18px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(36, 87, 214, 0.08);
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(6, 1fr);
  gap: 12px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
}

.analytics-grid.table-only {
  grid-template-columns: minmax(0, 1fr);
}

.analytics-grid.table-only .table-card {
  grid-column: 1 / -1;
}

.insight-list, .alert-list {
  display: grid;
  gap: 10px;
}

.insight-item, .alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.insight-item span, .alert-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-card {
  position: relative;
  min-width: 0;
  width: 100% !important;
  max-width: 100%;
  min-height: 380px;
  height: clamp(420px, calc(100vh - 330px), 620px);
  overflow: hidden;
}

.table-card.table-floating {
  position: relative;
  z-index: auto;
  max-width: 100%;
  margin: 0;
  box-shadow: var(--shadow);
}

.table-drag-handle {
  cursor: default;
  user-select: none;
}

.table-wrap {
  position: relative;
  overflow-y: auto;
  overflow-x: auto;
  max-height: none;
  height: calc(100% - 82px);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.table-floating .table-wrap {
  height: calc(100% - 82px);
  max-height: none;
}

.table-resize-handle {
  display: none;
}

body.table-moving,
body.table-resizing {
  user-select: none;
}

body.table-moving {
  cursor: move;
}

body.table-resizing {
  cursor: nwse-resize;
}

.table-card.table-size-small {
  width: 100% !important;
}

.table-card.table-size-wide {
  width: 100% !important;
}

.table-card.table-size-full {
  position: relative;
  inset: auto;
  z-index: auto;
  width: 100% !important;
  max-width: 100%;
  height: clamp(420px, calc(100vh - 330px), 620px);
}

.table-card.table-size-full .table-wrap {
  height: calc(100% - 82px);
  max-height: none;
}

.resize-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#sizeSmall,
#sizeWide,
#sizeFull {
  display: inline-flex;
}

.resize-controls button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

.resize-controls button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

#toggleHiddenFields {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

#toggleHiddenFields:hover {
  color: #fff;
  filter: brightness(0.95);
}

.pivot-panel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.pivot-panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.pivot-panel-toolbar strong {
  color: var(--text);
  font-weight: 900;
}

.pivot-panel-toolbar div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pivot-panel-toolbar button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 10px;
  font-weight: 800;
  cursor: pointer;
}

.pivot-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  max-height: 180px;
  overflow: auto;
  padding-right: 4px;
}

.pivot-field {
  display: flex;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.pivot-field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.pivot-field-check span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--panel);
  font-size: 11px;
}

th, td {
  padding: 7px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #edf3ff;
  color: #21314d;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  overflow: visible;
  vertical-align: top;
}

th.filter-open {
  z-index: 40;
}

.column-filter {
  position: relative;
}

.th-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.th-sort-label {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.th-sort-label span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(33, 49, 77, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.75);
  color: #21314d;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}

.column-filter-toggle.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.th-sort-label:hover,
.column-filter-toggle:hover {
  transform: none;
}

.column-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(260px, 82vw);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.18);
  cursor: default;
}

th:last-child .column-filter-menu {
  right: 0;
  left: auto;
}

.column-filter-title,
.column-filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.column-filter-title span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}

.column-filter-title small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.column-filter-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 900;
}

.column-filter-actions button:hover {
  transform: none;
  border-color: var(--primary);
  color: var(--primary);
}

.column-filter-options {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.column-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.column-filter-option input {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

.column-filter-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-filter-empty {
  padding: 8px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

body.dark th {
  background: #1d2a44;
  color: #f8fafc;
}

tbody tr:nth-child(even) td {
  background: rgba(148, 163, 184, 0.06);
}

tbody tr:hover td {
  background: rgba(36, 87, 214, 0.08);
}

.cell-status {
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.status-done { background: var(--green); }
.status-critical { background: var(--red); }
.status-pending { background: var(--yellow); color: #3d2b00; }
.status-purchase { background: var(--blue); }
.status-normal { background: var(--gray); }

.summary-select-cell {
  padding: 4px 6px;
}

.summary-select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 800;
}

.pqt-input-cell {
  padding: 4px 6px;
  min-width: 88px;
}

.pqt-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.pqt-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(36, 87, 214, 0.15);
}

.pqt-input::placeholder {
  color: var(--muted);
}

.summary-status-cell {
  padding: 4px 6px;
}

.summary-status {
  position: relative;
  display: block;
  width: 100%;
  min-width: 84px;
  height: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--red);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.summary-status-fill {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  display: block;
  background: var(--green);
}

.summary-status-done {
  color: #fff;
}

.summary-status-done .summary-status-fill {
  background: var(--green);
}

.summary-status-none .summary-status-fill {
  width: 100% !important;
  background: var(--red);
}

.summary-status-text {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.cell-negative {
  color: var(--red);
  font-weight: 700;
  background: rgba(217, 45, 32, 0.05);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  color: var(--muted);
  text-align: center;
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.36);
  color: #fff;
  font-weight: 900;
}

.loader.active {
  display: grid;
}

.loader div {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .topbar, .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .analytics-grid, .upload-grid, .filter-grid, .kpi-grid {
    grid-template-columns: 1fr;
  }

  .dash-heads {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-expand-grid,
  .dash-expand-grid.four-col {
    grid-template-columns: 1fr;
  }

  .dash-chart-row {
    grid-template-columns: 1fr;
  }

  .topbar-actions, .session-actions {
    width: 100%;
  }

  .topbar-actions button, .session-actions button {
    flex: 1;
  }

  .app-shell {
    padding: 14px;
  }

  .topbar {
    margin: -14px -14px 18px;
  }
}
