:root {
  --bg-from: #fbfdff;
  --bg-mid:  #f3f8fd;
  --bg-to:   #eaf2fb;
  --bg-glow: rgba(116, 170, 235, 0.14);

  --panel:     rgba(255, 255, 255, 0.88);
  --panel-alt: rgba(242, 248, 255, 0.52);
  --line:      #8fa7c3;
  --line-soft: rgba(204, 219, 236, 0.98);

  --text:   #1b2d42;
  --text-2: #304963;
  --muted:  #5f7898;
  --muted-2:#8097b2;

  --navy:   #58779c;
  --navy-2: #84a7cf;

  --green-head:   #deebf8;
  --green-sub:    #edf4fb;
  --green-body:   rgba(234, 243, 252, 0.72);
  --green-softer: rgba(248, 252, 255, 0.62);
  --green-accent: #6387b1;

  --pink-head:   #deebf8;
  --pink-sub:    #edf4fb;
  --pink-body:   rgba(234, 243, 252, 0.72);
  --pink-softer: rgba(248, 252, 255, 0.62);
  --pink-accent: #6387b1;

  --stay-head:  #dbe8f6;
  --stay-sub:   #edf4fb;
  --stay-body:  rgba(235, 243, 251, 0.88);

  --count-head: #d6e6f7;
  --count-sub:  #e8f2fc;
  --count-tiny: rgba(245, 249, 253, 0.92);
  --sum-col-bg: rgba(236, 244, 251, 0.94);
  --count-text: #32506d;

  --current-fill:   rgba(222, 234, 247, 0.98);
  --current-glow:   rgba(99, 135, 177, 0.14);
  --current-stripe: #8cb4df;
  --current-outline: rgba(120, 162, 209, 0.24);

  --white:  #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(900px 280px at 12% -6%, var(--bg-glow) 0%, rgba(146, 176, 210, 0) 72%),
    linear-gradient(180deg, var(--bg-from) 0%, var(--bg-mid) 58%, var(--bg-to) 100%);
  color: var(--text);
  font-family: "Geist", "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11", "palt";
  letter-spacing: 0.005em;
}

:lang(ja),
.event-title,
.top-label,
.card-title,
.metric-label {
  font-family: "Zen Kaku Gothic New", "Geist", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}

.dashboard {
  height: 100vh;
  padding: 12px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  position: relative;
}

/* ============ Topbar ============ */
.topbar {
  display: grid;
  grid-template-columns: 2.6fr 1fr 1fr 1fr 1fr;
  align-items: stretch;
  border: 1px solid rgba(143, 167, 195, 0.58);
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(180deg, rgba(255,255,255,0.88) 0%, rgba(235,244,253,0.8) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.86), 0 12px 26px rgba(77, 121, 170, 0.035);
  padding: 4px 0;
  flex: 0 0 auto;
  backdrop-filter: blur(10px);
}

.top-item {
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px 18px;
  position: relative;
}

.top-item + .top-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: var(--line);
}

.top-item:first-child:not(.top-item--title) { padding-left: 0; }

.top-item--title {
  padding: 14px 0 12px 36px;
  position: relative;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 8px;
  min-height: 82px;
}

.top-item--title::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 16%;
  bottom: 16%;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, #99bbe2 0%, #6e94c2 100%);
  box-shadow: 0 0 0 1px rgba(110, 148, 194, 0.12), 0 0 12px rgba(110, 148, 194, 0.12);
  opacity: 0.9;
  z-index: 0;
}

.top-item--status .top-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-accent);
  animation: live-pulse 1.8s ease-out infinite;
}

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(104, 132, 168, 0.22); }
  70%  { box-shadow: 0 0 0 6px rgba(104, 132, 168, 0); }
  100% { box-shadow: 0 0 0 0 rgba(104, 132, 168, 0); }
}

.sync-icon {
  display: inline-flex;
  align-items: center;
  color: var(--green-accent);
  opacity: 0.8;
}

.top-label {
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
  letter-spacing: 0.14em;
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
}

