/* Colour, the arrange-it-yourself grid, and the screens added after the first
   release: bills as a day book, one entry, parties, GST, cohorts. Loaded after
   styles.css, which holds the stage and the shared controls. */

/* ---------- colour: one hue per kind of thing, each with a soft tint ---------- */
:root {
  --c-sales: #4a56d6; --t-sales: #e9ebfc;
  --c-in: #1c8a55; --t-in: #dff3e7;
  --c-due: #b97707; --t-due: #fbefcd;
  --c-out: #cf4b3c; --t-out: #fce5e1;
  --c-stock: #0b8a8f; --t-stock: #dcf2f2;
  --c-tax: #7650cf; --t-tax: #ede7fb;
  --c-plain: #5a5c64; --t-plain: #ebebee;
}
.ico { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--t-plain); color: var(--c-plain); }
.ico svg { width: 17px; height: 17px; }
.ico.lg { width: 38px; height: 38px; border-radius: 12px; }
.ico.lg svg { width: 20px; height: 20px; }
.tone-sales { --tone: var(--c-sales); --tint: var(--t-sales); }
.tone-in { --tone: var(--c-in); --tint: var(--t-in); }
.tone-due { --tone: var(--c-due); --tint: var(--t-due); }
.tone-out { --tone: var(--c-out); --tint: var(--t-out); }
.tone-stock { --tone: var(--c-stock); --tint: var(--t-stock); }
.tone-tax { --tone: var(--c-tax); --tint: var(--t-tax); }
.tone-plain { --tone: var(--c-plain); --tint: var(--t-plain); }
[class*="tone-"] .ico, .ico[class*="tone-"] { background: var(--tint); color: var(--tone); }
.tag.blue { background: var(--t-sales); color: var(--c-sales); }
.tag.violet { background: var(--t-tax); color: var(--c-tax); }
.tag.teal { background: var(--t-stock); color: var(--c-stock); }
[class*="tone-"] .bl-fill { background: var(--tone); }
.stat-top { justify-content: flex-start; gap: 9px; }
.stat-top > .tag, .stat-top > svg { margin-left: auto; }
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--ink)); }
.figure-tone { color: var(--tone); }
.pill.tint { background: var(--tint); color: var(--tone); box-shadow: none; }

