/* ============================================================================
   Compact grouped lists — jobs, triggers, notifications (fixes_and_redesign).
   One white container per group, rows divided by a hairline instead of a card
   each. Desktop: a row is one line, its parts in columns. Phone: the same row
   stacks into two or three lines. Theme variables only (theme.css).
   ============================================================================ */

/* ── Toolbar: search + status chips ───────────────────────────────────────── */
/* min-width / max-width: a flex item, which Safari lets grow to its content — the chip row would then
   push the whole page past the screen instead of scrolling inside it. */
.klist-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: .25rem 0 1rem; min-width: 0; max-width: 100%; }
.klist-tools > * { min-width: 0; max-width: 100%; }
.klist-search {
    display: flex; align-items: center; gap: .45rem; flex: 0 1 280px; min-width: 0;
    height: 34px; padding: 0 .65rem; box-sizing: border-box;
    background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--ink-soft);
}
.klist-search:focus-within { border-color: var(--human); }
.klist-search input {
    flex: 1 1 auto; min-width: 0; border: 0; outline: none; background: transparent;
    font: inherit; font-size: var(--fs-md); color: var(--ink);
}
.klist-search svg { flex: 0 0 auto; }

/* Shown only where the left panel is a drawer: there the chips are how the filter is reached. */
.klist-narrow { display: none; }

.klist-note { display: flex; align-items: flex-start; gap: .4rem; margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); flex: 1 0 100%; }
.klist-note svg { flex: 0 0 auto; margin-top: 1px; }

/* ── Groups ───────────────────────────────────────────────────────────────── */
.klist-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.1rem; min-width: 0; }
.klist-head {
    display: flex; align-items: baseline; gap: .5rem;
    font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--ink-soft); padding: 0 .25rem;
}
.klist-head-note { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: var(--fs-sm); }

.klist {
    list-style: none; margin: 0; padding: 0; min-width: 0;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}

/* ── Row ──────────────────────────────────────────────────────────────────── */
.klist-row {
    display: flex; align-items: center; gap: .6rem; min-width: 0;
    min-height: 52px; padding: .45rem .4rem .45rem .9rem; box-sizing: border-box;
    cursor: pointer; transition: background .12s ease;
}
.klist-row + .klist-row { border-top: 1px solid var(--line); }
.klist-row:hover { background: var(--we); }
.klist-row.static { cursor: default; }
.klist-row.static:hover { background: transparent; }

.klist-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* Desktop columns, each one ellipsized line. Jobs: name | outcome | schedule. Triggers (.rule):
   name | rule | last run. */
.klist-cols {
    display: grid; align-items: center; column-gap: 1.25rem; row-gap: 2px;
    grid-template-columns: minmax(0, 1.3fr) minmax(9.5rem, .7fr) minmax(0, 1.5fr);
}
.klist-cols.rule { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(7.5rem, .5fr); }
/* People in the org chart: name | main unit | who approves (KBM-0013). */
.klist-cols.person { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); }
.klist-cols > * { min-width: 0; }
.klist-full { grid-column: 1 / -1; }

