/* Floyo Reporting: site styles */

:root {
  --bg: #18102A;
  --panel: #221636;
  --panel-2: #2C1D45;
  --border: #3A2A5C;
  --text: #E5DCF2;
  --muted: #A995CC;
  --accent: #8258D4;
  --deep: #533293;
  --light: #C4B4E0;
  --yellow: #FFD23F;
  --yellow-text: #18102A;
  --red: #FF7A7A;
  --green: #7FE0A8;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--light); }
button { font: inherit; cursor: pointer; }
code { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- password gate ---------- */
#gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
#gate form { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; width: 100%; max-width: 380px; }
#gate h1 { margin: 0 0 6px; font-size: 22px; }
#gate p { margin: 0 0 18px; color: var(--muted); }
#gate input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 16px; }
#gate input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
#gate .error { color: var(--red); min-height: 22px; margin: 8px 0 0; }
.brand-mark { color: var(--yellow); }

/* ---------- buttons ---------- */
.btn-primary { background: var(--yellow); color: var(--yellow-text); border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 700; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--light); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; }
.btn-ghost:hover { border-color: var(--accent); }
.btn-ghost:disabled { opacity: .5; cursor: default; }
.btn-accent { background: var(--deep); color: var(--text); border: 1px solid var(--accent); border-radius: 10px; padding: 9px 14px; font-weight: 600; }
.btn-accent:hover { background: var(--accent); }
.btn-accent:disabled { opacity: .5; cursor: default; }

/* ---------- app shell: left menu of sections, top bar with sub-tabs ---------- */
#app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { font-weight: 800; letter-spacing: .3px; font-size: 20px; padding: 6px 10px 20px; }
.sidebar .brand span { color: var(--yellow); }
#sections { display: flex; flex-direction: column; gap: 4px; }
#sections button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: transparent; color: var(--muted); border: 0; border-radius: 10px; padding: 11px 12px; font-weight: 600; font-size: 15px; }
#sections button svg { width: 20px; height: 20px; flex: none; }
#sections button:hover { color: var(--text); background: var(--panel-2); }
#sections button.active { color: var(--text); background: var(--deep); }
.page { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 18px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; min-height: 64px; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 700; }
.topbar h1.with-tabs { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .4px; }
.subtabs { display: flex; gap: 4px; overflow-x: auto; }
.subtabs button { background: transparent; color: var(--muted); border: 0; border-radius: 8px; padding: 8px 12px; font-weight: 600; white-space: nowrap; }
.subtabs button:hover { color: var(--text); background: var(--panel-2); }
.subtabs button.active { color: var(--text); background: var(--deep); }
.topbar .spacer { flex: 1; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
main { padding: 24px; max-width: 1200px; width: 100%; }
section.tab { display: none; }
section.tab.active { display: block; }
footer { color: var(--muted); font-size: 13px; padding: 10px 24px 30px; text-align: center; margin-top: auto; }

/* The menu button and the action icons only show on small screens. */
.menu-btn { display: none; background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 10px; width: 42px; height: 42px; padding: 0; align-items: center; justify-content: center; flex: none; }
.menu-btn svg { width: 22px; height: 22px; }
.menu-btn:hover { border-color: var(--accent); }
.topbar .actions .ico { display: none; width: 18px; height: 18px; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .menu-btn { display: inline-flex; }
  .topbar { position: sticky; top: 0; padding: 8px 12px; gap: 8px 12px; min-height: 58px; }
  .topbar h1 { font-size: 17px; }
  .topbar h1.with-tabs { font-size: 13px; }
  .subtabs { order: 10; flex-basis: 100%; margin: 0 -4px -2px; }
  .subtabs button { padding: 7px 11px; font-size: 14px; }
  main { padding: 16px; }
}
@media (max-width: 600px) {
  .topbar .actions .ico { display: block; }
  .topbar .actions .label { display: none; }
  .topbar .actions button { padding: 10px 11px; line-height: 0; }
}

/* ---------- phone drawer (the left menu as an overlay) ---------- */
.drawer { position: fixed; inset: 0; z-index: 12; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(10, 6, 20, 0); transition: background .18s ease; }
.drawer.open .drawer-backdrop { background: rgba(10, 6, 20, 0.6); }
.drawer-panel { position: absolute; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); background: var(--panel); border-right: 1px solid var(--border); padding: 14px 12px 24px; overflow-y: auto; transform: translateX(-100%); transition: transform .18s ease; display: flex; flex-direction: column; gap: 4px; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 14px 10px; }
.drawer-head .brand { font-weight: 800; letter-spacing: .3px; font-size: 20px; }
.drawer-head .brand span { color: var(--yellow); }
.drawer-close { background: transparent; border: 1px solid var(--border); color: var(--light); border-radius: 8px; width: 36px; height: 36px; font-size: 20px; line-height: 1; }
.drawer-section { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: transparent; color: var(--muted); border: 0; border-radius: 10px; padding: 12px 12px; font-weight: 600; font-size: 15px; }
.drawer-section svg { width: 20px; height: 20px; flex: none; }
.drawer-section .lock { width: 14px; height: 14px; margin-left: auto; opacity: .7; }
.drawer-section.heading { color: var(--muted); cursor: default; padding-bottom: 4px; }
.drawer-section.heading.active { color: var(--text); }
button.drawer-section:hover, button.drawer-section.active { color: var(--text); background: var(--deep); }
.drawer-group { display: flex; flex-direction: column; gap: 2px; }
.drawer-report { display: block; width: 100%; text-align: left; background: transparent; color: var(--muted); border: 0; border-radius: 10px; padding: 10px 12px 10px 44px; font-weight: 600; font-size: 15px; }
.drawer-report:hover, .drawer-report.active { color: var(--text); background: var(--deep); }
body.drawer-open { overflow: hidden; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; margin-bottom: 20px; }
.card h2 { margin: 0 0 4px; font-size: 19px; }
.card .sub { color: var(--muted); margin: 0 0 14px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.status { color: var(--muted); font-size: 14px; }
.status .ok { color: var(--green); }
.status .warn { color: var(--yellow); }
.err-details { display: inline-block; margin-left: 6px; }
.err-details summary { display: inline; cursor: pointer; color: var(--light); font-size: 12px; text-decoration: underline dotted; }
.err-details summary::before { content: none; }
.err-details pre { white-space: pre-wrap; word-break: break-word; color: var(--muted); font-size: 12px; margin: 8px 0 0; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; max-height: 220px; overflow: auto; }
.errbox .err-details { display: block; margin: 6px 0 0; }
.errbox .err-details summary { color: #FFD3DE; }
.errbox { background: #3A1C2C; border: 1px solid #6B2B44; color: #FFD3DE; border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; margin-bottom: 14px; }
.placeholder { color: var(--muted); }
.legend { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover { background: var(--panel-2); }
td.pct { color: var(--light); }
td.paid { font-weight: 700; color: var(--yellow); }
tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
tr.provisional td { color: var(--muted); font-style: italic; }
td.neg { color: var(--red); }
.table-wrap { overflow-x: auto; position: relative;
  /* a fade at the right edge while there is more table to scroll to (the gradient scrolls with the content, the shadow does not) */
  background: linear-gradient(to left, var(--panel) 30%, rgba(34, 22, 54, 0)) 100% 0, radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .45), rgba(0, 0, 0, 0)) 100% 0;
  background-repeat: no-repeat; background-size: 36px 100%, 12px 100%; background-attachment: local, scroll; }
/* The first column (the week, the month, the line item) stays put while the rest scrolls, so a wide table keeps its bearings. */
.table-wrap th:first-child, .table-wrap td:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; box-shadow: 1px 0 0 var(--border); }
.table-wrap tbody tr:hover td:first-child { background: var(--panel-2); }
.table-wrap table.doc th:first-child, .table-wrap table.doc td:first-child { position: static; box-shadow: none; }
th.center { text-align: center; }
.rows-note { color: var(--muted); font-size: 13px; }
button.link { background: none; border: 0; padding: 0; color: var(--light); font: inherit; font-size: inherit; text-decoration: underline dotted; cursor: pointer; }
button.link:hover { color: var(--yellow); }
.chart-note { margin-top: 8px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }

/* heatmap cells */
td.cell { position: relative; text-align: center; min-width: 74px; }
td.cell small { display: block; color: var(--muted); font-size: 11px; line-height: 1.1; }
td.cell.partial { outline: 1px dashed var(--muted); outline-offset: -4px; color: var(--muted); font-style: italic; }
td.cell.empty { color: var(--border); }
td.cell.paid-tint { background: rgba(255, 210, 63, 0.14); }

/* ---------- definitions ---------- */
.defs { color: var(--muted); font-size: 14px; }
.defs dt { color: var(--text); font-weight: 600; margin-top: 8px; }
.defs dd { margin: 0; }
details summary { cursor: pointer; color: var(--light); font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "\25B8"; font-size: 12px; color: var(--muted); }
details[open] summary::before { content: "\25BE"; }
details[open] summary { margin-bottom: 6px; }

/* ---------- charts ---------- */
.chart svg { width: 100%; height: auto; display: block; }

/* ---------- P&L-style tables (rows are line items, columns are months) ---------- */
table.pnl th, table.pnl td { padding: 7px 10px; }
table.pnl td.label { text-align: left; white-space: nowrap; }
table.pnl tr.sub td.label { padding-left: 24px; color: var(--muted); }
table.pnl tr.subtotal td { font-weight: 700; border-top: 1px solid var(--light); }
table.pnl tr.total td { font-weight: 800; color: var(--yellow); }
table.pnl tr.quiet td { color: var(--muted); font-size: 13px; }
table.pnl tr.section td { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding-top: 14px; border-bottom: 0; }
table.pnl th.current, table.pnl td.current { font-style: italic; color: var(--muted); }
table.pnl td.neg { color: var(--red); }

/* ---------- overview tiles ---------- */
.tiles-heading { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; margin: 4px 0 10px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tiles.compact { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.tiles.dense { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px 12px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.tile .tile-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.tile .tile-value { font-size: 32px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--yellow); }
.tile .tile-value.md { font-size: 28px; }
.tile .tile-value.approx::before { content: "\2248"; color: var(--muted); font-weight: 400; margin-right: 4px; }
.tile .tile-delta { font-size: 14px; font-weight: 600; }
.tile .tile-delta.good { color: var(--green); }
.tile .tile-delta.bad { color: var(--red); }
.tile .tile-delta.flat { color: var(--muted); }
.tile .tile-sub { color: var(--muted); font-size: 13px; line-height: 1.35; }
.tile .tile-sub b { color: var(--text); font-weight: 600; }
.tile .spark { margin-top: 8px; }
.tile .spark svg { width: 100%; height: 64px; display: block; }
.tile .spark-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 2px; }
.tile .tile-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; }
.tile .tile-foot .tile-sub { font-size: 12px; }
.tile-link { background: transparent; border: 0; color: var(--light); padding: 0; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tile-link:hover { color: var(--yellow); }
.tile.unavailable .tile-value { color: var(--muted); font-size: 18px; font-weight: 600; }

/* ---------- runway tab (second gate, document-style tables) ---------- */
.inline-gate { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.inline-gate input { width: 260px; max-width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 15px; }
.inline-gate input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.inline-gate .error { color: var(--red); font-size: 14px; }
table.doc th:first-child, table.doc td:first-child { text-align: left; white-space: normal; }
table.doc td.neg { color: var(--red); }
table.doc tr.bold td { font-weight: 700; color: var(--yellow); }
table.doc td.quiet { color: var(--muted); }
table.doc.gates th, table.doc.gates td { white-space: nowrap; }
.tile .tile-value.neg { color: var(--red); }
.rw-note { color: var(--light); font-style: italic; margin: 14px 0 0; }
.rw-text { margin: 6px 0 0; line-height: 1.55; }
.rw-bullets { margin: 6px 0 0; padding-left: 22px; }
.rw-bullets li { margin: 7px 0; }
.rw-updated { display: inline-block; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); margin-left: 8px; vertical-align: middle; }

/* ---------- loading overlay and spinner ---------- */
.loading { position: fixed; inset: 0; background: rgba(10, 6, 20, 0.55); display: grid; place-items: center; z-index: 15; }
.loading-box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px 28px; display: flex; align-items: center; gap: 14px; color: var(--muted); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--yellow); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal .spinner { display: flex; align-items: center; gap: 12px; }

/* ---------- analysis modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 6, 20, 0.7); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 760px; max-height: 90vh; overflow: auto; padding: 22px 24px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 20px; flex: 1; }
.modal-meta { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.modal-close { background: transparent; border: 1px solid var(--border); color: var(--light); border-radius: 8px; padding: 6px 10px; }
.modal-close:hover { border-color: var(--accent); }
.modal .headline { font-size: 16px; line-height: 1.5; padding: 12px 14px; background: var(--panel-2); border-radius: 10px; margin-bottom: 16px; }
.modal h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .4px; margin: 16px 0 6px; display: flex; align-items: center; gap: 8px; }
.modal h3::before { content: ""; width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--muted); }
.modal h3.up::before { background: var(--green); }
.modal h3.down::before { background: var(--red); }
.modal h3.caution::before { background: var(--yellow); }
.modal h3.watch::before { background: var(--accent); }
.modal ul { margin: 0; padding-left: 20px; }
.modal li { margin: 6px 0; }
.modal li small { display: block; color: var(--muted); font-size: 13px; }
.modal .spinner { color: var(--muted); padding: 24px 0; }
.modal .foot { color: var(--muted); font-size: 12px; margin-top: 18px; border-top: 1px solid var(--border); padding-top: 10px; }
.modal pre { white-space: pre-wrap; word-break: break-word; color: var(--muted); font-size: 13px; }

/* ---------- phones ---------- */
@media (max-width: 600px) {
  main { padding: 12px; }
  .card { padding: 14px 14px 12px; border-radius: 12px; margin-bottom: 14px; }
  .card h2 { font-size: 17px; }
  .card .sub { font-size: 14px; margin-bottom: 10px; }
  .tiles, .tiles.compact, .tiles.dense { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
  .tile { padding: 12px 12px 10px; border-radius: 12px; gap: 4px; }
  .tile .tile-label { font-size: 11px; }
  .tile .tile-value, .tile .tile-value.md { font-size: 22px; }
  .tile .tile-delta { font-size: 13px; }
  .tile .tile-sub { font-size: 12px; }
  .tile .tile-foot { flex-wrap: wrap; }
  th, td { padding: 8px 8px; font-size: 13px; }
  th { font-size: 12px; }
  table.pnl th, table.pnl td { padding: 7px 8px; }
  /* the pinned first column may wrap so the numbers get most of the width */
  table.pnl td.label { white-space: normal; max-width: 40vw; }
  table.pnl tr.section td.label { max-width: none; }
  .toolbar { gap: 6px 12px; }
  .topbar { padding: 8px 12px; }
  .topbar .actions { gap: 6px; }
  .topbar .actions button { padding: 9px 11px; font-size: 14px; }
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal { max-width: none; max-height: none; height: 100%; border-radius: 0; padding: 16px; }
  .defs { font-size: 13px; }
}
@media (pointer: coarse) {
  #sections button, .subtabs button, .btn-primary, .btn-ghost, .btn-accent, .modal-close { min-height: 42px; }
  .tile-link, button.link { padding: 6px 0; }
}
