:root {
  --blue: #07377c;
  --blue-dark: #042557;
  --green: #0b7026;
  --green-dark: #064d1a;
  --ink: #162033;
  --muted: #687487;
  --line: #d7dee9;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --danger: #bf2f2f;
  --gold: #ffc53d;
  --silver: #cbd5e1;
  --bronze: #d59b61;
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

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

.sidebar {
  background: #111827;
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #fff;
  border-radius: 8px;
}

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

.brand small {
  color: #b6c2d2;
  margin-top: 2px;
}

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

.nav-button,
.primary-button,
.ghost-button,
.danger-button,
.file-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

.nav-button {
  text-align: left;
  background: transparent;
  color: #dbe6f6;
}

.nav-button.active,
.nav-button:hover {
  background: #263244;
  color: #fff;
}

.sidebar-card {
  margin-top: auto;
  display: grid;
  gap: 8px;
  background: #263244;
  padding: 14px;
  border-radius: 8px;
}

.sidebar-card span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #c9d4e3;
  font-weight: 800;
}

.sidebar-card input,
.date-range input,
.admin-card input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}

main {
  padding: 24px;
  overflow-x: hidden;
}

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

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

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}

.topbar p,
.panel-heading p,
.muted {
  color: var(--muted);
  margin-top: 6px;
}

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

.department-switch {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  background: #e8eef8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  width: max-content;
  max-width: 100%;
}

.department-tab {
  border: 0;
  border-radius: 6px;
  min-height: 38px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 900;
  background: transparent;
  color: #34435c;
}

.department-tab.active {
  background: #174ea6;
  color: #fff;
}

.primary-button {
  background: #174ea6;
  color: #fff;
}

.ghost-button {
  background: #e9eef7;
  color: #1b315d;
}

.danger-button {
  background: var(--danger);
  color: #fff;
  width: max-content;
}

.file-button {
  display: inline-grid;
  place-items: center;
  background: #0f766e;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.import-status {
  background: #fff8dc;
  border: 1px solid #f3d779;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  color: #6f5713;
  font-weight: 700;
}

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

.board {
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(25, 42, 70, 0.08);
}

.board.marketplace {
  --accent: var(--blue);
  --accent-dark: var(--blue-dark);
}

.board.site {
  --accent: var(--green);
  --accent-dark: var(--green-dark);
}

.board-header {
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  color: #fff;
  min-height: 78px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

.board-icon {
  font-size: 34px;
  line-height: 1;
}

.board h2 {
  font-size: clamp(22px, 2.7vw, 34px);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.date-stamp {
  white-space: nowrap;
  font-weight: 900;
}

.table-wrap {
  overflow-x: auto;
  padding: 12px 10px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 760px;
}

th,
td {
  border: 1px solid rgba(22, 32, 51, 0.28);
  text-align: center;
  height: 52px;
  padding: 6px;
}

thead th {
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
  font-size: 12px;
}

tfoot th {
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
  height: 44px;
}

.cutoff {
  color: #fff;
  font-weight: 900;
  font-size: 21px;
}

.cut-1100 {
  background: #68b444;
}

.cut-1200 {
  background: #ff7417;
}

.cut-1300 {
  background: #f4c400;
}

.cut-1400 {
  background: #7d43b4;
}

.carrier-cell {
  font-weight: 900;
  text-transform: uppercase;
}

.carrier-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.carrier-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eaf0f7;
  color: var(--accent);
}

.worker-input {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: center;
  font-weight: 800;
  outline: none;
  min-height: 36px;
}

.time-input {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 6px;
  text-align: center;
  font-weight: 900;
  color: #172033;
  background: rgba(255, 255, 255, 0.9);
}

.cutoff-label {
  display: block;
}

.row-total {
  font-weight: 900;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr 1fr;
  gap: 10px;
  padding: 14px 10px 16px;
}

.summary-card {
  border: 1px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
  min-height: 150px;
}

.summary-card h3 {
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 8px;
  font-size: 14px;
  text-transform: uppercase;
}

.deadline-totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 10px;
}

