:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #17212b;
  --muted: #637283;
  --line: #d5dde6;
  --line-strong: #bcc8d4;
  --green: #1a7f5a;
  --teal: #146c94;
  --blue: #4259b8;
  --amber: #b66b12;
  --red: #b8473d;
  --purple: #7b5bb7;
  --shadow: 0 10px 26px rgba(23, 33, 43, 0.08);
  --header-bg: #ffffff;
  --row-alt: #f9fbfc;
  --table-head: #e8edf2;
  --chart-grid: #d8e0e8;
  --chart-axis: #9eabba;
  --button-bg: #ffffff;
  --input-bg: #ffffff;
}

body.dark {
  --bg: #111820;
  --surface: #18222d;
  --surface-soft: #202c38;
  --ink: #edf3f8;
  --muted: #aab8c6;
  --line: #2d3a47;
  --line-strong: #405061;
  --green: #38b47f;
  --teal: #39a7d0;
  --blue: #7d92f0;
  --amber: #e5a13a;
  --red: #e0685d;
  --purple: #a78bdf;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  --header-bg: #151f29;
  --row-alt: #1c2732;
  --table-head: #22303d;
  --chart-grid: #31404f;
  --chart-axis: #667788;
  --button-bg: #1f2b36;
  --input-bg: #121b24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 24px clamp(18px, 3vw, 40px) 18px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}

.title-block {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  width: clamp(155px, 18vw, 245px);
  max-height: 74px;
  object-fit: contain;
  border-radius: 4px;
  background: #ffffff;
  padding: 6px;
  border: 1px solid var(--line);
}

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

h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

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

.upload-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid #0f5d7d;
  background: var(--teal);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--button-bg);
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

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

.secondary-button.compact {
  min-height: 34px;
  padding: 0 11px;
}

.secondary-button:hover,
.upload-button:hover {
  filter: brightness(0.98);
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-status {
  color: var(--muted);
  font-size: 13px;
  min-width: 82px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px clamp(18px, 3vw, 40px) 0;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs button {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.tabs button.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
}

main {
  padding: 20px clamp(18px, 3vw, 40px) 42px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi,
.panel,
.pipeline-card,
.workbench,
.pipeline-head {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 112px;
  padding: 16px;
}

.kpi span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1;
}

.kpi small {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 9px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(310px, 0.7fr);
  gap: 14px;
  margin-bottom: 14px;
}

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

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

.panel-heading,
.pipeline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.panel-heading {
  margin-bottom: 14px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 3px;
  gap: 3px;
}

.segmented button {
  min-height: 31px;
  min-width: 46px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

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

.chart-summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0 2px;
}

.chart-summary strong {
  color: var(--green);
  font-size: 34px;
}

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

.chart-wrap {
  position: relative;
  height: 390px;
}

#trendChart {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.trend-hit-area {
  pointer-events: all;
}

.trend-tooltip {
  position: absolute;
  display: none;
  min-width: 150px;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 9px 10px;
  border-radius: 6px;
  background: #152331;
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(23, 33, 43, 0.24);
  pointer-events: none;
  z-index: 3;
}

.trend-tooltip.visible {
  display: grid;
  gap: 4px;
}

.trend-tooltip strong {
  font-size: 13px;
}

.trend-tooltip span {
  color: #d9e3ec;
  font-size: 12px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.legend {
  display: inline-block;
  width: 22px;
  height: 4px;
  border-radius: 999px;
  margin-right: 7px;
  vertical-align: middle;
}

.legend.utilization {
  background: var(--green);
}

.legend.jobs {
  background: var(--teal);
}

.legend.tenders {
  background: var(--amber);
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  height: 13px;
  background: var(--surface-soft);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.mini-table {
  display: grid;
  gap: 8px;
}

.mini-table div {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.mini-table span {
  color: var(--ink);
  font-size: 13px;
}

.mini-table small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.mini-table strong {
  color: var(--teal);
  font-size: 14px;
}

.workbench {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select {
  height: 40px;
  min-width: 180px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--input-bg);
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.field select {
  max-width: 280px;
}

.field input {
  width: min(36vw, 390px);
}

.field.wide input {
  width: 100%;
  min-width: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.check-row input {
  width: 17px;
  height: 17px;
}

.cloud-dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(23, 33, 43, 0.22);
  padding: 0;
}

.cloud-dialog::backdrop {
  background: rgba(23, 33, 43, 0.42);
}

.cloud-dialog form,
.access-panel {
  display: grid;
  gap: 15px;
  padding: 20px;
  background: var(--surface);
}

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

.icon-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.dialog-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(238, 242, 245, 0.96);
}

.access-gate[hidden] {
  display: none;
}

.access-panel {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.result-count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.result-count strong {
  color: var(--ink);
  font-size: 24px;
  margin-right: 4px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.status-strip button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.status-strip button.active {
  border-color: var(--teal);
  color: var(--teal);
  background: #eef8fb;
}

.status-strip span {
  font-weight: 800;
  font-size: 13px;
}

.status-strip strong {
  min-width: 28px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
}

.table-wrap {
  max-height: 68vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: var(--row-alt);
}

td strong {
  display: block;
}

td small {
  color: var(--muted);
  display: block;
  line-height: 1.45;
  margin-top: 3px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: #eef3f8;
  color: var(--blue);
  white-space: nowrap;
}

.status.job {
  background: #e6f3ee;
  color: var(--green);
}

.status.tender {
  background: #ebefff;
  color: var(--blue);
}

.status.training {
  background: #f1ecfb;
  color: var(--purple);
}

.status.home {
  background: #fff1dd;
  color: var(--amber);
}

.pipeline-head {
  padding: 15px 16px;
  margin-bottom: 14px;
}

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

.pipeline-card {
  padding: 15px;
}

.pipeline-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.pipeline-card-head strong {
  font-size: 16px;
}

.pipeline-card-head span {
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

dl {
  display: grid;
  gap: 9px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
}

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

dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

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

  .overview-grid,
  .insight-grid,
  .pipeline-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .app-header,
  .workbench,
  .panel-heading,
  .pipeline-head {
    align-items: stretch;
    flex-direction: column;
  }

  .kpi-grid,
  .overview-grid,
  .insight-grid,
  .pipeline-grid {
    grid-template-columns: 1fr;
  }

  .field input,
  .field select {
    width: 100%;
    min-width: 0;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 320px;
  }
}
