:root {
  --accent: #24a9a7;
  --accent-strong: #1e8e8c;
  --accent-soft: rgba(36, 169, 167, 0.12);
  --bg: #ffffff;
  --bg-soft: #f7f8f9;
  --border: #e6e8eb;
  --text: #1a1f24;
  --text-muted: #6b7480;
  --text-faint: #9aa3ad;
  --grid-line: #f0f1f3;
  --positive: #1f9d78;
  --negative: #d24b4b;
  --warn: #d98c2b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 6px;
}
:root[data-theme="dark"] {
  --accent: #2dc7c4;
  --accent-strong: #24a9a7;
  --accent-soft: rgba(45, 199, 196, 0.18);
  --bg: #0f1216;
  --bg-soft: #181c22;
  --border: #2a2f37;
  --text: #f1f4f8;
  --text-muted: #c6cdd5;
  --text-faint: #8b95a1;
  --grid-line: #232830;
  --positive: #37c493;
  --negative: #e26b6b;
  --warn: #e0a24e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Top bar + tabbed navigation ---------------- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Roboto', sans-serif;
  font-size: 22.5px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}
.tabs {
  display: flex;
  gap: 2px;
  height: 100%;
  align-items: stretch;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 100%;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: #0276be; }
.tab.disabled { color: var(--text-faint); cursor: default; }
.tab .soon {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 6px;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline-block; }

/* ---------------- Layout ---------------- */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  min-height: calc(100vh - 56px);
}
.sidebar {
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  /* Keep the section nav in view while the tables scroll. `align-self: start`
     shrinks the grid item to its content so sticky has room to work. */
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}
.sidebar-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint); padding: 0 12px 10px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius);
  color: var(--text); border-left: 2px solid transparent; margin-left: -2px;
}
.sidebar-item:hover { background: var(--bg-soft); text-decoration: none; }
.sidebar-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.sidebar-item.active .sidebar-num { color: var(--accent); }
.sidebar-num { font-family: 'Roboto Mono', monospace; font-size: 12px; color: var(--text-faint); font-weight: 500; }
.sidebar-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sidebar-title { font-size: 13px; font-weight: 500; }
.sidebar-sub { font-size: 11px; color: var(--text-muted); }

main { padding: 28px 32px 64px; width: 100%; min-width: 0; }

.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 22px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 13.5px; max-width: 720px; line-height: 1.5; }

/* ---------------- Company header ---------------- */
.co-header { margin-bottom: 18px; }
.co-id { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.co-id h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.co-jp { font-size: 13px; color: var(--text-faint); }
.co-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.co-meta .pill.mono { font-family: 'Roboto Mono', monospace; }
.co-sk { font-size: 12px; font-weight: 500; }
.co-change { font-size: 12px; color: var(--text-muted); }
.co-change:hover { color: var(--accent); }

/* ---------------- Panels (one per table) ---------------- */
.panel { margin-bottom: 22px; }
.panel-head {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel-head .titles { min-width: 0; }
.panel-title {
  font-size: 15.5px; font-weight: 600; margin: 0 0 3px;
  display: flex; align-items: center; gap: 8px;
}
.panel-jp { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.panel-desc { font-size: 12.5px; color: var(--text-muted); margin: 0; max-width: 640px; line-height: 1.45; }
/* Filters / refine controls sit left-aligned on their own row below the title */
.panel-controls {
  margin-left: 0; flex-basis: 100%;
  display: flex; align-items: center; justify-content: flex-start;
  gap: 10px; flex-wrap: wrap; margin-top: 4px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---------------- Controls ---------------- */
.field-search {
  position: relative; display: inline-flex; align-items: center;
}
.field-search svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--text-faint); pointer-events: none; }
input[type="text"], input[type="search"], input[type="number"], select {
  padding: 7px 11px; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 13px; color: var(--text); background: var(--bg); outline: none;
  transition: border-color .15s;
}
.field-search input { padding-left: 30px; min-width: 300px; }
input:focus, select:focus { border-color: var(--accent); }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); text-transform: none; letter-spacing: 0; margin: 0; }
label.inline input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.ctl-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  background: var(--accent); color: #fff; border: 0;
  transition: opacity .15s, filter .15s;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg-soft); filter: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg button {
  background: var(--bg); color: var(--text-muted); border: 0; border-right: 1px solid var(--border);
  padding: 6px 12px; font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent); color: #fff; }
