/*
 * Keeper base: product-neutral page primitives shared by the Keeper apps. Plain CSS, no build step.
 * Load it before the product stylesheet. It writes no colour or font values. Everything resolves
 * through the --k-* roles, which each product sets in its own token block (RabbitKeeper: app.css).
 * Contract and ownership: docs/keeper-kit.md.
 */

* { box-sizing: border-box; }
body { margin: 0; background: var(--k-bg); color: var(--k-ink); font: 16px/1.45 var(--k-font-body); }
a { color: var(--k-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-family: var(--k-font-display); }
.shell h1, .shell h2 { margin: 0; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
    outline: 2px solid var(--k-accent);
    outline-offset: 2px;
}

/* Hidden until focused, then pinned to the top corner above the workspace chrome. */
.skip-link { position: absolute; z-index: 20; inset: 8px auto auto 8px; padding: 10px 16px; border-radius: 999px; background: var(--k-surface); color: var(--k-ink); font-weight: 600; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
main[tabindex="-1"]:focus { outline: none; }

.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--k-accent); cursor: pointer; text-align: left; }
.linkbtn:hover { text-decoration: underline; }
.link { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; font: 400 14px var(--k-font-body); color: var(--k-accent); cursor: pointer; white-space: nowrap; }
.link:hover { text-decoration: underline; }
.link--dim { color: var(--k-dim); }

.notice { background: var(--k-highlight); color: var(--k-ink); border-radius: 12px; padding: 12px 16px; font-weight: 600; }

/* ---- page head: title, sub line and actions. --h1 is the page scale set by the product shell. ---- */
.head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; }
.head h1 { font-size: var(--h1); font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.eyebrow { font-size: 14px; color: var(--k-dim); margin-bottom: 7px; }
.sub { font-size: 15px; color: var(--k-dim); margin-top: 4px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-label { display: block; font: 600 11px/1.4 var(--k-font-body); letter-spacing: .04em; color: var(--k-accent); }
.section-heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; }
.section-heading h2 { font: 700 24px/1.1 var(--k-font-display); margin: 0; }
.section-heading > span { font-size: 13px; color: var(--k-dim); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 20px; border-radius: 999px; border: 1.5px solid transparent; font: 600 15px var(--k-font-body); cursor: pointer; text-decoration: none; }
.btn[hidden] { display: none; }
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--k-accent); color: var(--k-on-accent); }
.btn--outline { background: transparent; border-color: var(--k-ink); color: var(--k-ink); }
.btn--danger { background: var(--k-danger); color: var(--k-on-accent); }

/* ---- cards, chips, rows and facts ---- */
.card { background: var(--k-surface); border: 1px solid var(--k-line); border-radius: 18px; padding: 18px; }
.card h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.empty { color: var(--k-dim); margin: 6px 0; }
.foot { font-size: 13px; color: var(--k-dim); margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--k-line); background: var(--k-surface); font-weight: 600; font-size: 14px; color: var(--k-ink); }
.chip:hover { text-decoration: none; }
.chip span { display: inline-flex; justify-content: center; align-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: var(--k-soft); color: var(--k-ink); font-size: 12px; font-weight: 400; }
.chip.on { background: var(--k-ink); color: var(--k-on-accent); border-color: var(--k-ink); }
.chip.on span { background: var(--k-highlight); }

