/* app.css -- the application pages (home, Jobs, Admin, sign-in).
   Loaded after shell.css and uses its tokens. Operational-screen scale:
   title 24/700, card header 18/600, body and cells 16/400, labels and
   badges 14. Spacing in multiples of 4; radii 6 and 4; two shadows.
   Every colour is a token from css/tokens.css, light and dark. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0; background: var(--c-surface); color: var(--c-ink);
    font-family: var(--sx-font); font-size: 16px; line-height: 1.5;
}
a { color: var(--c-link); }
code, .ident { font-family: ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums slashed-zero; font-size: 14px; }

/* ---- page ------------------------------------------------------- */
.page { max-width: 1440px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { font-size: 24px; font-weight: 700; margin: 0; color: var(--c-ink); }
.lede { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { font-size: 14px; }

/* ---- notices ---------------------------------------------------- */
.notice { padding: 12px 16px; border-radius: var(--sx-radius-ctl); margin-bottom: 16px; border-left: 4px solid; }
.notice.ok    { background: var(--c-pos-tint);   color: var(--c-pos-ink); }
.notice.warn  { background: var(--c-warn-tint); color: var(--c-warn-ink); }
.notice.error { background: var(--c-neg-tint);  color: var(--c-neg-ink); }
.notice ul { margin: 4px 0 0 20px; padding: 0; }

/* ---- cards ------------------------------------------------------ */
.card {
    background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--sx-radius-card);
    box-shadow: var(--sx-shadow-card); margin-bottom: 20px; overflow: auto;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 16px 20px; border-bottom: 1px solid var(--c-line);
}
.card-head h2 { font-size: 18px; font-weight: 600; margin: 0; }
.card-head .muted { font-weight: 400; }
.card-body { padding: 16px 20px; }

/* A card with data-fold folds to its heading when the heading is clicked
   (js/app.js), as crm's sync admin sections did. While the Syncs page's
   filters narrow the list, folded sections open so no match is hidden. */
.card[data-fold] > .card-head { cursor: pointer; user-select: none; }
.card[data-fold] > .card-head h2::before {
    content: ""; display: inline-block; margin-right: 12px; vertical-align: middle;
    border-left: 8px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent;
    transform: rotate(90deg); transition: transform .2s ease;
}
.card.is-folded > .card-head { border-bottom: 0; }
.card.is-folded > .card-head h2::before { transform: none; }
.card.is-folded > :not(.card-head) { display: none; }
body.is-filtering .card.is-folded > :not(.card-head) { display: revert; }
body.is-filtering .card.is-folded > .card-head h2::before { transform: rotate(90deg); }
.fold-all { display: flex; justify-content: flex-end; gap: 16px; margin: 0 0 8px; font-size: 14px; }
.fold-all button { background: none; border: 0; padding: 0; font: inherit; color: var(--c-link); cursor: pointer; }
.fold-all button:hover { text-decoration: underline; }

/* ---- tables ----------------------------------------------------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left; font-size: 14px; font-weight: 600; padding: 8px 12px;
    background: var(--c-surface-sunk); border-bottom: 1px solid var(--c-line); white-space: nowrap;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--c-line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .sub { font-size: 14px; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data tr.is-hidden { display: none; }

@media (max-width: 760px) {
    table.data.stack, table.data.stack tbody { display: block; width: 100%; }
    table.data.stack thead { display: none; }
    table.data.stack tr { display: block; border-bottom: 1px solid var(--c-line); padding: 8px 0; }
    table.data.stack tr.is-hidden { display: none; }
    table.data.stack td { display: block; border: 0; padding: 4px 16px; text-align: left; }
    table.data.stack td::before { content: attr(data-label); display: block; font-size: 14px; font-weight: 600; }
    table.data.stack td.num { text-align: left; }
    table.data.stack td.actions { padding-top: 8px; }
    table.data.stack td.actions::before { content: none; }
    table.data.stack td.actions .form-actions.end { justify-content: flex-start; }
}

/* ---- badges ----------------------------------------------------- */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: var(--sx-radius-ctl);
    font-size: 14px; font-weight: 600; white-space: nowrap;
}
.badge.ok   { background: var(--c-pos-tint);   color: var(--c-pos-ink); }
.badge.warn { background: var(--c-warn-tint); color: var(--c-warn-ink); }
.badge.err  { background: var(--c-neg-tint);  color: var(--c-neg-ink); }
.badge.off  { background: var(--c-off-tint);  color: var(--c-off-ink); }
.badge.info { background: var(--c-surface); color: var(--c-link); box-shadow: inset 0 0 0 1px var(--c-link); }