/* ---------- screens people arrange themselves ---------- */
.wgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; grid-auto-flow: dense; }
.wg { grid-column: span 2; min-width: 0; position: relative; display: grid; }
.wg > .card { min-width: 0; }
.wg.w-stat { grid-column: span 1; }
.wg-tools { display: none; }
.wgrid.editing .wg { border-radius: 22px; outline: 1.5px dashed rgba(31, 32, 35, 0.28); outline-offset: 3px; cursor: grab; }
.wgrid.editing .wg > .card { pointer-events: none; opacity: 0.86; }
.wgrid.editing .wg-tools { display: flex; gap: 2px; position: absolute; z-index: 3; top: -8px; right: -4px; padding: 3px; border-radius: 999px; background: var(--ink); box-shadow: 0 8px 18px rgba(31, 32, 35, 0.28); }
.wg-tools button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; color: #f6f6f7; cursor: pointer; display: grid; place-items: center; padding: 0; }
.wg-tools button:hover { background: rgba(255, 255, 255, 0.16); }
.wg.dragging { opacity: 0.4; }
.wg.drop-here { outline: 2px solid var(--c-sales); }
.tray { border-radius: 20px; padding: 16px; margin-bottom: 14px; background: #fff; border: 1px solid var(--hair); box-shadow: 0 14px 34px rgba(40, 44, 52, 0.1); }
.tray h2 { font-size: 15px; font-weight: 500; }
.tray p { font-size: 13px; color: var(--muted); margin: 2px 0 4px; }
.tray-group { font-size: 12px; color: var(--faint); margin: 12px 0 6px; }
.tray .chip { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- bills: the day book ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .grow { flex: 1 1 200px; min-width: 0; }
.searchbox { position: relative; }
.searchbox svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); pointer-events: none; }
.searchbox .field { padding-left: 36px; }
.kinds { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px 12px; padding: 0 14px; }
.kinds::-webkit-scrollbar { display: none; }
.kinds .chip { display: inline-flex; align-items: center; gap: 7px; }
.kinds .chip small { font-size: 12px; opacity: 0.65; }
.kinds .chip[aria-pressed="true"] .dot { background: #fff; }
.month { margin-top: 16px; }
.month:first-child { margin-top: 0; }
.month-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px 8px; }
.month-head h2 { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.month-head span { font-size: 12.5px; color: var(--muted); }
.month-head b { font-family: var(--mono); font-weight: 500; letter-spacing: -0.03em; font-size: 13.5px; color: var(--ink); }
.entries { display: grid; border-radius: 18px; background: var(--card); border: 1px solid rgba(255, 255, 255, 0.85); box-shadow: var(--shadow); overflow: hidden; }
.entry { display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-width: 0; position: relative; transition: background-color 200ms; border: 0; background: none; text-align: left; width: 100%; }
.entry + .entry::before { content: ""; position: absolute; left: 56px; right: 14px; top: 0; border-top: 1px solid var(--hair); }
a.entry:hover, button.entry:hover { background: rgba(255, 255, 255, 0.9); cursor: pointer; }
.entry-main { flex: 1; min-width: 0; }
.entry-name { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
.entry-name > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-amt { flex: none; text-align: right; font-family: var(--mono); letter-spacing: -0.03em; font-size: 13.5px; }
.entry-amt small { display: block; font-family: var(--sans); letter-spacing: 0; font-size: 12px; color: var(--muted); }
.entry.off .entry-name > span:first-child, .entry.off .entry-amt { color: var(--faint); text-decoration: line-through; }
.entry .tag { height: 20px; font-size: 11px; padding: 0 7px; }
.waiting { display: grid; gap: 8px; margin-bottom: 14px; }
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; border-radius: 16px; background: var(--tint, #fff); color: var(--ink); font-size: 13.5px; line-height: 1.45; }
.banner > div { min-width: 0; flex: 1; }
.banner b { font-weight: 500; }
.banner .ico { background: #fff; }
.banner small { display: block; color: var(--muted); font-size: 12.5px; }
.banner .actions { flex: none; }

/* ---------- one entry, and the printed invoice ---------- */
.doc { padding: 0; overflow: hidden; }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px 24px; padding: 18px 18px 14px; }
.doc-head h3 { font-size: 12.5px; font-weight: 400; color: var(--muted); margin: 0 0 3px; }
.doc-head b { display: block; font-weight: 500; font-size: 15px; }
.doc-head small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.doc-body { padding: 0 18px 6px; }
.doc-sum { margin: 6px 0 0; padding: 4px 18px 14px; background: rgba(31, 32, 35, 0.03); border-top: 1px solid var(--hair); }
.doc-sum .line.total > span:last-child { font-size: 17px; }
.words { font-size: 12.5px; color: var(--muted); padding: 0 18px 16px; background: rgba(31, 32, 35, 0.03); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
#print { display: none; }
@media print {
  body { background: #fff !important; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; font: 12px/1.45 var(--sans); padding: 0; }
  #print h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
  #print .p-top { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 12px; }
  #print .p-title { text-align: right; font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
  #print .p-two { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 14px; }
  #print .p-two b { display: block; font-size: 13px; }
  #print small { color: #444; }
  #print table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
  #print th, #print td { border: 1px solid #999; padding: 5px 7px; text-align: right; vertical-align: top; }
  #print th { background: #f0f0f0; font-weight: 600; }
  #print th:first-child, #print td:first-child, #print td.l, #print th.l { text-align: left; }
  #print .p-total td { font-weight: 700; font-size: 13px; }
  #print .p-foot { display: flex; justify-content: space-between; margin-top: 34px; }
  @page { margin: 14mm; }
}

/* ---------- bill editor additions ---------- */
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice button { text-align: left; border: 0; cursor: pointer; padding: 12px 13px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1px var(--hair); transition: box-shadow 200ms; }
.choice button b { display: flex; align-items: center; gap: 7px; font-weight: 500; font-size: 14px; }
.choice button small { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.choice button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); }
.choice button[aria-pressed="true"] b::after { content: ""; margin-left: auto; width: 13px; height: 7px; border-left: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: translateY(-2px) rotate(-45deg); }
.line-nums.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--tint, rgba(31, 32, 35, 0.05)); font-size: 12.5px; line-height: 1.45; color: var(--ink); }
.note > span { flex: 1; min-width: 0; }

/* ---------- tabs inside a screen ---------- */
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px 14px; padding: 0 14px; border-bottom: 1px solid var(--hair); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { flex: none; height: 40px; padding: 0 12px; border: 0; background: none; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; }
.tabs [aria-selected="true"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--ink); }
.tabs small { font-size: 11.5px; padding: 1px 6px; border-radius: 999px; background: rgba(31, 32, 35, 0.07); }

/* ---------- cohorts ---------- */
.cohort { border-collapse: separate; border-spacing: 3px; font-size: 12.5px; }
.cohort th { font-weight: 400; color: var(--muted); padding: 4px 6px; white-space: nowrap; text-align: center; }
.cohort th:first-child, .cohort td:first-child { text-align: left; position: sticky; left: 0; background: #f3f3f5; z-index: 1; border-radius: 8px; padding: 6px 10px; white-space: nowrap; font-family: var(--sans); letter-spacing: 0; }
.cohort td:first-child small { color: var(--muted); margin-left: 6px; }
.cohort td { min-width: 52px; height: 34px; text-align: center; border-radius: 8px; font-family: var(--mono); letter-spacing: -0.03em; }
.cohort td.cell { background: color-mix(in srgb, var(--c-sales) calc(var(--p) * 1%), #eeeef2); color: var(--ink); cursor: default; }
.cohort td.cell.strong { color: #fff; }

/* ---------- parties ---------- */
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 600; font-size: 14px; background: var(--tint, var(--t-plain)); color: var(--tone, var(--c-plain)); }
.split { display: grid; gap: 12px; align-items: start; }
.split > .stack { display: grid; gap: 12px; min-width: 0; }
.fields { display: grid; gap: 10px; }
.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-edit .field { min-width: 0; }
.rows-lazy { content-visibility: auto; contain-intrinsic-size: auto 600px; }
.only-narrow { display: none; }
@media (max-width: 519px) {
  .only-wide { display: none; }
  .only-narrow { display: inline; }
  .choice { grid-template-columns: 1fr; }
}

@media (min-width: 700px) {
  .wgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
  .wg { grid-column: span 4; }
  .wg.w-stat { grid-column: span 1; }
  .wg.w-third, .wg.w-half { grid-column: span 2; }
  .kinds, .tabs { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .line-nums.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .split { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 14px; }
}
@media (min-width: 1280px) {
  .wgrid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .wg { grid-column: span 12; }
  .wg.w-stat { grid-column: span 3; }
  .wg.w-third { grid-column: span 4; }
  .wg.w-half { grid-column: span 6; }
  .wg.w-wide { grid-column: span 8; }
}
@media (min-width: 1700px) { .wgrid { gap: 18px; } }

/* the month still running: lighter, and starred */
.cohort td.cell.partial { opacity: 0.6; }
.cohort td.cell sup { font-size: 9px; margin-left: 1px; }
