/* Screen-specific layout: home counters, receive grid, tree, timeline, typeahead, markdown notes, filters. */

/* home */
.ctrs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; min-height: 76px; }
.ctr { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); min-height: 76px; }
a.ctr:hover { border-color: var(--accent); text-decoration: none; }
.ctr-n { font-size: 22px; font-weight: 700; line-height: 1.1; }
.ctr-l { font-weight: 600; }
.ctr-s { font-size: 12px; color: var(--muted); }
.ctr-info .ctr-n { color: var(--info); }
.ctr-warn .ctr-n { color: var(--warn); }
.ctr-accent .ctr-n { color: var(--accent); }
.ctr-unknown { border-style: dashed; border-color: var(--warn); }
.ctr-unknown .ctr-n { color: var(--warn); }

/* search */
.q { color: var(--accent); }
.results .row-link { grid-template-columns: 1fr auto; }

/* trees (places, projects) */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 18px; border-left: 1px solid var(--border); margin-left: 10px; }
.tree .row-link { grid-template-columns: auto auto 1fr; justify-content: start; column-gap: 10px; }
.tree .row-s { grid-column: auto; }

/* unit timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 4px 0 10px 10px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.tl-data { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.tl-note { margin-top: 2px; }
.tl-who { font-size: 12px; color: var(--faint); }

/* typeahead */
.pk { position: relative; min-width: 0; }
.pk-input { width: 100%; }
.pk-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 2px); max-height: 300px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 260px; }
.pk-opt { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.pk-opt[aria-selected="true"] { background: var(--accent-soft); }
.pk-t { font-weight: 500; overflow-wrap: anywhere; }
.pk-r { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.pk-h, .pk-w { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.pk-w { color: var(--warn); font-weight: 600; }
.pk-create { color: var(--accent); font-weight: 600; }
.pk-empty { padding: 6px 8px; color: var(--muted); }
.pk-note { display: block; color: var(--muted); font-size: 12px; min-height: 16px; overflow-wrap: anywhere; }

/* receive */
.rc-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 12px; align-items: start; }
.rc-head input[type="text"], .rc-head input[type="date"], .rc-head select { width: 100%; }
.rc .table-wrap { overflow: visible; } /* the typeahead list must not be clipped */
.rc-grid { table-layout: fixed; }
.rc-grid th:nth-child(1) { width: 32px; }
.rc-grid th:nth-child(3), .rc-grid th:nth-child(4), .rc-grid th:nth-child(5) { width: 7.5em; }
.rc-grid th:nth-child(6) { width: 8em; }
.rc-grid th:nth-child(7) { width: 40px; }
.rc-grid td { vertical-align: top; padding-top: 4px; padding-bottom: 4px; }
.rc-grid .num-input { width: 100%; }
.rc-grid .landed { padding-top: 10px; }
.rc-charges { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.rc-charges .inline input { width: 7em; text-align: right; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--border); z-index: 5; }

/* notes (safe markdown) */
.md p { margin: 6px 0; }
.md pre { background: var(--surface-2); padding: 8px 10px; border-radius: 6px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md table { border-collapse: collapse; margin: 6px 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 3px 8px; text-align: left; }
.md ul, .md ol { padding-left: 20px; }

/* journal filters */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filters input { width: 150px; }

/* login / keys */
.login { max-width: 560px; }
.keys dt { text-align: right; }

@media (max-width: 640px) {
  .rc-grid td.rc-item { display: block; text-align: left; }
  .rc-grid td.rc-item::before { display: block; margin-bottom: 2px; }
  .rc-grid { table-layout: auto; }
  .rc-grid .num-input { width: 9em; }
  .filters input, .filters select { flex: 1 1 140px; width: auto; }
  .sticky-actions { bottom: calc(var(--tabbar) + var(--safe-b)); }
  .pk-list { min-width: 0; }
}
