:root {
  color: #172026;
  background: #eef2f4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.sidebar {
  background: #172026;
  color: #f7fafb;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
}

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

.brandMark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #0f8b8d;
  color: white;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #9fb0b7;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  border: 0;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cdd8dd;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: #23333b;
  color: #ffffff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.apiNote {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #32474f;
  border-radius: 8px;
  color: #cdd8dd;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
}

.apiNote p {
  margin: 0;
  line-height: 1.45;
  font-size: 13px;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #0f8b8d;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

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

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

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  letter-spacing: 0;
}

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

.inputIcon {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid #d1dbe0;
  border-radius: 7px;
  background: #ffffff;
}

.inputIcon input,
.inputIcon select {
  border: 0;
  outline: 0;
  min-width: 170px;
  background: transparent;
  color: #172026;
}

.weekPickerButton {
  border: 0;
  min-width: 190px;
  min-height: 38px;
  padding: 0 28px 0 0;
  background: transparent;
  color: #172026;
  text-align: left;
  cursor: pointer;
  position: relative;
}

.weekPickerButton::after {
  content: '⌄';
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  color: #60717b;
}

.weekPickerMenu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  padding: 6px;
  border: 1px solid #d1dbe0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(23, 32, 38, 0.16);
  display: none;
}

.weekPickerMenu.open {
  display: grid;
  gap: 4px;
}

.weekPickerMenu button {
  border: 0;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 7px;
  background: transparent;
  color: #172026;
  text-align: left;
  cursor: pointer;
}

.weekPickerMenu button:hover,
.weekPickerMenu button.active {
  background: #eef7f7;
  color: #0c6f71;
}

.statsGrid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: #ffffff;
  border: 1px solid #dce4e8;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
}

.stat > span {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
}

.stat svg {
  width: 20px;
  height: 20px;
}