.top-value {
  font-family: "Geist", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.event-title {
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0.015em;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  position: relative;
  z-index: 1;
}

.event-meta {
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.event-meta .meta-sep { color: var(--muted-2); font-weight: 400; letter-spacing: 0; }
.event-meta .meta-day { font-family: "Geist", system-ui, sans-serif; letter-spacing: 0.06em; }

/* ============ Cards ============ */
.cards {
  display: none;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(30,60,100,0.035), 0 1px 0 rgba(255,255,255,0.9) inset;
  backdrop-filter: blur(8px);
}

.card--flow { grid-template-columns: 1fr; }

.card--flow .card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px;
}

.card-main,
.card-side {
  padding: 8px 14px;
}

.card-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.card-side {
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  background: var(--panel-alt);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.card-title::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green-accent);
  box-shadow: 0 0 6px rgba(16, 196, 182, 0.6);
}

.card--flow .card-title::before {
  background: var(--muted);
  box-shadow: none;
}

.card-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
  font-weight: 500;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.big-value {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding-bottom: 1px;
  align-self: flex-end;
}

.big-number {
  font-family: "Geist", system-ui, sans-serif;
  font-size: 40px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.big-unit {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
  padding-bottom: 5px;
}

.metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line-soft);
}

.metric:first-child { border-top: none; padding-top: 0; }

.metric-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.metric-value {
  font-family: "Geist", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.accent-green { color: var(--green-accent); }
.accent-pink  { color: var(--pink-accent); }

/* ============ Flow card ============ */
.flow-rows { display: flex; flex-direction: column; gap: 3px; }

.flow-rows--inline {
  flex-direction: row;
  align-items: stretch;
  gap: 0;
}

.flow-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 3px;
  border-top: 1px solid var(--line-soft);
}

.flow-rows--inline .flow-row {
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 0 10px;
  border-top: none;
  border-left: 1px solid var(--line-soft);
}

.flow-rows--inline .flow-row:first-child { padding-left: 0; border-left: none; }
.flow-row:first-child { border-top: none; padding-top: 0; }

.flow-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.flow-value {
  font-family: "Geist", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.flow-value .flow-unit { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.flow-value.is-up   { color: var(--green-accent); }
.flow-value.is-down { color: var(--pink-accent); }

/* ============ Table ============ */
.table-shell {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  box-shadow: 0 10px 24px rgba(77, 121, 170, 0.04);
  backdrop-filter: blur(12px);
  margin-top: 8px;
  position: relative;
}

table {
  width: 100%;
  height: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  position: relative;
  z-index: 1;
}

.grid-overlay {
  display: none;
  position: absolute;
  inset: 0 auto auto 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}

.grid-line {
  position: absolute;
  background: rgba(190, 206, 224, 0.96);
}

.grid-line--v {
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-1px);
}

.grid-line--h {
  left: 0;
  right: 0;
  height: 2px;
  transform: translateY(-1px);
}

th, td {
  position: relative;
  text-align: center;
  padding: 10px 7px;
  font-size: 18px;
  line-height: 1.1;
  color: var(--text);
  background: #fbfdff;
}

/* Draw the right and bottom grid lines as inset gradients on each cell.
   Old Android TV WebViews drop sub-pixel CSS borders at column edges with
   border-collapse, so we paint the lines inside the cell box where the
   renderer can't trim them. */
th::after,
td::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(100% - 2px), var(--line-soft) calc(100% - 2px)),
    linear-gradient(to bottom, transparent calc(100% - 2px), var(--line-soft) calc(100% - 2px));
  z-index: 2;
}

th:last-child::after,
td:last-child::after {
  background:
    linear-gradient(to bottom, transparent calc(100% - 2px), var(--line-soft) calc(100% - 2px));
}

tbody tr:last-child td::after {
  background:
    linear-gradient(to right, transparent calc(100% - 2px), var(--line-soft) calc(100% - 2px));
}

tbody tr:last-child td:last-child::after {
  background: none;
}

/* Drop the rule between the header block and the table body
   (covers both the normal last-row cells and the rowspan="3" cells
   whose visual bottom edge lands at the thead/tbody boundary). */
