:root {
  --navy: #082449;
  --navy-2: #0f3768;
  --gold: #c99a2e;
  --gold-soft: #f3d98d;
  --white: #ffffff;
  --bg: #eef2f7;
  --line: #dbe3ee;
  --text: #13243a;
  --muted: #6c7a8e;
  --danger: #d94d4d;
  --warning: #d99322;
  --info: #2e77d0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(201, 154, 46, 0.18), transparent 28rem),
    linear-gradient(135deg, #f8fafc 0%, var(--bg) 55%, #e7edf5 100%);
}

body.dark {
  --bg: #07172b;
  --white: #0d2038;
  --text: #edf4ff;
  --muted: #b5c4d9;
  --line: rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, #061324 0%, #102742 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 288px;
  height: 100vh;
  padding: 22px;
  background: linear-gradient(180deg, var(--navy), #06172d);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 10;
}

.brand,
.user-chip,
.panel-head,
.topbar,
.hero-band,
.progress-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  color: #10213b;
  font-weight: 900;
}

.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 8px;
  background: white;
  padding: 3px;
}

.brand span,
.sidebar-footer span {
  display: block;
  color: #b9c9df;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  overflow: auto;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  color: #dce7f6;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.nav-item.active {
  border-left: 3px solid var(--gold);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 22px;
}

.topbar {
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

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

.search {
  width: min(360px, 32vw);
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
}

body.dark .search {
  background: rgba(255, 255, 255, 0.08);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.user-chip {
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.user-chip > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--navy);
  color: white;
}

.user-chip small {
  color: var(--muted);
}

.icon-button,
.mode-toggle,
.primary,
.secondary {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
}

.icon-button {
  display: none;
  min-width: 58px;
}

.primary {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  color: #12243c;
  font-weight: 800;
}

.secondary,
.mode-toggle,
.icon-button {
  background: var(--white);
  color: var(--text);
}

.hero-band {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 26px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(8, 36, 73, 0.94), rgba(15, 55, 104, 0.88)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px 14px);
  color: white;
  box-shadow: 0 18px 45px rgba(8, 36, 73, 0.18);
}

.hero-band h2 {
  max-width: 820px;
  margin-bottom: 0;
  font-size: clamp(24px, 4vw, 44px);
  line-height: 1.08;
}

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

.page {
  display: none;
}

.page.active {
  display: block;
}

.stats-grid,
.content-grid,
.module-layout,
.role-grid,
.report-grid,
.kanban,
.module-actions {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.stat-card,
.panel,
.table-panel,
.kanban article,
.role-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 14px 38px rgba(27, 45, 74, 0.08);
  backdrop-filter: blur(14px);
}

body.dark .stat-card,
body.dark .panel,
body.dark .table-panel,
body.dark .kanban article,
body.dark .role-grid article {
  background: rgba(255, 255, 255, 0.07);
}

.stat-card {
  padding: 18px;
}

.stat-card span,
.stat-card small,
.panel p,
.timeline span,
.role-grid span {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 30px;
  color: var(--navy-2);
}

body.dark .stat-card strong {
  color: white;
}

.stat-card.accent {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: white;
}

.stat-card.accent strong,
.stat-card.accent small {
  color: white;
}

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

.panel,
.table-panel {
  padding: 18px;
}

.panel.wide {
  grid-column: span 2;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.live-dot {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(45, 160, 104, 0.12);
  color: #20905a;
  font-size: 12px;
  font-weight: 800;
}

canvas {
  width: 100%;
  max-width: 100%;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline div {
  padding-left: 14px;
  border-left: 3px solid var(--gold);
}

.timeline strong,
.timeline span {
  display: block;
}

.alert {
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(46, 119, 208, 0.1);
  color: var(--info);
  font-weight: 700;
}

.alert.danger {
  background: rgba(217, 77, 77, 0.1);
  color: var(--danger);
}

.alert.warning {
  background: rgba(217, 147, 34, 0.12);
  color: var(--warning);
}

.module-layout {
  grid-template-columns: 2fr 1fr;
  margin-bottom: 16px;
}

.module-actions {
  grid-template-columns: repeat(3, max-content);
  align-items: center;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.edit-search {
  max-width: 520px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--white);
  color: var(--text);
}

.qr-box,
.scan-card,
.upload-zone {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  padding: 20px;
}

.qr-code {
  position: relative;
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  padding: 10px;
  background: white;
  border: 1px solid var(--line);
}

.qr-code img,
.qr-code canvas {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
}

.qr-logo {
  position: absolute;
  width: 34px !important;
  height: 34px !important;
  padding: 3px;
  border-radius: 8px;
  background: white;
  object-fit: contain;
  box-shadow: 0 0 0 2px white;
  image-rendering: auto !important;
}

.full-button {
  width: 100%;
  margin-top: 12px;
}

.progress {
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #d7dfeb;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--navy-2));
}

.progress-row {
  justify-content: space-between;
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.map {
  position: relative;
  min-height: 340px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(8, 36, 73, 0.08) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(rgba(8, 36, 73, 0.08) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(135deg, #f7fbff, #dfe8f5);
  overflow: hidden;
}

body.dark .map {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(135deg, #0b1c32, #12345b);
}

.pin {
  position: absolute;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--navy);
  color: white;
  box-shadow: 0 0 0 8px rgba(201, 154, 46, 0.16);
  font-size: 12px;
  font-weight: 800;
}

.p1 { left: 16%; top: 30%; }
.p2 { right: 18%; top: 22%; }
.p3 { left: 48%; bottom: 24%; }

.kanban {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.kanban article {
  min-height: 230px;
  padding: 16px;
}

.kanban div {
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(8, 36, 73, 0.07);
}

.vendor-grid,
.role-grid,
.report-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.vendor-grid {
  display: grid;
  gap: 10px;
}

.vendor-grid span,
.report-grid button,
.role-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.report-grid button {
  min-height: 68px;
  color: var(--text);
  text-align: left;
}

.report-grid button:hover,
.scan-card:hover,
.pin:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.role-grid {
  margin-bottom: 16px;
}

.role-grid article {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.org {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.org span {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--navy);
  color: white;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(5, 17, 33, 0.58);
  z-index: 40;
}

.modal-backdrop.open {
  display: grid;
}

.modal {
  width: min(520px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.modal-close {
  float: right;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: transparent;
  color: var(--text);
}

#modalExtra {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(380px, calc(100vw - 28px));
  padding: 13px 16px;
  border-radius: 8px;
  background: var(--navy);
  color: white;
  box-shadow: 0 18px 44px rgba(8, 36, 73, 0.28);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.row-hidden {
  display: none;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
}

.prose {
  max-width: 960px;
}

@media (max-width: 1100px) {
  .stats-grid,
  .content-grid,
  .kanban {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .search {
    width: 260px;
  }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .icon-button {
    display: inline-grid;
    place-items: center;
  }

  .main {
    padding: 14px;
  }

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

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

  .stats-grid,
  .content-grid,
  .module-layout,
  .module-actions,
  .vendor-grid,
  .role-grid,
  .report-grid,
  .kanban,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }

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