:root {
  --bg: #0e0f12;
  --panel: #16181d;
  --text: #e8ecf1;
  --muted: #a5adba;
  --accent: #4da3ff;
  --good: #2fbf71;
  --warn: #ffd166;
  --bad: #ff6b6b;
  --border: #262a33;
  --tooltip-bg: #0b0c10;
  --tooltip-border: #2a2f3a;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a, a:visited {color:orange;}
.container { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.site-header, .site-footer { padding: 1rem; background: var(--panel); border-bottom: 1px solid var(--border); }
.site-footer { border-top: 1px solid var(--border); border-bottom: none; color: var(--muted); }
h1 { margin: 0 0 .25rem; font-size: clamp(1.25rem, 1.5vw + 1rem, 2rem); }
#tonote, #table, #currency {margin-top: 4rem;}
.lead { margin: 0; color: var(--muted); }
.notes {font-size: 0.9rem;}
.controls { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; margin: 1rem 0; }
.control label { display: block; font-weight: 600; margin-bottom: .35rem; }
.control input, .control select, .control button {
  width: 100%; padding: .6rem .7rem; background: #0b0c10; color: var(--text);
  border: 1px solid var(--border); border-radius: .6rem; outline: none;
}
.control input:focus, .control select:focus, .control button:focus { border-color: var(--accent); }
.search-wrap { position: relative; }
.clear-btn {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  width: 1.6rem; height: 1.6rem; border-radius: .4rem; border: 1px solid var(--border);
  background: #0b0c10; color: var(--muted); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; line-height: 1; font-weight: 700;
  width: 10% !important
}
.clear-btn:hover { color: var(--text); }
.clear-btn:focus { outline: none; border-color: var(--accent); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin: .25rem 0 1rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.etag {
  display: inline-block; font-weight: 700; font-size: .85rem; padding: 0 .45rem;
  border: 1px solid var(--border); border-radius: .35rem; background: #0b0c10; color: var(--text);
}
.summary {
  background: #0b0c10; border: 1px solid var(--border); border-radius: .6rem;
  padding: .75rem 1rem; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.summary-right button {
  background: var(--accent); color: #06121a; font-weight: 700; padding: .5rem .75rem;
  border: 1px solid var(--border); border-radius: .6rem; cursor: pointer;
}
.table-wrap {
  margin-top: 1rem; border: 1px solid var(--border); border-radius: .8rem; overflow: visible; background: var(--panel);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; }
thead th {
  position: sticky; top: 0; background: #111318; border-bottom: 1px solid var(--border);
  text-align: left; padding: .75rem .75rem; font-size: .95rem; z-index: 1;
}
tbody td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
.badge { display: inline-block; padding: .2rem .5rem; border-radius: .5rem; font-size: .8rem; font-weight: 700; }
.badge.yes { background: rgba(47,191,113,.15); color: var(--good); border: 1px solid rgba(47,191,113,.35); }
.badge.no  { background: rgba(255,107,107,.15); color: var(--bad); border: 1px solid rgba(255,107,107,.35); }
.badge.unknown { background: rgba(255,209,102,.15); color: var(--warn); border: 1px solid rgba(255,209,102,.35); }
/* Entity cell + tooltip */
.entity-cell { position: relative; display: inline-flex; align-items: center; gap: .4rem; }
.qmark {
  width: 1.25rem; height: 1.25rem; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: #0b0c10; border: 1px solid var(--border); font-size: .85rem; cursor: help; color: var(--muted);
}
.qmark:focus { outline: none; border-color: var(--accent); color: var(--text); }
.tooltip {
  position: absolute; left: 0; top: calc(100% + .4rem); min-width: 16rem; max-width: 28rem; padding: .5rem .65rem;
  background: var(--tooltip-bg); color: var(--text); border: 1px solid var(--tooltip-border); border-radius: .45rem;
  box-shadow: 0 8px 20px rgba(0,0,0,.35); z-index: 5;
}
.tooltip.top { top: auto; bottom: calc(100% + .4rem); }
.tooltip[hidden] { display: none; }
.tooltip .tip {
  position: absolute; top: -6px; left: .8rem; width: 10px; height: 10px; background: var(--tooltip-bg);
  border-left: 1px solid var(--tooltip-border); border-top: 1px solid var(--tooltip-border); transform: rotate(45deg);
}
.tooltip.top .tip { top: auto; bottom: -6px; transform: rotate(225deg); }
/* Expander */
th:last-child, td:last-child { width: 2.75rem; }
.expander {
  width: 1.9rem; height: 1.9rem; display: inline-flex; align-items: center; justify-content: center;
  border-radius: .45rem; background: #94a0ce; border: 1px solid var(--border); cursor: pointer; font-weight: 700; line-height: 1; color: #06121a;
}
.expander[aria-expanded="true"] { border-color: var(--accent); }
.expander:focus { outline: none; border-color: var(--accent); }
.desc-row td { background: #101218; color: var(--text); padding-top: .9rem; padding-bottom: .9rem; }
/* Export button after table */
.post-table-actions { display: flex; justify-content: flex-end; margin: .5rem 0 1.25rem; }
.btn-quiet {
  padding: .35rem .6rem; font-size: .9rem; border: 1px solid var(--border); border-radius: .5rem;
  background: transparent; color: var(--muted); cursor: pointer;
}
.btn-quiet:hover { color: var(--text); }
.indentChild li {margin-left: 2rem;}
/* Back to top */
.back-to-top {
  position: fixed; right: 50%; bottom: 1rem; width: 2.25rem; height: 2.25rem; border-radius: .6rem;
  background: var(--accent); color: #06121a; border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 900; cursor: pointer; box-shadow: 0 10px 24px rgba(0,0,0,.35); opacity: 0; transform: translateY(8px);
  transition: opacity .15s ease, transform .15s ease; z-index: 50;
}
.back-to-top.show { opacity: 1; transform: translateY(0); }
.back-to-top:focus { outline: none; box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--accent); }
.help { color: var(--muted); margin: 1rem 0 2rem; }
.help summary { cursor: pointer; color: var(--text); }
.help code { background: #0b0c10; padding: .1rem .35rem; border: 1px solid var(--border); border-radius: .35rem; }
/* List items */
li { padding: 0.25rem; }
/* current date */
.current-date {color:yellow; font-weight:bold;}
/* table data from EAs in Details */
/* Reset/neutral style for EA tables inside descriptions */
table.eaData {
  /* override global table rules */
  width: auto;
  border-collapse: collapse;   /* ignore global 'separate' */
  border-spacing: 0;
  margin: .25rem 0 1rem;
  background: transparent;
}
table.eaData thead {
	background: var(--bg);
}
/* undo sticky headers, backgrounds, and heavy paddings */
.eaData thead th,
.eaData tbody td {
  position: static !important; /* defeat sticky header */
  top: auto !important;
  z-index: auto !important;
  background: transparent !important;
  padding: .4rem .6rem;        /* compact, readable */
  border: 1px solid var(--border);
  vertical-align: top;
}
.eaData thead th {
  font-weight: 700;
  text-align: left;
}
/* prevent global row-hover effect from the outer list */
.eaData tbody tr:hover {
  background: transparent;
}
/* cancel the global "last column fixed width" rule */
.eaData th:last-child,
.eaData td:last-child {
  width: auto;
}
/* optional: a caption style if you use <caption> */
.eaData caption {
  caption-side: top;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: .25rem;
}
/* optional: align numeric cells if you add class="num" */
.eaData th.num,
.eaData td.num {
  text-align: right;
}
/* styling for special numbered lists */
.desc-row ol {margin: 0rem 3rem;}
.moveOver {margin: 1rem 4.5rem !important;}
/* 1 & 2 — constant prefix + dot (e.g., 52.1, F17.1) */
/* Scope to ONLY top-level items so nested lists keep their own markers */
ol.prefix-dot > li::marker {
  content: attr(data-prefix) "." counter(list-item) " ";
}
/* Helpers for lettered child lists */
ol.alpha-paren-after > li::marker { content: counter(list-item, lower-alpha) ") "; }
ol.alpha-parens > li::marker     { content: "(" counter(list-item, lower-alpha) ") "; }
ol.number-parens > li::marker     { content: "(" counter(list-item) ") "; }
ol.alpha-plain > li::marker      { content: counter(list-item, lower-alpha) " "; }
/* 3 — wrapped in parentheses: (1), (2), … */
ol.parens li::marker {
  content: "(" counter(list-item) ") ";
}
/* 4 — trailing parenthesis: 201), 202), … */
ol.paren-after li::marker {
  content: counter(list-item) ") ";
}
/* (Optional) tidy spacing alignment across browsers */
ol { padding-left: 2.25ch; }
/* zig zag */
hr.zig, hr.zag {
  border: none;
  height: 30px;
  margin: 0 1.5rem;
}
hr.zig{
  background: linear-gradient(-135deg, #101218 20px, rgba(0, 0, 0, 0) 0) 0 5px, linear-gradient(135deg, #101218 20px, rgba(0, 0, 0, 0) 0) 0 5px;
  background-color: rgba(0, 0, 0, 0);
  background-position: center bottom;
  background-repeat: repeat-x;
  background-size: 20px 40px;
  z-index: 100;
  position: relative;
}
hr.zag {
  background: linear-gradient(-135deg, #333 20px, rgba(0, 0, 0, 0) 0) 0 5px, linear-gradient(135deg, #333 20px, #101218 0) 0 5px;
  background-color: rgba(0, 0, 0, 0);
  background-position: center bottom;
  background-repeat: repeat-x;
  background-size: 20px 40px;
  z-index: 50;
  margin-top: -28px;
}
/* Position the copy-link in the top-left of the Details panel */
#eaTable tbody tr.desc-row td { position: relative; }
.copy-link {
  position: absolute;
  top: .5rem;
  right: .75rem;
  padding: .25rem .5rem;
  font-size: .85rem;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: #0b0c10;
  color: var(--muted);
  cursor: pointer;
}
.copy-link:hover { color: var(--text); }
/* Give the content a little left padding to not collide with the button */
#eaTable tbody tr.desc-row td .ea-head 
/* #eaTable tbody tr.desc-row td p:first-child */ {
  padding-left: 6.5rem; /* room for the button; adjust if needed */
}
.muted {color: var(--muted);}
/* On small screens, tuck it in slightly different if you like */
@media (max-width: 880px) {
  .copy-link { top: .5rem; right: .6rem; }
  #eaTable tbody tr.desc-row td .ea-head,
  #eaTable tbody tr.desc-row td p:first-child { padding-left: 6rem; }
}
/* Offset anchor targets so sticky headers don't cover them */
#eaTable tbody tr[id] { scroll-margin-top: 65px; }  

/* media queries */
@media only screen and (max-width: 1100px) {
  .notes.moveOver {margin: 1rem !important;}
}
@media only screen and (max-width: 880px) {
  /* Always keep hidden rows hidden, even in mobile card view */
  #eaTable [hidden] { display: none !important; }
  /* Hide thead and turn each row into a "card" */
  #eaTable thead { 
    display: none; 
  }
  #eaTable tbody tr {
    display: block;
    margin: .75rem 0;
    border: 1px solid var(--border);
    border-radius: .6rem;
    background: var(--panel);
  }
  #eaTable tbody tr:hover {
    background: var(--panel); /* cancel row hover glow on cards */
  }
    /* Description row: full-width block, no label/value grid */
  #eaTable tbody tr.desc-row td {
    display: block;
    grid-template-columns: 1fr !important; /* cancel the 2-col grid */
    width: auto !important;                 /* override last-child width */
    border-bottom: none;                    /* optional: cleaner edge */
    padding-top: .9rem;
    padding-bottom: .9rem;
  }
  #eaTable tbody tr.desc-row td::before {
    content: none !important;               /* no injected label on Details */
  }
  /* Explicitly undo the fixed width on the last cell in the desc row */
  #eaTable tbody tr.desc-row td:last-child {
    width: auto !important;
  }
  /* Make each cell a 2-column grid: label (left) + value (right) */
  #eaTable tbody td {
    display: grid;
    grid-template-columns: 9.5rem minmax(0, 1fr);
    gap: .5rem;
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border);
    white-space: normal;                  /* allow wrapping */
    overflow-wrap: anywhere;              /* break long tokens/URLs */
    word-break: break-word;
    hyphens: auto;
  }
  #eaTable tbody tr > td:last-child {
    border-bottom: none;                  /* last row edge cleanup */
  }
  /* Override the generic grid/flex on the 2nd column (Agency) */
  #eaTable tbody td:nth-child(2) {
    display: block !important;        /* cancel the grid/flex used for other cells */
    position: relative;
    /* Leave the same top/right/bottom padding; create a left “label column”:
       9.5rem label width + 0.5rem gap + 0.75rem inner left padding */
    padding-left: calc(9.5rem + 0.5rem + 0.75rem) !important;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  /* Place the "Agency" label just like other labels */
  #eaTable tbody td:nth-child(2)::before {
    content: "Agency";                /* same label text as the grid version */
    position: absolute;
    left: 0.75rem;                    /* matches your cell left padding */
    top: 0.6rem;                      /* aligns with the first line of content */
    width: 9.5rem;                    /* same label column width as other cells */
    font-weight: 600;
    color: var(--muted);
  }
  /* Ensure the (website) link behaves inline with the agency name */
  #eaTable tbody td:nth-child(2) a {
    display: inline;
    white-space: normal;
  }
  /* Inject per-cell labels via CSS (matches your current column order) */
  #eaTable tbody td:nth-child(1)::before { content: "Portfolio"; font-weight: 600; color: var(--muted); }
  #eaTable tbody td:nth-child(2)::before { content: "Agency";    font-weight: 600; color: var(--muted); }
  #eaTable tbody td:nth-child(3)::before { content: "Entity";    font-weight: 600; color: var(--muted); }
  #eaTable tbody td:nth-child(4)::before { content: "Listed as"; font-weight: 600; color: var(--muted); }
  #eaTable tbody td:nth-child(5)::before { content: "Shutdown?"; font-weight: 600; color: var(--muted); }
  #eaTable tbody td:nth-child(6)::before { content: "Early Close"; font-weight: 600; color: var(--muted); }
  #eaTable tbody td:nth-child(7)::before { content: "Details";   font-weight: 600; color: var(--muted); }
  /* Make the "Details" cell a little tighter so the expander sits nicely */
  #eaTable tbody td:nth-child(7) {
    align-items: center;
  }
  /* Expanded description rows: full-width, no label column */
  #eaTable tbody tr.desc-row {
    margin-top: -.5rem;                  /* visually attaches to the parent card */
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }
  #eaTable tbody tr.desc-row td {
    display: block;
    border-bottom: none;
    grid-template-columns: 1fr;          /* no label/value split */
    padding-top: .9rem;
    padding-bottom: .9rem;
  }
  #eaTable tbody tr.desc-row td::before {
    content: none !important;            /* no injected label on description */
  }
  /* Keep links and badges wrapping nicely inside cards */
  #eaTable td a {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  /* Optional: slightly smaller text for dense screens */
  #eaTable tbody td { font-size: .95rem; }
    /* Normal (summary) rows become "cards" with more space below */
  #eaTable tbody tr:not(.desc-row) {
    margin: 1rem 0 .25rem;           /* bigger gap before next card */
    border-radius: .6rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);  /* subtle lift for delineation */
  }
  /* Description row visually attaches to its card, then adds spacing after */
  #eaTable tbody tr.desc-row {
    margin: -.5rem 0 1.25rem;        /* snug to card, extra gap after pair */
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: .6rem;
    border-bottom-right-radius: .6rem;
  }
  .table-wrap {background:none; border:0px;}
  /* Keep hidden rows fully collapsed (prevents empty gaps) */
  #eaTable [hidden] { display: none !important; }
  #eaTable tbody tr[id] { scroll-margin-top: 10px; }
}