:root {
  color-scheme: light;
  font-family: Inter, Roboto, Arial, sans-serif;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #10233f;
  --muted: #657287;
  --line: #dbe3ef;
  --green: #12824a;
  --blue: #0b6bea;
  --amber: #d59118;
  --red: #c53030;
  --nav: #071c36;
  --nav-2: #0c315f;
  --soft-blue: #eaf3ff;
  --soft-green: #eaf8f0;
  --soft-amber: #fff6df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button.ghost {
  background: #eef5ff;
  color: #0950b8;
}

button.warn {
  background: #fff3db;
  color: #7a4a00;
}

button.danger {
  background: #ffe9e9;
  color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.toast {
  min-height: 0;
}

.toast:not(:empty) {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f0f7ff;
  color: #074aa6;
}

.toast.error {
  background: #ffe9e9;
  color: var(--red);
}

.shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #fff;
  padding: 22px 16px;
  box-shadow: 8px 0 24px rgba(10, 31, 58, 0.08);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--green);
  font-weight: 800;
}

.brand span {
  display: block;
  color: #c7d8ef;
  font-size: 13px;
}

.sidebar-section-label {
  margin: 18px 8px 8px;
  color: #9fbedf;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.role-switch {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.role-switch button {
  min-height: 38px;
  justify-content: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #e7f2ff;
  text-align: left;
}

.role-switch button.active,
.role-switch button:hover {
  background: #078744;
  color: #fff;
}

nav {
  display: grid;
  gap: 6px;
}

nav a {
  min-height: 44px;
  color: #d8e8df;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}

nav a.active,
nav a:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

nav a[hidden] {
  display: none;
}

main {
  padding: 24px 28px 32px;
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

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

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

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

.identity {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 6px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft-green);
  color: #0f6b35;
  font-size: 12px;
  font-weight: 900;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 44px;
  margin: -4px 0 12px;
  padding: 0;
  background: transparent;
}

.page-toolbar span {
  min-width: 112px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

select,
input,
textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(16, 35, 63, 0.05);
}

.metric strong {
  display: block;
  font-size: 26px;
  margin-bottom: 6px;
}

.metric:nth-child(3n + 1) {
  border-top: 4px solid var(--green);
}

.metric:nth-child(3n + 2) {
  border-top: 4px solid var(--blue);
}

.metric:nth-child(3n) {
  border-top: 4px solid var(--amber);
}

.metric span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(16, 35, 63, 0.05);
}

.page-block[hidden] {
  display: none !important;
}

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

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

.toolbar input {
  min-width: 220px;
}

.compact-panel {
  padding: 14px 16px;
}

.queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.queue-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.queue-grid strong {
  display: block;
  font-size: 24px;
}

.queue-grid span {
  color: var(--muted);
  font-size: 13px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfdfc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.map-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9aa5a0;
}

.map-legend-item.ACTIVE i {
  background: var(--green);
}

.map-legend-item.VACANT i {
  background: #4b89dc;
}

.map-legend-item.INACTIVE i {
  background: var(--red);
}

.map-legend-item.RISK i {
  background: var(--amber);
}