.deadline-box {
  border: 1px solid var(--line);
  min-height: 62px;
  display: grid;
  align-content: start;
  border-radius: 4px;
  overflow: hidden;
}

.deadline-box span {
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 5px 3px;
  text-align: center;
}

.deadline-box strong {
  font-size: 20px;
  padding-top: 8px;
  text-align: center;
}

.grand-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px 14px;
  text-transform: uppercase;
  font-weight: 900;
}

.grand-line strong {
  border: 1px solid var(--line);
  border-radius: 4px;
  min-width: 80px;
  padding: 8px;
  text-align: center;
}

.checks {
  list-style: none;
  margin: 0;
  padding: 12px 18px;
  display: grid;
  gap: 8px;
  font-weight: 900;
  text-transform: uppercase;
  font-size: 13px;
}

.checks li::before {
  content: "✓";
  color: var(--accent);
  font-size: 20px;
  margin-right: 10px;
}

.notes textarea {
  width: 100%;
  height: 108px;
  border: 0;
  resize: none;
  padding: 12px;
  outline: none;
  background: repeating-linear-gradient(#fff, #fff 23px, #d9dfe8 24px);
}

.history-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.history-list,
.history-detail,
.admin-card,
.ranking-table,
.podium {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.history-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.history-item {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  color: var(--muted);
  margin-top: 4px;
}

.history-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.small-button {
  border: 0;
  border-radius: 6px;
  background: #dde6f5;
  color: #1f3b69;
  font-weight: 800;
  min-height: 34px;
  padding: 0 10px;
  cursor: pointer;
}

.empty-state {
  color: var(--muted);
  display: block;
  text-align: center;
  padding: 40px 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.metric {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.metric span,
.rank-row span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 4px;
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 14px;
  min-height: 250px;
  margin-bottom: 18px;
}

.podium-card {
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  color: #182033;
  border: 1px solid var(--line);
}

.podium-card.first {
  min-height: 210px;
  background: linear-gradient(#fff7cc, #ffe28a);
  order: 2;
}

.podium-card.second {
  min-height: 170px;
  background: linear-gradient(#f8fafc, #dbe4ef);
  order: 1;
}

.podium-card.third {
  min-height: 145px;
  background: linear-gradient(#fff0dd, #e2ad78);
  order: 3;
}

.medal {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  background: #fff;
  font-size: 24px;
  font-weight: 900;
}

.podium-card h3 {
  font-size: 20px;
}

.podium-card strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 70px 1fr 130px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.rank-row:last-child {
  border-bottom: 0;
}

.rank-position {
  font-weight: 900;
  color: #174ea6;
}

.admin-grid {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 18px;
}

.admin-card {
  display: grid;
  gap: 14px;
  align-content: start;
}

.admin-card label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #eef4ff;
  border: 1px solid #cbdaf5;
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 800;
}

.chip button {
  border: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d7e3fa;
  cursor: pointer;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  transform: translateY(120px);
  opacity: 0;
  transition: 0.25s ease;
  max-width: min(380px, calc(100vw - 40px));
  font-weight: 800;
}

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

@media (max-width: 1200px) {
  .boards,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .history-layout {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    min-height: auto;
  }

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

  .topbar-actions,
  .date-range,
  .department-switch {
    width: 100%;
  }

  .department-switch {
    flex-direction: column;
  }

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

  .summary-grid,
  .detail-grid,
  .podium {
    grid-template-columns: 1fr;
  }

  .podium-card.first,
  .podium-card.second,
  .podium-card.third {
    order: initial;
    min-height: auto;
  }

  .rank-row {
    grid-template-columns: 54px 1fr;
  }

  .rank-row strong {
    grid-column: 2;
  }
}
