:root {
  color-scheme: light;
  --bg: #f8f8f8;
  --surface: #ffffff;
  --surface-2: #fff1f2;
  --ink: #241113;
  --muted: #7a6164;
  --line: #f0d4d7;
  --green: #c1121f;
  --green-dark: #9f0f19;
  --gold: #c1121f;
  --blue: #2563eb;
  --red: #b42318;
  --shadow: 0 18px 45px rgba(23, 33, 27, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 750;
}

button:hover {
  background: var(--green-dark);
}

button.ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

button.ghost:hover {
  border-color: var(--green);
  color: var(--green);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #7f1d1d;
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: #c1121f;
  font-weight: 950;
  font-size: 24px;
}

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

.brand span,
.login-box p {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  margin: 2px 0 0;
}

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

.nav-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  min-height: 44px;
  padding: 0 12px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item span {
  width: 20px;
  text-align: center;
  color: #ffffff;
}

.login-box {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.login-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.login-row input {
  min-width: 0;
}

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

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

.topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 34px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 850;
}

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

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

.period-picker select {
  min-width: 150px;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.screen-mode {
  background: #7f1d1d;
}

.screen-mode .app-shell {
  display: block;
}

.screen-mode .sidebar,
.screen-mode .topbar {
  display: none;
}

.screen-mode .workspace {
  padding: 0;
}

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

.kpi,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  border-top: 4px solid var(--green);
  box-shadow: var(--shadow);
}

.kpi {
  padding: 18px;
  min-height: 118px;
}

.kpi span,
.kpi small {
  display: block;
  color: var(--muted);
}

.kpi strong {
  display: block;
  margin: 12px 0 6px;
  font-size: 30px;
}

.dashboard-grid,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(340px, 0.8fr);
  gap: 14px;
}

.wide-panel {
  grid-column: 1 / -1;
}

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

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

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

.podium-card {
  min-height: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f6faf7 100%);
}

.podium-card.first {
  background: linear-gradient(180deg, #fff1f2 0%, #ffffff 100%);
  border-color: #c1121f;
}

.rank-badge {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 28px;
  border-radius: 8px;
  background: #13231e;
  color: white;
  font-weight: 900;
}

.quick-board {
  display: grid;
  gap: 10px;
}

.quick-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) repeat(3, minmax(145px, 1fr)) minmax(110px, .6fr);
  gap: 10px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.quick-cell {
  display: grid;
  gap: 8px;
  align-content: center;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
  min-height: 88px;
}

.quick-cell strong {
  font-size: 24px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 40px 40px;
  gap: 6px;
}

.quick-actions button {
  min-height: 36px;
  padding: 0;
  font-size: 18px;
}

.quick-total {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #7f1d1d;
  color: white;
  text-align: center;
  padding: 10px;
}

.quick-total strong {
  display: block;
  font-size: 28px;
}

.person-line {
  display: flex;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--green);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
  flex: 0 0 auto;
}

.muted {
  color: var(--muted);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.metric-row span {
  padding: 9px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.metric-row strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
}

.team-race,
.announcement-list,
.compact-list {
  display: grid;
  gap: 10px;
}

.screen-stage {
  min-height: 100vh;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(127, 29, 29, .96), rgba(193, 18, 31, .92)),
    #7f1d1d;
  color: white;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
}

.screen-hero {
  min-height: 112px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
}

.screen-kicker {
  margin: 0 0 6px;
  font-weight: 900;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .78);
}

.screen-hero h2 {
  margin: 0;
  font-size: 58px;
  line-height: 1;
  letter-spacing: 0;
}

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

.screen-summary span,
.screen-exit {
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 8px;
  padding: 10px 14px;
  color: white;
  background: rgba(255, 255, 255, .12);
  backdrop-filter: blur(10px);
}

.screen-summary strong {
  font-size: 24px;
}

.screen-exit {
  display: grid;
  place-items: center;
}

.screen-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 14px;
}

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

