:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --ink: #111827;
  --green: #059669;
  --red: #e11d48;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar__inner {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 32px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 22px;
  font-weight: 800;
}

.brand h1,
.entry-card h2,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.2;
}

.brand p,
.panel p,
.entry-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.date-pill,
.ghost-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}

.date-pill {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #475569;
}

.ghost-button,
.secondary-button {
  border: 1px solid #cbd5e1;
  background: white;
  color: #334155;
  font-weight: 650;
  transition: background 160ms ease, border-color 160ms ease;
}

.ghost-button:hover,
.secondary-button:hover {
  background: #f8fafc;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 32px 32px;
}

.workspace {
  display: grid;
  gap: 20px;
  min-width: 0;
}

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

.metric-card,
.platform-card,
.panel,
.entry-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card,
.platform-card,
.entry-card,
.panel__header {
  padding: 20px;
}

.metric-card__top,
.platform-card__top,
.entry-card__header,
.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.metric-card__label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.metric-card__value {
  margin-top: 14px;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.metric-card__hint {
  margin-top: 4px;
  color: #94a3b8;
  font-size: 12px;
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

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

.platform-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  font-weight: 800;
}

.platform-title h2 {
  margin: 0;
  font-size: 16px;
}

.platform-title p {
  margin: 4px 0 0;
  color: #94a3b8;
  font-size: 12px;
}

.platform-short {
  border-radius: 6px;
  background: #f1f5f9;
  color: #64748b;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.mini-metric,
.delta-box {
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.mini-metric span,
.delta-box span {
  display: block;
  color: #94a3b8;
  font-size: 12px;
}

.mini-metric strong,
.delta-value {
  display: block;
  margin-top: 4px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.delta-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.delta-up {
  color: var(--green);
}

.delta-down {
  color: var(--red);
}

.delta-flat {
  color: #64748b;
}

.panel {
  overflow: hidden;
}

.panel__header {
  border-bottom: 1px solid var(--line-soft);
}

.panel h2 {
  font-size: 18px;
}

.panel p {
  font-size: 14px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented.compact {
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 4px;
}

.tab-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: #475569;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 650;
}

.compact .tab-button {
  border: 0;
  background: transparent;
}

.tab-button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.compact .tab-button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.chart-empty {
  display: grid;
  min-height: 300px;
  place-items: center;
  color: #64748b;
  text-align: center;
}

.chart-wrap {
  padding: 18px 20px 20px;
}

.chart-scroll {
  overflow-x: auto;
}

.chart {
  width: 100%;
  min-width: 700px;
  height: 300px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #475569;
  font-size: 14px;
}

.legend i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

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

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

thead {
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  text-transform: uppercase;
}

th,
td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fafc;
}

.platform-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 6px 9px;
  font-weight: 700;
}

.sidebar {
  min-width: 0;
}

.entry-card {
  position: sticky;
  top: 20px;
  padding: 20px;
}

.entry-card h2 {
  font-size: 18px;
}

.clock {
  color: #cbd5e1;
  font-size: 24px;
}

.platform-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.platform-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: #334155;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 750;
}

.platform-button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.field-stack {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.field-stack span {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.field-stack input {
  width: 100%;
  height: 48px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  padding: 0 12px;
  font-size: 16px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-stack input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.12);
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  padding: 10px 12px;
}

.secondary-button {
  margin-top: 18px;
}

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

.primary-button {
  margin-top: 12px;
  border: 0;
  background: var(--ink);
  color: white;
  font-weight: 800;
  transition: background 160ms ease;
}

.primary-button:hover {
  background: #273244;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.rule-note,
.notice {
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.rule-note {
  background: #fff7ed;
  color: #9a3412;
}

.notice {
  background: #f1f5f9;
  color: #334155;
}

.empty-row {
  padding: 44px 20px;
  text-align: center;
  color: #64748b;
}

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

  .entry-card {
    position: static;
  }
}

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

  .topbar__inner,
  .panel__header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar__tools {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .topbar__inner,
  .shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand h1 {
    font-size: 20px;
  }

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