.seg button:hover:not(.active) { background: var(--bg-soft); color: var(--text); }

/* ---------------- Tables ---------------- */
/* Fit to the available width — text cells wrap, numeric cells stay compact,
   so tables don't need horizontal scrolling (the overflow guard remains as a
   safety net for very narrow screens). */
.table-scroll { width: 100%; overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto;
}
table.data thead th {
  position: sticky; top: 0;
  background: var(--bg-soft);
  text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--text-muted);
  padding: 9px 10px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
table.data thead th.no-sort { cursor: default; }
table.data thead th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data thead th .arrow { color: var(--accent); font-size: 10px; margin-left: 3px; }
table.data tbody td {
  padding: 9px 10px; border-bottom: 1px solid var(--grid-line);
  color: var(--text); white-space: normal; vertical-align: middle;
  overflow-wrap: anywhere;
}
/* keep compact tokens on one line */
table.data td .pill, table.data td .mono, table.data td .co-code { white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg-soft); }
td.wrap, th.wrap { white-space: normal; min-width: 130px; }
.mono { font-family: 'Roboto Mono', monospace; font-size: 12px; color: var(--text-muted); }

/* ---------------- Section sub-navigation ---------------- */
.subnav {
  position: sticky; top: 56px; z-index: 20;
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 12px 0; margin-bottom: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.subnav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 20px;
  font-size: 12.5px; font-weight: 500; color: #0276be;
  background: rgba(2, 118, 190, 0.098); border: 0;
  white-space: nowrap; cursor: pointer;
}
.subnav a:hover { background: rgba(2, 118, 190, 0.18); text-decoration: none; }
.subnav a.active { color: #fff; background: #0276be; border: 0; }
.subnav a.active:hover { background: #0276be; }
.subnav a .jp { font-size: 10px; opacity: 0.7; font-weight: 400; }
.panel { scroll-margin-top: 118px; }

/* company link cell */
.co { display: inline-flex; flex-direction: column; gap: 1px; min-width: 0; }
.co-name { font-weight: 500; color: var(--text); }
a.co-name:hover { color: var(--accent); }
.co-code { font-family: 'Roboto Mono', monospace; font-size: 11px; color: var(--text-faint); }
.co-link-icon { width: 11px; height: 11px; opacity: .55; margin-left: 4px; vertical-align: -1px; }
a.co-name:hover .co-link-icon { opacity: 1; }

/* value coloring */
.pos { color: var(--positive); font-weight: 500; }
.neg { color: var(--negative); font-weight: 500; }

/* pills / badges */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 11px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
  background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border);
}
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.pos { background: rgba(31,157,120,.14); color: var(--positive); border-color: transparent; }
.pill.neg { background: rgba(210,75,75,.14); color: var(--negative); border-color: transparent; }
.pill.warn { background: rgba(217,140,43,.16); color: var(--warn); border-color: transparent; }
.pill.high { background: rgba(210,75,75,.14); color: var(--negative); border-color: transparent; }
.pill.medium { background: rgba(217,140,43,.16); color: var(--warn); border-color: transparent; }
.pill.low { background: var(--bg-soft); color: var(--text-muted); }

/* clickable cell (e.g. view proposal detail) */
table.data td.clickable { cursor: pointer; }
table.data td.clickable:hover { background: var(--accent-soft); }
.cell-en { font-weight: 500; color: var(--text); }
.cell-jp { display: block; font-size: 11px; color: var(--text-faint); margin-top: 1px; }
td.clickable:hover .cell-en { color: var(--accent); }
.cell-more { font-size: 10px; color: var(--accent); margin-left: 4px; opacity: 0; }
td.clickable:hover .cell-more { opacity: 1; }

/* ---------------- Summary tiles ---------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 4px; }
.tile { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-v { font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.tile-k { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); margin-top: 4px; }

/* ---------------- Chart ---------------- */
.chart-wrap { position: relative; height: 420px; padding: 4px; }
@media (max-width: 640px) { .chart-wrap { height: 300px; } }

