:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --ink: #182230;
  --muted: #667085;
  --line: #d7dee8;
  --blue: #2459a8;
  --blue-soft: #eaf1ff;
  --teal: #087f7a;
  --teal-soft: #e5f6f4;
  --gold: #9a6a00;
  --gold-soft: #fff4d6;
  --red: #b42318;
  --red-soft: #fde8e5;
  --shadow: 0 12px 28px rgba(24, 34, 48, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 14px;
  background: #172033;
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #ffffff;
  object-fit: contain;
  padding: 4px;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.brand-subtitle {
  color: #aeb9c9;
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #d8dfeb;
  background: transparent;
  text-align: left;
  padding: 0 12px;
  font-weight: 600;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.nav-item.active {
  color: #172033;
  background: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d8dfeb;
  font-size: 13px;
  padding: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  flex: 0 0 auto;
}

.status-dot.good {
  background: #18a058;
}

.status-dot.bad {
  background: var(--red);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.topbar h1,
.section-heading h2,
.panel h3 {
  margin: 0;
}

.topbar h1 {
  font-size: 26px;
  line-height: 1.15;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.section-heading h2 {
  font-size: 19px;
}

.section-meta {
  color: var(--muted);
  font-size: 13px;
}

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

.metric-card,
.panel,
.table-shell,
.module-tile,
.quick-grid a {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 112px;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 18px;
}

.metric-card strong {
  font-size: 25px;
  line-height: 1;
}

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

.metric-card.accent {
  border-color: #a8d9d5;
  background: var(--teal-soft);
}

.metric-card.warning {
  border-color: #f0d98a;
  background: var(--gold-soft);
}

.module-grid,
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.module-tile {
  min-height: 104px;
  text-align: left;
  padding: 16px;
  display: grid;
  align-content: space-between;
  color: var(--ink);
}

.module-tile:hover,
.quick-grid a:hover {
  border-color: var(--blue);
}

.module-tile span {
  font-weight: 800;
  font-size: 17px;
}

.module-tile strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.toolbar,
.form-grid,
.collection-bar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar.compact {
  align-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.collection-bar {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 130px;
}

.field.wide {
  min-width: 240px;
  flex: 1 1 240px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(36, 89, 168, 0.13);
}

.primary-button,
.success-button,
.ghost-button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--blue);
}

.primary-button.secondary {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #bdd0ef;
}

.success-button {
  color: #ffffff;
  background: var(--teal);
}

.ghost-button {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.align-end {
  align-self: end;
}

.badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.muted {
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}

.badge.good {
  color: #05603a;
  background: #e7f8ef;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.42fr) minmax(420px, 1fr);
  gap: 14px;
}

.split-layout.narrow {
  grid-template-columns: repeat(2, minmax(300px, 1fr));
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel h3 {
  font-size: 16px;
  margin-bottom: 14px;
}

.summary-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.summary-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-pill strong {
  color: var(--ink);
}

.table-shell {
  overflow: auto;
}

.table-shell.small {
  max-height: 360px;
  box-shadow: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: var(--surface);
}

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

th {
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  z-index: 1;
}

td {
  font-size: 13px;
}

tbody tr:hover {
  background: #f9fbfd;
}

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

.list-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
  text-align: left;
}

.list-item.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.list-item strong {
  font-size: 14px;
}

.list-item span {
  color: var(--muted);
  font-size: 12px;
}

.total-box {
  min-width: 120px;
  min-height: 48px;
  display: grid;
  align-content: center;
  gap: 3px;
  border-left: 3px solid var(--teal);
  background: var(--teal-soft);
  padding: 6px 12px;
  border-radius: 7px;
}

.total-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.total-box strong {
  font-size: 16px;
}

.quick-grid a {
  display: grid;
  place-items: center start;
  min-height: 80px;
  color: var(--ink);
  padding: 14px;
  text-decoration: none;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.empty-state {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.number-input {
  max-width: 110px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
  }

  .nav-list {
    display: flex;
    overflow: auto;
    gap: 6px;
  }

  .nav-item {
    width: auto;
    min-width: 110px;
    text-align: center;
  }

  .sidebar-footer {
    display: none;
  }

  .metric-grid,
  .module-grid,
  .quick-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .split-layout,
  .split-layout.narrow {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 14px;
  }

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

  .metric-grid,
  .module-grid,
  .quick-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .collection-bar {
    align-items: stretch;
  }

  .primary-button,
  .success-button,
  .ghost-button {
    width: 100%;
  }
}