/* ---- buttons ---------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 8px 16px; border-radius: var(--sx-radius-ctl);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    background: var(--c-bar); color: var(--c-on-solid); border: 1px solid var(--c-bar);
}
.btn:hover { filter: brightness(1.12); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--c-bar); outline-offset: 2px;
}
.btn.secondary { background: var(--c-surface); color: var(--c-link); }
.btn.secondary:hover { background: var(--c-surface-sunk); filter: none; }
.btn.danger { background: var(--c-surface); color: var(--c-neg-ink); border-color: var(--c-neg-solid); }
.btn.danger:hover { background: var(--c-neg-tint); filter: none; }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; }

/* ---- forms ------------------------------------------------------ */
.form-row { margin-bottom: 16px; }
.form-row > label, .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.hint { font-size: 14px; margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=number], select, textarea {
    font: inherit; font-size: 16px; color: var(--c-ink); background: var(--c-surface);
    padding: 8px 12px; border: 1px solid var(--c-line-strong); border-radius: var(--sx-radius-ctl); min-height: 40px;
}
input[type=month], input[type=date], input[type=datetime-local] {
    font: inherit; font-size: 16px; padding: 8px 12px; border: 1px solid var(--c-line-strong);
    border-radius: var(--sx-radius-ctl); min-height: 40px; width: auto;
}
.w1 { width: 11ch; } .w2 { width: 22ch; } .w3 { width: 33ch; } .w4 { width: 44ch; }
@media (max-width: 760px) { .w3, .w4 { width: 100%; } }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--c-link); margin: 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.form-grid { display: flex; flex-wrap: wrap; gap: 0 24px; align-items: flex-start; }
.form-grid > .form-row { max-width: 100%; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.form-actions.end { justify-content: flex-end; }
details.sub summary { cursor: pointer; color: var(--c-link); }
details.sub p { margin: 4px 0; max-width: 60ch; }
fieldset { border: 1px solid var(--c-line); border-radius: var(--sx-radius-card); padding: 12px 16px; margin: 0 0 16px; }
legend { font-size: 14px; font-weight: 600; padding: 0 4px; }

/* ---- filters ---------------------------------------------------- */
.filters { display: flex; gap: 12px 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.filters .f { display: flex; flex-direction: column; }
.filters .f label { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.filters .count { font-size: 14px; margin-left: auto; align-self: center; }

/* ---- tiles (home, endpoint strip) -------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile {
    display: block; padding: 16px 20px; border: 1px solid var(--c-line); border-radius: var(--sx-radius-card);
    box-shadow: var(--sx-shadow-card); background: var(--c-surface); color: var(--c-ink); text-decoration: none;
}
a.tile:hover { border-color: var(--c-bar); }
.tile h3 { font-size: 18px; font-weight: 600; margin: 0 0 4px; color: var(--c-link); }
.tile p { margin: 0; font-size: 14px; }
.tile .meta { margin-top: 8px; font-size: 14px; }
.tile.busy { border-left: 4px solid var(--c-bar); }
.tiles.compact { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tiles.compact .tile { padding: 12px 16px; }
@media (max-width: 760px) { .tiles.compact { grid-template-columns: 1fr 1fr; gap: 8px; } .tiles.compact .tile h3 { font-size: 16px; } }
.log:empty { display: none; }

/* ---- log -------------------------------------------------------- */
.log {
    background: var(--c-head); color: var(--c-on-solid); border-radius: var(--sx-radius-ctl);
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.5;
    padding: 12px 16px; max-height: 420px; overflow: auto; white-space: pre-wrap; margin: 0;
}

/* ---- pager ------------------------------------------------------ */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 20px; }
.list-end { padding: 12px 20px; text-align: center; }

/* ---- sign-in pages ---------------------------------------------- */
.auth-wrap { max-width: 440px; margin: 64px auto; padding: 0 16px; }
.auth-wrap .card { overflow: hidden; }
.auth-brand { font-size: 24px; font-weight: 700; color: var(--c-link); margin-bottom: 16px; text-align: center; }
.auth-wrap input[type=text], .auth-wrap input[type=password] { width: 100%; }
.auth-wrap .btn { width: 100%; }
.or { text-align: center; font-size: 14px; margin: 16px 0; }

@media (max-width: 760px) {
    .page { padding: 16px; }
}

.struck, .struck td { text-decoration: line-through; }
.big code, .big .ident { font-size: 18px; }

/* Recovery codes, shown once at setup (v19). */
ul.codes { list-style: none; padding: 0; margin: 8px 0 16px; columns: 12rem 2; max-width: 30rem; }
ul.codes li { margin: 0 0 6px; white-space: nowrap; }