thead tr:last-child th::after,
thead th[rowspan]::after {
  background:
    linear-gradient(to right, transparent calc(100% - 2px), var(--line-soft) calc(100% - 2px));
}
thead tr:last-child th:last-child::after,
thead th[rowspan]:last-child::after {
  background: none;
}

/* Vertical column dividers in the header — drawn via inset box-shadow
   because the gradient ::after pseudo-elements above don't render on
   the target Android TV WebView. Stacks on top of background so the
   lines stay visible regardless of which header tone the cell uses. */
thead th {
  box-shadow: inset -1px 0 0 #8aa4c4;
}
thead th:last-child {
  box-shadow: none;
}
/* Horizontal divider between the header block and the table body —
   2px line on the cells whose bottom edge lands at the thead/tbody
   boundary (the last header row plus the rowspan cells). */
thead tr:last-child th,
thead th[rowspan] {
  box-shadow: inset -1px 0 0 #8aa4c4, inset 0 -2px 0 #8aa4c4;
}
thead tr:last-child th:last-child,
thead th[rowspan]:last-child {
  box-shadow: inset 0 -2px 0 #8aa4c4;
}
thead th.time-head {
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.22), inset 0 -2px 0 #8aa4c4;
}

/* Body column dividers — lighter than the header rules so the header
   reads as the dominant structural element. */
tbody td {
  box-shadow: inset -2px 0 0 #b6c5d8;
}
tbody td:last-child {
  box-shadow: none;
}
tbody td.time-col {
  box-shadow: inset -2px 0 0 rgba(255,255,255,0.16);
}