.klist-line { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.klist-name {
    min-width: 0; font-size: var(--fs-lg); font-weight: 600; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.klist-row.off .klist-name { color: var(--ink-soft); }
.klist-sub {
    min-width: 0; font-size: var(--fs-sm); color: var(--ink-soft);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.klist-sub.ink { color: var(--ink); }
.klist-err { font-size: var(--fs-sm); color: var(--alert-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.klist-ico { flex: 0 0 auto; color: var(--ink-soft); }

.klist-tag {
    flex: 0 0 auto; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: .68rem; font-weight: 600; line-height: 1.4; padding: 1px 6px; border-radius: 6px;
    background: var(--paper); color: var(--ink-soft);
}
.klist-tag.proj { background: var(--human-soft); color: var(--human-text); }

/* Outcome: a dot and a word, coloured by tone. */
.klist-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); opacity: .6; }
.klist-status { flex: 0 0 auto; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.t-ok   .klist-dot { background: var(--human); opacity: 1; }
.t-ok   .klist-status { color: var(--human-text); }
.t-err  .klist-dot { background: var(--alert); opacity: 1; }
.t-err  .klist-status { color: var(--alert-text); }
.t-run  .klist-dot { background: var(--focus); opacity: 1; }
.t-run  .klist-status { color: var(--focus-text); }
.t-warn .klist-dot { background: var(--amber); opacity: 1; }
.t-warn .klist-status { color: var(--amber-text); }

/* Trailing controls: the switch and the ⋯, each a full touch target. */
.klist-ctl { flex: 0 0 auto; display: flex; align-items: center; }
.klist-switch { display: flex; align-items: center; justify-content: center; width: 48px; height: 40px; }
.klist-kebab {
    width: 36px; height: 36px; border: 0; border-radius: 9px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: var(--ink-soft); cursor: pointer;
}
.klist-kebab:hover { background: var(--paper); color: var(--ink); }

.klist-empty { padding: 2rem 1rem; text-align: center; font-size: var(--fs-md); color: var(--ink-soft); }

/* A setting that sits above a list, in the same container style. */
.klist-setting {
    display: flex; align-items: center; gap: .75rem; margin: 0 0 1rem;
    padding: .65rem .6rem .65rem .9rem;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.klist-setting-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-md); font-weight: 600; color: var(--ink); }
.klist-setting-text small { font-size: var(--fs-sm); font-weight: 400; line-height: 1.35; color: var(--ink-soft); }

/* ── Row action menu: popover by the ⋯ on desktop, bottom sheet on a phone ── */
.klist-menu-scrim { position: fixed; inset: 0; z-index: 1040; background: transparent; border: 0; padding: 0; }
.klist-menu { position: fixed; z-index: 1041; width: 244px; }
.klist-menu-title { display: none; }
.klist-menu .kctx-item { border: 0; background: transparent; width: 100%; font: inherit; color: inherit; text-align: left; }
.klist-menu .kctx-item.danger { color: var(--alert-text); }
.klist-menu .kctx-item:disabled { color: var(--ink-soft); cursor: default; }

/* ── Phone / tablet: the panel is a drawer, rows stack ───────────────────── */
@media (max-width: 1024px) {
    .klist-narrow { display: flex; }
}

@media (max-width: 768px) {
    .klist-tools { flex-direction: column; align-items: stretch; }
    .klist-search { flex: 0 0 auto; height: 40px; }
    .klist-search input { font-size: 16px; }   /* below 16px iOS zooms the page on focus */
    .klist-tools .k-chip { height: 36px; padding: 0 14px; border-radius: 18px; font-size: .85rem; }

    /* stretch, not the grid's centre: centred lines shrink to their text and never ellipsize. */
    .klist-cols, .klist-cols.rule { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
    .klist-row { padding: .55rem .2rem .55rem .85rem; min-height: 60px; }
    .klist-name { font-size: .95rem; }
    /* Badges beside a name wrap below it instead of squeezing it to "E…": a wrapping line breaks
       on the content's width before anything shrinks. */
    .klist-line { flex-wrap: wrap; row-gap: 2px; }

    .klist-menu-scrim { background: var(--scrim); }
    .klist-menu {
        left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-width: none;
        border-radius: 18px 18px 0 0; padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    }
    .klist-menu::before {
        content: ""; display: block; width: 36px; height: 4px; border-radius: 2px;
        background: var(--line); margin: 0 auto 8px;
    }
    .klist-menu-title {
        display: block; padding: 0 .5rem .5rem; font-size: 1rem; font-weight: 700; color: var(--ink);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .klist-menu .kctx-item { height: 48px; font-size: .95rem; }
}

/* The page head turns into a column at 640px (base.css): there a 100% basis would be a height. */
@media (max-width: 640px) {
    .klist-note { flex: 0 0 auto; }
}

/* ── Project picker on a phone (ProjectPickerModal .ppick) ─────────────────────
   One line per project — code, name, the button — instead of a card per row: status and
   last activity are for sorting on a desktop. */
@media (max-width: 640px) {
    .ppick .k-grid tbody tr {
        display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem;
        margin-bottom: .4rem; padding: .45rem .6rem;
    }
    .ppick .k-grid tbody td { width: auto; padding: 0; min-width: 0; }
    .ppick .k-grid tbody td:nth-child(3), .ppick .k-grid tbody td:nth-child(4) { display: none; }
    .ppick .k-cell-main { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