.list h2 { margin-bottom: 4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 56px; padding: 8px 0; border-top: 1px solid var(--k-line); color: var(--k-ink); }
.row:hover { text-decoration: none; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-meta { font-size: 14px; color: var(--k-dim); }
.row-end { font-size: 14px; color: var(--k-dim); white-space: nowrap; }

.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; }
.facts > div { padding: 12px 14px; border-top: 1px solid var(--k-line); }
.facts dt { font-size: 13px; color: var(--k-dim); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.notes { margin: 0; font-size: 17px; white-space: pre-line; overflow-wrap: anywhere; }

/* ---- forms ---- */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field label, .field .label, .field legend { font-size: 14px; font-weight: 600; padding: 0; }
.input { width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--k-line); border-radius: 12px; background: var(--k-surface); color: var(--k-ink); font: 16px var(--k-font-body); }
textarea.input { min-height: 120px; resize: vertical; }
.input.narrow { width: 110px; }
.hint { font-size: 13px; color: var(--k-dim); }
.err { font-size: 14px; font-weight: 600; color: var(--k-danger); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.pair { display: flex; flex-wrap: wrap; gap: 12px; }
.unit { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; font-weight: 400; }
.choice input { width: 22px; height: 22px; accent-color: var(--k-accent); }
details.field summary { cursor: pointer; font-weight: 600; font-size: 14px; min-height: 44px; display: flex; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- motion ---- */
.btn, .chip { transition: background .18s, border-color .18s, transform .18s; }
.btn:hover { transform: translateY(-1px); }
.btn--primary:hover { background: var(--k-ink); }
.btn--outline:hover { background: var(--k-soft); }
@media (prefers-reduced-motion: reduce) {
    .btn, .chip { transition: none; }
    .btn:hover { transform: none; }
}

/* ---- record screens: detail head and menu, list groups, filters, count and pager ---- */
.record-head { align-items: flex-start; }
.record-head .sub { margin-bottom: 0; }
.record-back { align-self: flex-start; }
.record-quick-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.record-menu { position: relative; }
.record-menu summary { list-style: none; white-space: nowrap; }
.record-menu summary::-webkit-details-marker { display: none; }
.record-menu ul {
    position: absolute;
    z-index: 2;
    inset-inline-end: 0;
    min-width: max-content;
    margin: 6px 0 0;
    padding: 4px 0;
    list-style: none;
    border: 1px solid var(--k-line);
    border-radius: 12px;
    background: var(--k-surface);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--k-ink) 12%, transparent);
}
.record-menu a { display: flex; align-items: center; min-height: 44px; padding: 4px 14px; }
.record-menu a:hover { background: var(--k-soft); }
.record-menu .record-delete { color: var(--k-danger); border-top: 1px solid var(--k-line); }

.record-groups { display: flex; flex-wrap: wrap; gap: 0 18px; border-bottom: 1px solid var(--k-line); }
.record-groups a { display: flex; align-items: center; min-height: 44px; border-bottom: 2px solid transparent; }
.record-groups a[aria-current="page"] { color: var(--k-ink); border-color: var(--k-accent); font-weight: 700; }
/* Default filter row: search, two selects and the submit. See the modifiers below for other shapes. */
.record-filters { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.record-filters > .actions { margin: 0; gap: 0 10px; min-height: 46px; }
.record-filters .input { min-width: 0; }
.list-options { min-width: 0; }
.list-options label { display: flex; align-items: center; gap: 6px; }
.record-page-summary { color: var(--k-dim); font-size: 14px; margin: 0 0 -9px; }
.record-pages { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.record-pages .actions { margin: 0; }
.record-fields { display: grid; min-inline-size: 0; gap: 14px; margin: 0; border: 0; border-top: 1px solid var(--k-line); padding: 12px 0 0; }
.record-fields legend { padding-inline-end: 10px; font: 700 18px var(--k-font-display); }
.record-fields > p { margin: 0; }

/* ---- phone ---- */
@media (max-width: 760px) {
    .head-actions { flex: 1 1 100%; }
    .head-actions .btn { flex: 1 1 0; }
    .section-heading h2 { font-size: 22px; }
    .section-heading > span { font-size: 12px; }
    .chips { gap: 6px; }
    .chip { padding-inline: 12px; }
    .input.narrow { width: 100%; min-width: 90px; }
    .pair .unit { flex: 1 1 120px; }
    .record-menu:not(:first-child) { margin-inline-start: auto; }
    .record-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .record-filters > :is(.record-search, .actions) { grid-column: 1 / -1; }
}

/* Filter modifiers keep their columns at every width, so they follow the phone rules above.
   --fit: many fields (list options, sort) wrap into as many 136px columns as fit.
   --compact: one search field and its submit. */
.record-filters--fit { grid-template-columns: repeat(auto-fit, minmax(min(100%, 136px), 1fr)); }
.record-filters--compact { grid-template-columns: minmax(0, 1fr) auto; }
