@import url("https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --bg: #0d1117;
  --surface: #121821;
  --surface-raised: #161e29;
  --surface-muted: #0f151d;
  --border: #263241;
  --border-strong: #354557;
  --text: #edf2f7;
  --muted: #9aa8b6;
  --muted-strong: #c0cad4;
  --accent: #5dd3c8;
  --accent-strong: #2fb7ad;
  --good: #62d26f;
  --warn: #f1b95e;
  --danger: #f47067;
  --shadow: rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(25, 34, 45, 0.72), rgba(13, 17, 23, 0) 260px),
    var(--bg);
  font-family: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 18px 14px 28px;
  display: grid;
  gap: 12px;
}

.shell > *,
.grid > *,
.filters > *,
.hero-top > *,
.panel-head > * {
  min-width: 0;
}

.hero {
  padding: 2px 2px 4px;
}

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

.hero h1 {
  margin: 1px 0 3px;
  font-size: clamp(1.45rem, 3.2vw, 2rem);
  line-height: 1.08;
}

.eyebrow,
label,
.panel-head small,
.refresh-meta,
.event-list .meta,
.kv-list dt {
  font-family: "IBM Plex Mono", monospace;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 62ch;
  overflow-wrap: anywhere;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.logout-form {
  margin: 0;
}

.lang-btn {
  min-width: 38px;
  border: 0;
  border-radius: 5px;
  padding: 7px 8px;
  background: transparent;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  cursor: pointer;
}

.lang-btn.is-active {
  background: var(--accent);
  color: #061313;
  font-weight: 700;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 10px 24px var(--shadow);
}

.panel h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.panel-head-stack {
  align-items: flex-start;
}

.panel-head small,
.refresh-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.panel-copy {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.filters {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  background: rgba(18, 24, 33, 0.96);
  backdrop-filter: blur(12px);
}

.field {
  display: grid;
  gap: 4px;
}

.field-wide,
.refresh-meta {
  grid-column: 1 / -1;
}

label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
}

input,
select,
.btn {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 9px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.92rem;
}

input::placeholder {
  color: #748292;
}

input:focus-visible,
select:focus-visible,
.btn:focus-visible,
.lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: #061313;
  font-weight: 700;
}

.btn:hover {
  background: #76e1d8;
}

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

.btn-secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--muted-strong);
}

.btn-secondary:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.btn-compact {
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
}

.refresh-meta {
  margin: -1px 0 0;
}

.login-shell {
  min-height: 100vh;
  width: min(100%, 420px);
  margin: 0 auto;
  padding: 28px 16px;
  display: grid;
  align-content: center;
}

.login-panel h1 {
  margin: 4px 0 18px;
  font-size: 1.75rem;
}

.login-form {
  display: grid;
  gap: 12px;
}

.auth-error {
  margin: 0;
  color: #ffe1df;
  background: rgba(244, 112, 103, 0.16);
  border: 1px solid rgba(244, 112, 103, 0.5);
  border-radius: 6px;
  padding: 9px 10px;
  overflow-wrap: anywhere;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

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

.metric-grid div {
  min-height: 76px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px;
  background: var(--surface-muted);
  display: grid;
  align-content: space-between;
  gap: 7px;
}

.metric-grid div:nth-child(3),
.metric-grid div:nth-child(5) {
  border-left: 3px solid var(--good);
}

.metric-grid div:nth-child(4),
.metric-grid div:nth-child(6) {
  border-left: 3px solid var(--danger);
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.metric-grid strong {
  font-size: 1.28rem;
  line-height: 1;
}

.kv-list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 8px 10px;
}

.kv-list dt {
  color: var(--muted);
  font-size: 0.76rem;
}

.kv-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #1b2530;
  border: 1px solid var(--border-strong);
  color: var(--muted-strong);
  font-size: 0.84rem;
}

.status-badge.is-good {
  border-color: rgba(98, 210, 111, 0.45);
  background: rgba(98, 210, 111, 0.12);
  color: #b8f4be;
}

.status-badge.is-danger {
  border-color: rgba(244, 112, 103, 0.52);
  background: rgba(244, 112, 103, 0.13);
  color: #ffc7c3;
}

.status-badge.is-warn {
  border-color: rgba(241, 185, 94, 0.48);
  background: rgba(241, 185, 94, 0.13);
  color: #ffe0ad;
}

.current-tools {
  margin: 0 0 10px;
  max-width: 360px;
}

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

.daily-table-wrap,
.current-table-wrap {
  max-height: 330px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
  scrollbar-gutter: stable;
}

.current-table-wrap {
  max-height: 380px;
}

.daily-table-wrap table,
.current-table-wrap table,
table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.daily-table-wrap th,
.current-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #19222d;
}

th,
td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
  vertical-align: top;
}

th {
  color: var(--muted-strong);
  font-size: 0.75rem;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  text-transform: uppercase;
}

tbody tr {
  transition: background-color 0.14s ease;
}

tbody tr:hover {
  background: #1a2633;
}

tbody tr.is-selected {
  background: rgba(93, 211, 200, 0.16);
}

.daily-table-wrap tbody tr {
  cursor: pointer;
}

.event-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 250px;
  overflow-y: auto;
  display: grid;
  gap: 7px;
}

.event-list li {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px;
  display: grid;
  gap: 2px;
  background: var(--surface-muted);
}

.event-copy {
  margin: 0;
  line-height: 1.4;
}

.event-list .meta {
  color: var(--muted);
  font-size: 0.74rem;
}

.event-list .lost {
  color: var(--danger);
}

.ig-link {
  color: #9de7df;
  text-decoration: none;
}

.ig-link:hover {
  color: #c9fff9;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ig-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: 88vw;
  background: #c7433a;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  padding: 10px 12px;
  font-weight: 700;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

@media (min-width: 760px) {
  .shell {
    padding: 20px 22px 36px;
  }

  .filters {
    grid-template-columns: minmax(190px, 1.45fr) minmax(150px, 1fr) minmax(92px, 0.52fr) minmax(108px, 0.62fr) minmax(180px, 0.95fr);
  }

  .field-wide {
    grid-column: auto;
  }

  .refresh-meta {
    grid-column: 1 / -1;
  }

  .grid {
    grid-template-columns: 0.78fr 1.22fr;
  }

  .daily-table-wrap {
    max-height: 400px;
  }

  .current-table-wrap {
    max-height: 500px;
  }
}

@media (max-width: 759px) {
  .shell {
    gap: 10px;
  }

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

  .logout-form {
    grid-column: 2;
    grid-row: 2;
  }

  .hero-top > div:first-child {
    grid-column: 1 / -1;
  }

  .lang-switch {
    justify-self: start;
  }

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

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

  .kv-list {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  th,
  td {
    padding: 7px;
    font-size: 0.8rem;
  }
}
