:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #edf3f7;
  --ink: #07111f;
  --muted: #566477;
  --line: #d6deea;
  --accent: #168557;
  --accent-strong: #0d5e3c;
  --amber: #bd6b00;
  --red: #b42318;
  --good-bg: #dff4e8;
  --warn-bg: #fff2d7;
  --shadow: 0 18px 42px rgba(12, 30, 51, 0.12);
  --navy: #101828;
  --navy-soft: #17233a;
  --excel-line: #6ee083;
  --group-ontime: #263f83;
  --group-nns: #2c2cc2;
  --group-activation: #c03a86;
  --group-subs: #15a8cf;
  --group-maq: #22b87a;
  --group-nm: #d19b2d;
  --group-aos: #a8d8eb;
  --group-orders: #0c366d;
  --total-row: #3f444b;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: var(--surface-soft);
}

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

button svg,
.top-button svg,
.run-state svg,
.file-icon svg,
.local-import-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 9px clamp(12px, 2vw, 24px) 8px;
  background: var(--navy);
  border-bottom: 2px solid var(--excel-line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.title-block {
  grid-column: 2;
  text-align: center;
}

.top-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-actions {
  grid-column: 1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-button {
  min-height: 32px;
  border-color: #44bf7d;
  background: #176442;
  color: #ddfbe8;
  font-weight: 700;
  font-size: 12px;
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}

.icon-button {
  width: 32px;
  min-width: 32px;
  padding: 0;
}

.copy-folder-button {
  border-color: #44bf7d;
  background: #176442;
}

.copy-folder-button[data-state="copied"] {
  border-color: #44bf7d;
  background: #176442;
}

.copy-folder-button[data-state="error"] {
  border-color: #d99a31;
  background: #734a06;
}

.top-button[data-state="copied"] {
  border-color: #44bf7d;
  background: #176442;
}

.top-button[data-state="error"] {
  border-color: #d99a31;
  background: #734a06;
}

.top-button[hidden] {
  display: none;
}

.eyebrow {
  display: none;
  margin: 0;
  color: #b8c3d5;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.15;
  letter-spacing: 0;
  font-weight: 800;
}

.run-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  color: #dce7f8;
  background: var(--navy-soft);
}

.run-state[data-state="ok"] {
  color: #ddfbe8;
  background: #176442;
  border-color: #44bf7d;
}

.run-state[data-state="warn"] {
  color: #fff0bf;
  background: #734a06;
  border-color: #d99a31;
}

main {
  padding: 12px clamp(10px, 2vw, 20px) 32px;
  display: grid;
  gap: 10px;
}

body.focus-mode main {
  padding-top: 8px;
}

body.focus-mode .control-band {
  display: none;
}

body.focus-mode .tabs {
  display: none;
}

body.focus-mode .workspace {
  border-radius: 4px;
}

body.focus-mode .tab-panel.active {
  padding: 0;
}

body.focus-mode .ranking-shell {
  border: 0;
  border-radius: 0;
  max-height: calc(100vh - 56px);
}

.control-band {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 10px 24px rgba(12, 30, 51, 0.08);
}

.file-zone {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 8px;
}

.import-source {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.42fr);
  gap: 8px;
  align-items: stretch;
}

.file-box {
  min-height: 66px;
  border: 1px dashed #aebbd0;
  border-radius: 6px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  cursor: pointer;
  background: #fbfdff;
}

.file-box[data-dragging="true"] {
  border-color: var(--accent);
  background: #f1fff6;
  box-shadow: inset 0 0 0 1px rgba(22, 133, 87, 0.25);
}

.file-box input {
  display: none;
}

.file-box strong,
.file-box small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-box small {
  color: var(--muted);
  margin-top: 3px;
}

.file-icon {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  color: var(--accent-strong);
}

.direct-import {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  gap: 8px;
  min-height: 66px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.direct-import[data-active="true"] {
  border-color: #44bf7d;
  background: #f1fff6;
}

.direct-paste-button {
  min-height: 30px;
  border-radius: 999px;
  border-color: #44bf7d;
  background: #176442;
  color: #ddfbe8;
  font-size: 12px;
  font-weight: 700;
}

.direct-import > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paste-catcher {
  position: fixed;
  left: -1000px;
  top: 0;
  width: 1px;
  height: 1px;
  min-height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.params-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(108px, 1fr));
  gap: 8px;
  align-items: end;
}

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

.folder-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: flex-end;
}

.folder-actions button {
  min-width: 150px;
  height: 38px;
}

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

.params-grid input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
}

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

.actions button {
  min-width: 150px;
  height: 38px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.kpi,
.import-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  min-height: 78px;
}

.kpi {
  border-width: 0 1px 0 0;
  border-radius: 0;
  min-height: 60px;
  padding: 8px 12px;
}

.kpi:last-child {
  border-right: 0;
}

.kpi span,
.import-tile span,
.import-tile small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi strong,
.import-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.workspace {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tabs {
  display: flex;
  gap: 3px;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfe;
  overflow-x: auto;
}

.tab {
  border-color: transparent;
  background: transparent;
  min-height: 32px;
  white-space: nowrap;
}

.tab.active {
  background: var(--surface-soft);
  color: var(--accent-strong);
  border-color: var(--line);
}

.tab-panel {
  display: none;
  padding: 8px;
}

.tab-panel.active {
  display: block;
}

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 62vh;
  background: var(--surface);
}