.stat.green > span { background: #0f8b8d; }
.stat.blue > span { background: #2f80ed; }
.stat.red > span { background: #e94f37; }
.stat.amber > span { background: #f5a623; }
.stat.violet > span { background: #7a5cff; }

.stat small {
  color: #60717b;
  display: block;
  margin-bottom: 4px;
}

.stat strong {
  font-size: 24px;
}

.contentLayout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
  margin-bottom: 16px;
}

.dashboardLayout {
  grid-template-columns: 1fr;
}

.panel {
  background: #ffffff;
  border: 1px solid #dce4e8;
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
}

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

.panelHead.compact {
  margin-bottom: 12px;
}

.panelHead p {
  margin-bottom: 0;
  color: #60717b;
  line-height: 1.45;
  font-size: 14px;
}

.primaryButton {
  border: 0;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #172026;
  color: white;
  cursor: pointer;
  white-space: nowrap;
}

.secondaryButton {
  border: 1px solid #d1dbe0;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #ffffff;
  color: #172026;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.secondaryButton.connected {
  border-color: #b8e2dc;
  background: #eef7f7;
  color: #0c6f71;
}

.secondaryButton:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.compactControl {
  color: #60717b;
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
}

.compactControl select,
.compactControl input {
  min-width: 150px;
  min-height: 38px;
  border: 1px solid #d1dbe0;
  border-radius: 7px;
  padding: 0 10px;
  background: #ffffff;
  color: #172026;
}

.reportStatsGrid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.primaryButton:disabled {
  opacity: 0.72;
  cursor: wait;
}

.spin {
  animation: spin 0.9s linear infinite;
}

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

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

.formGrid label {
  color: #60717b;
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.formGrid .wide {
  grid-column: span 3;
}

.formGrid input,
.formGrid select,
.formGrid textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d1dbe0;
  border-radius: 7px;
  padding: 0 11px;
  color: #172026;
  outline-color: #0f8b8d;
  background: white;
}

.formGrid textarea {
  min-height: 138px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

.crawlLog {
  grid-column: span 3;
  margin: 0;
  padding: 12px;
  border-radius: 7px;
  background: #eef7f7;
  color: #0c6f71;
  font-size: 14px;
  line-height: 1.45;
}

.crawlLog.error {
  background: #fff0ec;
  color: #a83b25;
}

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

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

.teamCard {
  border: 1px solid #e5ecef;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 14px;
}

.teamCardHead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.teamCard strong,
.teamCard small {
  display: block;
}

.teamCard small {
  color: #60717b;
  margin-top: 4px;
}

.teamCard label,
.kpiSettings label {
  color: #60717b;
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.teamCard select,
.kpiSettings input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #d1dbe0;
  border-radius: 7px;
  padding: 0 10px;
  background: #ffffff;
  color: #172026;
}

.kpiLayout {
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(0, 1.22fr);
  gap: 16px;
}

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

.kpiSettings fieldset {
  border: 1px solid #e5ecef;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.kpiSettings legend {
  padding: 0 6px;
  font-weight: 800;
}

.kpiProgress {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(220px, 1.2fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid #e5ecef;
  border-radius: 8px;
}

.kpiProgress strong,
.kpiProgress small {
  display: block;
}

.kpiProgress small {
  color: #60717b;
  margin-top: 4px;
}

.progressRows {
  display: grid;
  gap: 6px;
}

.progressRows label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #60717b;
  font-size: 12px;
  font-weight: 800;
}

.progressRows meter {
  width: 100%;
  height: 9px;
}

.personRow {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e5ecef;
  border-radius: 8px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #0f8b8d;
  background: #e4f4f3;
}

.personInfo strong,
.personInfo small,
td small {
  display: block;
}

.personInfo small,
td small {
  color: #60717b;
  margin-top: 4px;
}

.meters {
  margin-top: 9px;
  display: grid;
  gap: 4px;
}

.meters::before,
.meters::after {
  content: '';
  grid-row: 1;
  grid-column: 1;
  height: 5px;
  border-radius: 999px;
  background: #e9eff2;
}

.meters span {
  grid-row: 1;
  grid-column: 1;
  height: 5px;
  border-radius: 999px;
}

.meters span:first-child {
  background: #0f8b8d;
}

.meters span:last-child {
  margin-top: 9px;
  background: #2f80ed;
}

.passBadge,
.watchBadge {
  min-width: 82px;
  min-height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
}

.passBadge {
  color: #08715f;
  background: #dcf5ef;
}

.watchBadge {
  color: #9a6410;
  background: #fff1d7;
}

.chartGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 330px;
  gap: 16px;
  margin-bottom: 16px;
}

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

.chartPanel {
  min-height: 390px;
}

.chartPanel canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.chartPanelWide {
  min-height: 430px;
}

.chartGridWide .chartPanel:last-child {
  grid-column: span 2;
}

.tablePanel {
  padding-bottom: 8px;
}

.tableWrap {
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
}

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

th,
td {
  text-align: left;
  padding: 14px 10px;
  border-top: 1px solid #e5ecef;
  vertical-align: middle;
}

th {
  color: #60717b;
  font-size: 12px;
  text-transform: uppercase;
}

.clipCell {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 330px;
}

.clipCell img,
.thumbFallback {
  width: 54px;
  height: 72px;
  border-radius: 7px;
  object-fit: cover;
  background: #172026;
  color: #ffffff;
  display: grid;
  place-items: center;
}

.clipCell strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rowActions {
  display: flex;
  gap: 6px;
}

.ownerSelect {
  width: 150px;
  min-height: 34px;
  border: 1px solid #d1dbe0;
  border-radius: 7px;
  padding: 0 9px;
  background: #ffffff;
  color: #172026;
}

.rowActions button,
.rowActions a {
  width: 34px;
  height: 34px;
  border: 1px solid #d1dbe0;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #172026;
  background: #ffffff;
  cursor: pointer;
}

.rowActions a {
  text-decoration: none;
}

@media (max-width: 1180px) {
  .statsGrid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .contentLayout,
  .chartGrid,
  .kpiLayout {
    grid-template-columns: 1fr;
  }

  .teamGrid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    background: #eef2f4;
    overflow-x: hidden;
  }

  .app {
    grid-template-columns: 1fr;
    max-width: 100vw;
  }

  .sidebar {
    position: sticky;
    z-index: 30;
    top: 0;
    height: auto;
    padding: 12px;
    gap: 12px;
    box-shadow: 0 8px 22px rgba(23, 32, 38, 0.16);
    max-width: 100vw;
    overflow: hidden;
  }

  .brand {
    justify-content: space-between;
    min-width: 0;
  }

  .brandMark {
    width: 36px;
    height: 36px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    width: 100%;
    min-width: 0;
    max-width: calc(100vw - 24px);
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav button {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .apiNote {
    display: none;
  }

  .workspace {
    padding: 14px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar,
  .panelHead {
    align-items: stretch;
    flex-direction: column;
  }

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

  .inputIcon {
    width: 100%;
    min-height: 44px;
  }

  .inputIcon input,
  .weekPickerButton {
    min-width: 0;
    width: 100%;
  }

  .weekPickerMenu {
    left: 0;
    right: 0;
    min-width: 0;
  }

  .statsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    min-height: 84px;
    padding: 12px;
    gap: 10px;
  }

  .stat > span {
    width: 34px;
    height: 34px;
  }

  .stat strong {
    font-size: 20px;
  }

  .stat small {
    font-size: 12px;
  }

  .panel {
    padding: 14px;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar > *,
  .secondaryButton,
  .primaryButton,
  .compactControl,
  .compactControl input,
  .compactControl select {
    width: 100%;
  }

  .secondaryButton,
  .primaryButton {
    justify-content: center;
  }

  .formGrid {
    grid-template-columns: 1fr;
  }

  .formGrid .wide {
    grid-column: span 1;
  }

  .crawlLog {
    grid-column: span 1;
  }

  .teamGrid,
  .kpiProgress {
    grid-template-columns: 1fr;
  }

  .personRow {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .personRow .passBadge,
  .personRow .watchBadge {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .chartGridWide .chartPanel:last-child {
    grid-column: auto;
  }

  .chartPanel,
  .chartPanelWide {
    min-height: 320px;
  }

  table {
    min-width: 820px;
  }

  h1 {
    font-size: 26px;
    line-height: 1.12;
  }
}

@media (max-width: 430px) {
  .workspace {
    padding: 12px;
  }

  .statsGrid {
    grid-template-columns: 1fr;
  }

  .topbar {
    margin-bottom: 14px;
  }

  .clipCell {
    min-width: 280px;
  }
}