.group-head {
  font-size: 14px;
  font-weight: 700;
  padding: 10px 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sub-head {
  font-size: 14px;
  font-weight: 600;
  padding: 8px 3px;
  letter-spacing: 0.03em;
}

.tiny-head {
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 3px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.time-head {
  background: linear-gradient(180deg, #6f90b8 0%, #58779c 100%);
  color: #ffffff;
  font-size: 15px;
  letter-spacing: 0.16em;
  font-weight: 700;
  text-transform: uppercase;
}
.time-head::after {
  background:
    linear-gradient(to right, transparent calc(100% - 2px), rgba(255,255,255,0.16) calc(100% - 2px)),
    linear-gradient(to bottom, transparent calc(100% - 2px), var(--line-soft) calc(100% - 2px));
}

.queue-head {
  background: rgba(236, 243, 250, 0.82);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.stay-head {
  background: var(--stay-head);
  color: var(--count-text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.group-head.entry-head { background: linear-gradient(180deg, var(--count-head) 0%, #d4e2f1 100%); color: var(--count-text); }
.group-head.exit-head  { background: linear-gradient(180deg, var(--count-head) 0%, #d4e2f1 100%); color: var(--count-text); }

.sub-head.entry-head { background: rgba(234, 241, 248, 0.98); color: var(--count-text); }
.sub-head.exit-head  { background: rgba(234, 241, 248, 0.98); color: var(--count-text); }

.tiny-head.entry-head { background: var(--count-tiny); color: var(--count-text); }
.tiny-head.exit-head  { background: var(--count-tiny); color: var(--count-text); }

.sub-head.sum-col-header {
  background: linear-gradient(180deg, #d9e6f4 0%, #d0deed 100%);
  color: var(--count-text);
  letter-spacing: 0.04em;
  font-weight: 700;
}

.tiny-head.sum-col-header {
  background: rgba(230, 238, 247, 0.98);
  color: var(--count-text);
  font-weight: 600;
}

.time-col {
  background: linear-gradient(180deg, rgba(111, 144, 184, 0.98) 0%, rgba(88, 119, 156, 0.98) 100%);
  color: rgba(255,255,255,0.96);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.03em;
  width: 88px;
  font-variant-numeric: tabular-nums;
}

.queue-col { width: 118px; }

.sum-col {
  background: #dde8f3;
  font-weight: 700;
  color: var(--count-text);
}

.stay-col {
  background: #dde8f3;
  font-weight: 700;
  color: var(--text);
}

tbody td { font-variant-numeric: tabular-nums; font-weight: 400; color: var(--text-2); }
tbody td:not(.time-col) { font-size: 19px; }
tbody td.time-col { color: rgba(255,255,255,0.96); }
tbody td.sum-col, tbody td.stay-col { color: var(--text); }

tbody tr:hover td:not(.time-col):not(.sum-col):not(.stay-col) {
  background: rgba(237, 244, 251, 0.68);
}

tbody tr:nth-child(even) td:not(.time-col):not(.sum-col):not(.stay-col) {
  background: #e0e8f1;
}

/* ---- Current row ---- */
/* No background of its own — the focus row inherits the zebra rhythm and
   stands out via row height + a thick top/bottom bracket + larger type. */
.current-row td {
  font-weight: 700;
  color: var(--text);
  font-size: 34px;
  padding-top: 17px;
  padding-bottom: 17px;
  box-shadow:
    inset 0 2px 0 #7a96b8,
    inset 0 -2px 0 #7a96b8,
    inset -2px 0 0 #b6c5d8;
}
.current-row td:last-child {
  box-shadow:
    inset 0 2px 0 #7a96b8,
    inset 0 -2px 0 #7a96b8;
}

.current-row .time-col { font-size: 24px; }
.current-row .stay-col { font-size: 28px; }
.current-row .sum-col { font-size: 26px; }

.current-row .time-col {
  background: linear-gradient(180deg, rgba(124, 157, 198, 0.98) 0%, rgba(97, 132, 176, 0.98) 100%);
  color: #ffffff;
  position: relative;
  box-shadow:
    inset 0 2px 0 #7a96b8,
    inset 0 -2px 0 #7a96b8,
    inset -2px 0 0 rgba(255,255,255,0.16);
}
.current-row .time-col::after {
  background:
    linear-gradient(to right, transparent calc(100% - 2px), rgba(255,255,255,0.16) calc(100% - 2px)),
    linear-gradient(to bottom, transparent calc(100% - 2px), var(--line-soft) calc(100% - 2px));
}

.current-row .time-col::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--current-stripe);
  box-shadow: 0 0 10px rgba(142, 168, 199, 0.65);
  animation: stripe-breathe 2.6s ease-in-out infinite;
}

@keyframes stripe-breathe {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--current-stripe); }
  50%       { opacity: 0.7; box-shadow: 0 0 18px var(--current-stripe); }
}

.current-row td.cell-pending {
  position: relative;
  overflow: hidden;
}

.current-row td.cell-pending::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(132, 164, 198, 0.56) 0 2px, transparent 2.5px) 0 50% / 6px 6px no-repeat,
    radial-gradient(circle, rgba(132, 164, 198, 0.56) 0 2px, transparent 2.5px) 9px 50% / 6px 6px no-repeat,
    radial-gradient(circle, rgba(132, 164, 198, 0.56) 0 2px, transparent 2.5px) 18px 50% / 6px 6px no-repeat;
  animation: pending-dots 1.2s ease-in-out infinite;
}

@keyframes pending-dots {
  0%, 100% {
    opacity: 0.45;
    filter: none;
  }
  50% {
    opacity: 0.92;
    filter: saturate(0.9);
  }
}

/* Keep legacy keyframes for fallback parity in older deployed caches. */
@keyframes pending-shimmer {
  0% {
    opacity: 0.45;
    background-position: 100% 50%;
  }
  50% {
    opacity: 0.9;
    background-position: 0% 50%;
  }
  100% {
    opacity: 0.45;
    background-position: 100% 50%;
  }
}

.row-muted td { color: color-mix(in srgb, var(--muted-2) 84%, white); }
.row-muted td.time-col { color: rgba(255,255,255,0.45); }
.row-muted td.sum-col, .row-muted td.stay-col { color: var(--muted); }

.placeholder {
  padding: 60px 20px !important;
  color: var(--muted);
  font-size: 13px;
  background: var(--panel) !important;
  border: none !important;
}

.fetch-meta { display: none; }

@media (max-width: 1400px) {
  .event-title { font-size: 17px; }
  .big-number  { font-size: 28px; }
  th, td { font-size: 11.5px; padding: 3px 4px; }
  .dashboard { padding: 8px 14px; }
}