.screen-podium-card,
.screen-team-card,
.screen-board {
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  box-shadow: 0 22px 55px rgba(80, 0, 8, .25);
}

.screen-podium-card {
  min-height: 150px;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 8px;
  border-top: 8px solid #c1121f;
}

.screen-podium-card span {
  color: #c1121f;
  font-weight: 950;
  text-transform: uppercase;
}

.screen-podium-card strong {
  font-size: 36px;
  line-height: 1;
}

.screen-podium-card div {
  color: var(--muted);
  font-size: 20px;
  font-weight: 850;
}

.screen-podium-card.place-1 {
  background: #fff7f7;
}

.screen-teams {
  display: grid;
  gap: 10px;
}

.screen-team-card {
  padding: 16px;
}

.screen-team-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.screen-team-card strong {
  font-size: 24px;
}

.screen-team-card span {
  color: var(--muted);
  font-weight: 900;
}

.screen-board {
  overflow: hidden;
}

.screen-board-head,
.screen-row {
  display: grid;
  grid-template-columns: 76px minmax(260px, 1.5fr) repeat(3, minmax(140px, 1fr)) minmax(150px, 1fr);
  gap: 0;
  align-items: center;
}

.screen-board-head {
  min-height: 54px;
  background: #241113;
  color: white;
  font-weight: 950;
  text-transform: uppercase;
}

.screen-board-head span,
.screen-row > div {
  padding: 12px 16px;
}

.screen-row {
  min-height: 96px;
  border-bottom: 1px solid var(--line);
}

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

.screen-rank {
  font-size: 32px;
  font-weight: 950;
  color: #c1121f;
}

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

.screen-avatar {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  color: white;
  display: grid;
  place-items: center;
  font-weight: 950;
}

.screen-seller strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.screen-seller small {
  color: var(--muted);
  font-weight: 800;
}

.screen-day strong,
.screen-total strong {
  display: block;
  font-size: 30px;
}

.screen-total {
  background: #fff1f2;
  min-height: 96px;
}

.screen-meter {
  height: 12px;
  border-radius: 999px;
  background: #f1d0d4;
  overflow: hidden;
  margin-top: 8px;
}

.screen-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #c1121f;
}

.team-item,
.list-item,
.announcement {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.team-top,
.list-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.bar {
  height: 9px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 10px;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.announcement.gold {
  border-color: #e9c56d;
  background: #fff9ec;
}

.announcement.green {
  border-color: #9fd5c9;
  background: #f0fbf8;
}

.announcement.blue {
  border-color: #bdd1ff;
  background: #f3f6ff;
}

.table-wrap {
  overflow-x: auto;
}

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

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

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

.search-input {
  max-width: 300px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.check-row {
  align-content: end;
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink) !important;
}

.check-row input {
  width: auto;
  min-height: 0;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.item-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.danger {
  color: var(--red) !important;
  border-color: #f1b8b4 !important;
}

.status-pill,
.team-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
  background: var(--surface-2);
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #13231e;
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}

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

.hidden,
.admin-only.hidden {
  display: none !important;
}

.admin-warning {
  margin: 0 0 14px;
  padding: 12px;
  border-radius: 8px;
  background: #fff9ec;
  color: #8a5c0f;
  border: 1px solid #e9c56d;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .split-grid,
  .screen-grid,
  .quick-row {
    grid-template-columns: 1fr;
  }

  .screen-board-head,
  .screen-row {
    grid-template-columns: 54px minmax(210px, 1.2fr) repeat(3, minmax(100px, 1fr)) minmax(110px, 1fr);
  }

  .screen-hero {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .workspace {
    padding: 18px;
  }

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

  .topbar h1 {
    font-size: 27px;
  }

  .topbar-actions,
  .podium,
  .screen-podium,
  .kpi-grid,
  .form-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .screen-stage {
    padding: 16px;
  }

  .screen-board {
    overflow-x: auto;
  }

  .screen-board-head,
  .screen-row {
    min-width: 820px;
  }

  .screen-hero h2 {
    font-size: 38px;
  }

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