.ranking-shell {
  max-height: 68vh;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
}

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

td:first-child,
th:first-child,
td:nth-child(2),
th:nth-child(2) {
  text-align: left;
}

tbody tr:hover {
  background: #fbfbf7;
}

.dashboard-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  min-width: 1240px;
  font-size: 15px;
}

.dashboard-user-col {
  width: 190px;
}

.dashboard-table th,
.dashboard-table td {
  border-bottom: 0;
  height: 32px;
  padding: 6px 9px;
  text-transform: none;
  letter-spacing: 0;
}

.dashboard-table thead th {
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: none;
}

.dashboard-table .dashboard-groups th {
  top: 0;
  z-index: 3;
}

.dashboard-table .dashboard-labels th {
  top: 32px;
  z-index: 2;
}

.dashboard-table th:last-child,
.dashboard-table td:last-child {
  border-right: 0;
}

.dashboard-table .group-ontime {
  background: var(--group-ontime);
}

.dashboard-table .group-nns {
  background: var(--group-nns);
}

.dashboard-table .group-activation {
  background: var(--group-activation);
}

.dashboard-table .group-subs {
  background: var(--group-subs);
}

.dashboard-table .group-maq {
  background: var(--group-maq);
}

.dashboard-table .group-nm {
  background: var(--group-nm);
}

.dashboard-table .group-aos {
  background: var(--group-aos);
  color: #17324d;
}

.dashboard-table .group-orders {
  background: var(--group-orders);
}

.dashboard-table tbody td {
  background: #ffffff;
  color: #000000;
  font-size: 15px;
  border-right: 1px solid transparent;
  border-bottom: 1px solid #edf3f8;
  text-align: center;
}

.dashboard-table tbody tr:nth-child(odd):not(.totals-row) td {
  background: #ffffff;
}

.dashboard-table tbody tr:nth-child(even):not(.totals-row) td {
  background: #eef6fb;
}

.dashboard-table tbody tr:hover td {
  background: #fff9de;
}

.dashboard-table tbody td:first-child {
  text-align: left;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-table tbody td.editable-user {
  cursor: text;
}

.dashboard-table tbody td:not(:first-child) {
  font-weight: 800;
}

.dashboard-table tbody tr.totals-row td {
  background: var(--total-row);
  color: #ffffff;
  border-bottom-color: #343941;
  font-weight: 800;
}

.dashboard-table tbody tr.totals-row:hover td {
  background: var(--total-row);
}

.dashboard-table tbody tr.totals-row td.goal-met {
  background: #2f6b48;
  color: #ffffff;
}

.dashboard-table tbody tr.totals-row td.goal-miss {
  background: var(--total-row);
  color: #ffd58a;
}

.goal-met {
  background: var(--good-bg);
  color: var(--accent-strong);
  font-weight: 800;
}

.goal-miss {
  color: var(--amber);
  font-weight: 800;
}

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

.local-imports {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 12px;
  overflow: hidden;
  background: #fbfdff;
}

.local-imports-header {
  min-height: 42px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fbfe;
  border-bottom: 1px solid var(--line);
}

.local-imports-header strong {
  font-size: 13px;
}

.local-imports-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.local-import-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow: auto;
}

.local-import-list li {
  min-height: 54px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.local-import-list .local-import-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.local-import-list li:last-child {
  border-bottom: 0;
}

.local-import-list strong,
.local-import-list small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-import-list small,
.local-import-detail {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.local-import-detail {
  text-align: right;
  white-space: nowrap;
}

.local-import-icon {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  color: var(--accent-strong);
}

.messages {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.message {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--muted);
  background: #fbfcfa;
}

.message.error {
  border-color: #efb0aa;
  color: var(--red);
  background: #fff3f2;
}

.message.success {
  border-color: #94d5ac;
  color: var(--accent-strong);
  background: #effbf3;
}

.users-panel {
  display: none;
}

.users-panel.active {
  display: grid;
  gap: 12px;
}

.users-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

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

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.5;
  color: var(--ink);
}

@media (max-width: 1120px) {
  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 150px;
  }

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

  .folder-actions {
    flex-wrap: wrap;
  }

  .import-source {
    grid-template-columns: 1fr;
  }

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

  .kpi:nth-child(3n) {
    border-right: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
    align-items: start;
  }

  .title-block,
  .copy-actions,
  .top-actions {
    grid-column: 1;
  }

  .title-block {
    text-align: left;
  }

  .top-actions {
    justify-self: start;
    flex-wrap: wrap;
  }

  .copy-actions {
    justify-self: start;
    flex-wrap: wrap;
  }

  .run-state {
    white-space: normal;
  }

  .import-source,
  .file-zone,
  .params-row,
  .params-grid,
  .import-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .folder-actions,
  .actions {
    flex-direction: column;
  }

  .control-band {
    padding: 10px;
  }

  .kpi {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .kpi:last-child {
    border-bottom: 0;
  }

  .kpi strong,
  .import-tile strong {
    font-size: 20px;
  }

  .local-imports-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .local-import-list li {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .local-import-detail,
  .local-imports-header span {
    text-align: left;
    white-space: normal;
  }
}
