/* Creator panel. Rules: ../DESIGN.md */
:root {
	color-scheme: dark;
	--page: #111213;
	--surface: #18191b;
	--field: #111213;
	--ink: #ededee;
	--text-2: #a9adb3;
	--line: #303236;
	--line-strong: #44474c;
	--line-soft: #25272a;
	--hover: #222326;
	--money: #6fcf97;
	--danger: #ff8f86;
	--warn: #e2b860;
	--focus: #8ab4ff;
	--radius: 6px;
	--sans: "IBM Plex Sans", system-ui, sans-serif;
	--mono: "IBM Plex Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 14px/1.5 var(--sans); }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 20px; font-weight: 600; line-height: 1.3; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
p { margin: 0 0 10px; }
code, .code, .num, td.n, tfoot th.n { font-family: var(--mono); }
.n, .num { font-variant-numeric: tabular-nums; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; position: relative; }
/* The sidebar's white column runs the full page height, the sidebar itself stays in view. */
.shell::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 216px; background: var(--surface); border-right: 1px solid var(--line); }
.sidebar { position: relative; z-index: 1; display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; align-self: start; }
.brand { display: block; font-weight: 600; text-decoration: none; padding: 0 8px 18px; }
.brand span { display: block; font-weight: 400; color: var(--text-2); font-size: 13px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: block; padding: 7px 8px; border-radius: var(--radius); text-decoration: none; color: var(--text-2); transition: background-color 120ms, color 120ms; }
.sidebar nav a:hover { background: var(--hover); color: var(--ink); }
.sidebar nav a[aria-current="page"] { background: var(--hover); color: var(--ink); font-weight: 500; }
.who { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.who-name { font-weight: 500; }
.who-role { color: var(--text-2); }
.linklike { background: none; border: 0; padding: 0; margin-top: 6px; font: inherit; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linklike:hover { color: var(--ink); }
.main { padding: 28px 32px 48px; max-width: 1160px; width: 100%; }

/* ---- page structure: title line + content, repeated ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.summary { color: var(--text-2); max-width: 72ch; margin-bottom: 20px; }
.summary .num { color: var(--ink); }
section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.muted { color: var(--text-2); }
.money { color: var(--money); }
.money.none { color: var(--text-2); }
.ok { color: var(--money); }
.warn { color: var(--warn); }
.block { display: block; font-size: 12px; }
.code { font-size: 12px; color: var(--text-2); margin-left: 8px; }
p > .code:first-child { margin-left: 0; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; white-space: nowrap; }
thead th { font-weight: 500; color: var(--text-2); border-bottom: 1px solid var(--line); background: var(--surface); }
tbody tr + tr > * { border-top: 1px solid var(--line-soft); }
tbody th { font-weight: 400; }
tfoot > tr > * { border-top: 1px solid var(--line); font-weight: 500; }
td.n, th.n { text-align: right; }
td.empty { color: var(--text-2); white-space: normal; padding: 18px 12px; }
.row-link { font-weight: 500; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 14px; border-radius: var(--radius); border: 1px solid transparent; font: 500 14px var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color 120ms, border-color 120ms; }
.btn.primary { background: var(--ink); color: #111213; }
.btn.primary:hover { background: #ffffff; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.error-text { color: var(--danger); white-space: normal; }
.confirm-form { margin-top: 20px; }
.btn.secondary:hover { border-color: var(--line-strong); background: var(--hover); }
form.inline { display: inline; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.form-width { max-width: 460px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.w-s input { max-width: 140px; }
.field.w-m input, .field.w-m select { max-width: 260px; }
label { font-weight: 500; }
input, select { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--field); color: var(--ink); font: 400 14px var(--sans); width: 100%; }
input:hover, select:hover { border-color: var(--line-strong); }
input[aria-invalid="true"] { border-color: var(--danger); }
.help { color: var(--text-2); font-size: 13px; margin: 0; }
.error { color: var(--danger); font-size: 13px; margin: 0; }
.buttons { display: flex; gap: 10px; }
.rights { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.rights legend { font-weight: 500; padding: 0; margin-bottom: 8px; }
td.wrap { white-space: normal; min-width: 260px; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.month-picker { display: flex; align-items: center; gap: 8px; }
.month-picker label { font-weight: 400; color: var(--text-2); }
.month-picker select { width: auto; min-width: 160px; }

/* ---- copy box ---- */
.copy { display: flex; gap: 8px; align-items: stretch; max-width: 760px; }
.copy code { flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 10px; height: 34px; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; overflow-x: auto; white-space: nowrap; }
.copy + .help { margin-top: 8px; max-width: 72ch; }

::selection { background: #3a4a66; color: var(--ink); }

/* ---- notices ---- */
.notice { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin-bottom: 16px; max-width: 760px; }
.notice.error { border-color: #5c2b28; background: #241615; color: var(--danger); }
.notice.warn { border-color: #57461f; background: #221d12; color: var(--warn); }
.notice.ok { border-color: #2c4a39; background: #142019; color: var(--money); }

/* ---- signed-out pages ---- */
body.bare { display: grid; place-items: start center; }
.bare-main { width: 100%; max-width: 420px; padding: 12vh 20px 40px; }
.narrow h1 { margin-bottom: 4px; }
.lede { color: var(--text-2); margin-bottom: 22px; }
.narrow .stack + .help { margin-top: 18px; }

/* ---- small screens: the sidebar becomes a top bar ---- */
@media (max-width: 760px) {
	.shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
	.shell::before { display: none; }
	.sidebar { position: static; height: auto; background: var(--surface); flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
	.brand { padding: 0; margin-right: auto; }
	.brand span { display: none; }
	.sidebar nav { flex-direction: row; order: 3; width: 100%; overflow-x: auto; }
	.page-head { align-items: flex-start; }
	.actions { width: 100%; }
	.month-picker select { min-width: 0; flex: 1; }
	.who { margin: 0; padding: 0; border: 0; flex-direction: row; align-items: center; gap: 10px; }
	.who-role { display: none; }
	.linklike { margin: 0; }
	.main { padding: 20px 16px 40px; }
	.copy { flex-direction: column; }
	.copy .btn { align-self: flex-start; }
}

.js .js-hide { display: none; }

/* ---- statistics: charts always come with their table ---- */
.chart-block { margin-top: 30px; }
.pie-layout { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.pie-layout .table-wrap { flex: 1; min-width: 280px; max-width: 720px; }
.pie { flex: none; }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 6px; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 600px; height: auto; }
svg .grid { stroke: var(--line-soft); stroke-width: 1; }
svg .tick { fill: var(--text-2); font: 400 11px var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; padding: 0; margin: 10px 0 12px; color: var(--text-2); font-size: 13px; }
.legend li, td .swatch { display: inline-flex; align-items: center; }
.swatch { margin-right: 8px; vertical-align: -1px; flex: none; }
.figures { max-width: 640px; }
.figures th { white-space: normal; }
.figures td.n { vertical-align: top; font-size: 14px; }
.empty-note { color: var(--text-2); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px 14px; margin: 0; }
@media (max-width: 760px) {
	.pie { width: 180px; height: 180px; }
}