/* ---------------- Expandable sections (filing/report text) ---------------- */
details.sec { border-bottom: 1px solid var(--grid-line); padding: 8px 0; }
details.sec:last-child { border-bottom: 0; }
details.sec > summary { cursor: pointer; font-weight: 500; font-size: 13.5px; list-style: none; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: '▸'; color: var(--accent); margin-right: 8px; font-size: 11px; }
details.sec[open] > summary::before { content: '▾'; }
.sec-text { margin-top: 8px; font-size: 13px; line-height: 1.6; color: var(--text-muted); white-space: normal; max-height: 340px; overflow-y: auto; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 14, 18, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3); width: 100%; max-width: 540px;
  max-height: 85vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-x {
  background: transparent; border: 0; color: var(--text-muted); font-size: 22px;
  line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-x:hover { color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-body .dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13px; }
.modal-body .dl dt { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; }
.modal-body .dl dd { margin: 0; color: var(--text); }
.modal-body .prop-en { font-size: 15px; font-weight: 500; margin: 0 0 4px; }
.modal-body .prop-jp { font-size: 13px; color: var(--text-muted); margin: 0 0 16px; line-height: 1.5; }
.votebar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 6px 0 4px; background: var(--bg-soft); }
.votebar .vf { background: var(--positive); }
.votebar .va { background: var(--negative); }
.votebar .vb { background: var(--text-faint); }
.votekey { display: flex; gap: 14px; font-size: 11px; color: var(--text-muted); }
.votekey b { color: var(--text); font-weight: 500; }

/* ---------------- Table footer / pagination ---------------- */
.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted); flex-wrap: wrap;
}
.foot-right { display: inline-flex; align-items: center; gap: 12px; }
.view-more {
  background: transparent; border: 1px solid var(--border); color: var(--accent);
  border-radius: var(--radius); padding: 6px 14px; font-size: 12.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background .12s, border-color .12s;
}
.view-more:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.view-more:disabled { opacity: .6; cursor: default; }
.pager { display: inline-flex; align-items: center; gap: 8px; }
.pager button {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 5px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.pager button:hover:not(:disabled) { background: var(--bg-soft); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.meta-note { font-size: 11px; color: var(--text-faint); }

/* ---------------- States ---------------- */
.state {
  padding: 40px 24px; text-align: center; color: var(--text-muted); font-size: 13px;
}
.state .spinner {
  display: inline-block; width: 16px; height: 16px; vertical-align: middle; margin-right: 8px;
  border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.state.error { color: var(--negative); }

/* ---------------- Loading skeleton ---------------- */
.skel-bar {
  display: inline-block; height: 12px; max-width: 100%;
  border-radius: 4px; background: var(--border);
  position: relative; overflow: hidden; vertical-align: middle;
}
.skel-bar::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  animation: shimmer 1.2s infinite;
}
[data-theme="dark"] .skel-bar::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.10), transparent);
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.state.error .hint { display: block; margin-top: 6px; color: var(--text-faint); font-size: 12px; }
.state.empty .hint { display: block; margin-top: 6px; color: var(--text-faint); font-size: 12px; }

/* ---------------- Calendar ---------------- */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 16px; }
.cal-dow { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-faint); text-align: center; padding-bottom: 4px; }
.cal-cell {
  border: 1px solid var(--border); border-radius: var(--radius); min-height: 66px;
  padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; background: var(--bg);
}
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.has:hover { border-color: var(--accent); }
.cal-day { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cal-count {
  margin-top: auto; align-self: flex-start; font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 1px 8px;
}

/* ---------------- Placeholder view ---------------- */
.placeholder {
  max-width: 560px; margin: 12vh auto 0; text-align: center; padding: 0 24px;
}
.placeholder .ic {
  width: 66px; height: 66px; margin: 0 auto 22px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.placeholder .ic svg { width: 30px; height: 30px; }
.placeholder h1 { font-size: 22px; font-weight: 600; margin: 0 0 12px; }
.placeholder p { color: var(--text-muted); line-height: 1.6; font-size: 14px; margin: 0 0 8px; }
.placeholder .tag {
  display: inline-block; margin-top: 16px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 20px; padding: 5px 14px;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 6px;
  font-size: 13px; z-index: 50; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0; border-bottom: 1px solid var(--border);
    display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px;
  }
  .sidebar-label { display: none; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-item { white-space: nowrap; }
  .sidebar-sub { display: none; }
}
@media (max-width: 640px) {
  .topbar-inner { gap: 14px; padding: 0 16px; }
  .brand small { display: none; }
  main { padding: 20px 16px 48px; }
  .panel-controls { width: 100%; margin-left: 0; }
  .field-search input { min-width: 0; width: 100%; }
  .calendar { gap: 3px; padding: 10px; }
  .cal-cell { min-height: 52px; padding: 4px; }
}