.map-heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.heat-cell {
  min-height: 86px;
  display: grid;
  gap: 4px;
  align-content: start;
  border: 1px solid var(--line);
  border-left: 5px solid #9aa5a0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.heat-cell span,
.heat-cell em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.heat-cell strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.heat-LOW {
  border-left-color: var(--green);
}

.heat-MEDIUM {
  border-left-color: var(--amber);
  background: #fffaf0;
}

.heat-HIGH,
.heat-CRITICAL {
  border-left-color: var(--red);
  background: #fff7f7;
}

.map-floor-plan {
  min-height: 240px;
}

.floor-plan-canvas {
  position: relative;
  min-height: 240px;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.floor-zone-band {
  position: absolute;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  border-top: 1px solid rgba(55, 72, 64, 0.16);
  background: rgba(238, 242, 240, 0.54);
  pointer-events: none;
}

.floor-zone-band span {
  margin: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.floor-stall {
  position: absolute;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #cfd8d2;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.floor-stall span {
  max-width: 100%;
  padding: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.floor-stall:hover,
.floor-stall:focus-visible {
  z-index: 3;
  outline: 2px solid rgba(19, 138, 68, 0.28);
  box-shadow: 0 8px 20px rgba(14, 36, 24, 0.14);
}

.floor-stall.status-ACTIVE {
  border-color: var(--green);
}

.floor-stall.status-VACANT {
  border-color: #4b89dc;
  background: #f4f9ff;
}

.floor-stall.status-INACTIVE {
  border-color: var(--red);
  background: #fff7f7;
}

.floor-stall.has-alert {
  border-width: 2px;
  border-color: var(--amber);
  background: #fffaf0;
}

.floor-stall.floor-HIGH,
.floor-stall.floor-CRITICAL {
  color: #6f1d1d;
}

.market-map {
  display: grid;
  gap: 12px;
}

.map-zone {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.map-zone-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.map-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.map-row + .map-row {
  margin-top: 10px;
}

.map-row-label {
  min-height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef2f0;
  color: #314039;
  font-size: 12px;
  font-weight: 700;
}

.map-row-stalls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 8px;
}

.map-stall {
  width: 100%;
  min-height: 112px;
  display: grid;
  align-content: start;
  gap: 4px;
  border: 1px solid var(--line);
  border-left: 5px solid #9aa5a0;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.map-stall:hover,
.map-stall:focus-visible {
  box-shadow: 0 8px 22px rgba(14, 36, 24, 0.1);
  outline: 2px solid rgba(19, 138, 68, 0.18);
}

.map-stall.status-ACTIVE {
  border-left-color: var(--green);
}

.map-stall.status-VACANT {
  border-left-color: #4b89dc;
}

.map-stall.status-INACTIVE {
  border-left-color: var(--red);
}

.map-stall.has-alert {
  background: #fffbf2;
  border-top-color: #f2d28d;
  border-right-color: #f2d28d;
  border-bottom-color: #f2d28d;
}

.map-stall-code,
.map-stall small,
.map-stall em {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-style: normal;
}

.map-stall strong,
.map-stall span,
.map-stall small,
.map-stall em {
  overflow-wrap: anywhere;
}

.map-stall strong {
  font-size: 14px;
}

.map-stall em {
  color: #8a5600;
  font-weight: 700;
}

.feedback-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.feedback-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.feedback-summary strong {
  display: block;
  font-size: 22px;
}

.feedback-summary span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2f0;
  color: #314039;
  font-size: 13px;
  font-weight: 600;
}

.status.APPROVED,
.status.ACTIVE,
.status.RESOLVED,
.status.VACANT,
.status.PAID,
.status.COMPLETED,
.status.LOW,
.status.TOT {
  background: #e4f6eb;
  color: #0f6b35;
}

.status.SUBMITTED,
.status.PENDING_REVIEW,
.status.UNDER_REVIEW,
.status.CONFIRMED,
.status.READY,
.status.TRIAGED,
.status.ON_DINH {
  background: #e7f0ff;
  color: #074aa6;
}

.status.NEED_SUPPLEMENT,
.status.PREPARING,
.status.PARTIAL,
.status.PENDING,
.status.PLANNED,
.status.MEDIUM,
.status.HIGH,
.status.CAN_THEO_DOI {
  background: #fff3db;
  color: #7a4a00;
}

.status.REJECTED,
.status.OPEN,
.status.INACTIVE,
.status.CANCELED,
.status.WONT_FIX,
.status.CRITICAL,
.status.RUI_RO {
  background: #ffe9e9;
  color: #a12a2a;
}

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

.list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.split,
.triple {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

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

.log {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.report-actions {
  margin-bottom: 12px;
}

.score-config-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  align-items: end;
}

.score-config-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.score-config-form input {
  min-width: 0;
}

.score-config-form button {
  width: 100%;
}

.snapshot-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.snapshot-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
}

.snapshot-pill span,
.snapshot-pill em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.snapshot-pill strong {
  display: block;
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.comparison-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.comparison-summary {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f6fbff;
}

.comparison-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
}

.comparison-pill.good {
  border-color: #9ccaa6;
  background: #f4fbf5;
}

.comparison-pill.watch,
.comparison-pill.missing {
  border-color: #e0aaa0;
  background: #fff7f5;
}

.comparison-pill.new {
  border-color: #a9bfdd;
  background: #f6f9ff;
}

.comparison-pill.stable {
  border-color: #cdd6d0;
}

.comparison-pill span,
.comparison-pill em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.comparison-pill strong {
  display: block;
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.cohort-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.cohort-summary {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f8fbf7;
}

.cohort-pill {
  border: 1px solid #cdd8ce;
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
}

.cohort-pill span,
.cohort-pill em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.cohort-pill strong {
  display: block;
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.operation-result {
  margin: 12px 0 0;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(9, 22, 16, 0.36);
}

.drawer-backdrop[hidden],
.modal-backdrop[hidden] {
  display: none;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(520px, 100%);
  height: 100vh;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 34px rgba(14, 36, 24, 0.14);
  transform: translateX(0);
  transition: transform 0.18s ease;
}

.detail-drawer[aria-hidden="true"] {
  pointer-events: none;
  transform: translateX(100%);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.drawer-body {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
}

.field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.field strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.json-preview {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  max-height: 180px;
  overflow: auto;
  background: #fbfdfc;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.timeline {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.timeline-item {
  border-left: 3px solid var(--green);
  padding: 8px 10px;
  background: #fbfdfc;
}

.timeline-item span,
.timeline-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.timeline-item strong {
  display: block;
  margin: 2px 0;
}

.timeline-item p {
  color: var(--ink);
  font-size: 13px;
}

.modal-backdrop {
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
}

.confirm-modal {
  width: min(420px, 100%);
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 18px;
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(14, 36, 24, 0.18);
}

.confirm-modal p {
  margin-top: 8px;
}

.confirm-note {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  font-weight: 700;
}

.confirm-note textarea {
  width: 100%;
  resize: vertical;
  font-weight: 400;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

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

  .sidebar {
    position: static;
  }

  .metric-grid,
  .queue-grid,
  .feedback-summary,
  .split,
  .triple {
    grid-template-columns: 1fr;
  }

  .score-config-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .snapshot-strip,
  .comparison-strip,
  .cohort-strip {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-controls {
    width: 100%;
    justify-content: stretch;
  }

  .topbar-controls .identity {
    width: 100%;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-zone-head {
    flex-direction: column;
  }

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

  .map-row-label {
    place-items: start;
    padding: 10px;
  }

  .map-row-stalls {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  }

  .toolbar,
  .toolbar input {
    width: 100%;
  }

  .detail-drawer {
    width: 100%;
  }
}
