/*
  The design kit's one stylesheet, for a development's screens (docs/spec/05-screens.md, 3). It starts from the
  portal's admin screens (server/src/SapPortOne.Portal.Admin/wwwroot/admin.css) - the dark bar across the top, soft
  rounded cards on a cool grey page, the same controls - so that SAP Port One reads as one product; but these are the
  customer's screens, so nothing here carries SAP Port One's brand (no mint, no logo).

  Rules:
  - Every colour is a token below (--kit-*), so a rule never names a colour of its own, and a development can change
    the look by overriding tokens alone. Text tokens read at 4.5:1 or better on the surface they sit on; the ratio is
    noted beside each.
  - Light and dark: dark follows the device (prefers-color-scheme), and data-kit-theme="light" or "dark" on <html>
    fixes either.
  - Everything is under the kit's own names (.kit, .kit-*): a development that uses only part of the kit, or has its
    own styles, is not restyled behind its back. Plain elements are styled only inside .kit, the shell.
  - Logical properties (inline-start, inline-end) throughout, so the same rules lay out right to left in Hebrew and
    left to right in English.
  - Accessible: a visible focus ring on everything that takes the focus, 44px targets, and nothing that needs a
    mouse. Works from a phone's width up.
*/

/* ---- Tokens ------------------------------------------------------------------------------------ */

:root {
    color-scheme: light;

    --kit-page: #f3f5fa;
    --kit-surface: #ffffff;
    --kit-raised: #f7f8fb;                    /* a quiet block inside a card */
    --kit-ink: #0b1220;                       /* 18:1 on surface */
    --kit-body: #384152;                      /* 10:1 */
    --kit-muted: #586174;                     /* 6.4:1 */
    --kit-line: #e4e8f0;
    --kit-line-soft: #eef1f6;
    --kit-field-line: #8a93a6;                /* a field's border: 3:1, as a control's edge needs */

    --kit-bar: #0b1220;                       /* the header */
    --kit-bar-ink: #e7ecf5;                   /* 15:1 on bar */
    --kit-bar-muted: #aeb8ca;                 /* 9:1 */
    --kit-bar-fill: rgba(255, 255, 255, .08);
    --kit-bar-fill-hover: rgba(255, 255, 255, .16);

    --kit-accent: #2f5bff;                    /* buttons: white text 5.2:1 */
    --kit-accent-strong: #2142c9;             /* hover, links: 7.4:1 */
    --kit-accent-soft: #eaf0ff;
    --kit-accent-line: #c8d5ff;
    --kit-on-accent: #ffffff;
    --kit-focus: #2f5bff;

    --kit-good: #12784a;   --kit-good-soft: #e3f5ec;   /* 5.2:1 on its soft fill */
    --kit-wait: #8a4b00;   --kit-wait-soft: #fff2dc;   /* 6.4:1 */
    --kit-bad: #b4232a;    --kit-bad-soft: #fdecec;    /* 5.9:1 */
    --kit-quiet-soft: #eef1f6;

    --kit-scrim: rgba(11, 18, 32, .55);
    --kit-shadow: 0 1px 2px rgba(11, 18, 32, .04), 0 12px 32px rgba(11, 18, 32, .06);
    --kit-radius: 20px;
    --kit-radius-control: 12px;
    --kit-font: Rubik, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

/* Dark, by the device's choice unless the page fixed light. */
@media (prefers-color-scheme: dark) {
    :root:not([data-kit-theme="light"]) {
        color-scheme: dark;

        --kit-page: #0b1220;
        --kit-surface: #131c2e;
        --kit-raised: #1a2438;
        --kit-ink: #eef2f8;                   /* 15:1 on surface */
        --kit-body: #c9d1de;                  /* 11:1 */
        --kit-muted: #9eaabd;                 /* 7:1 */
        --kit-line: #2a3549;
        --kit-line-soft: #212b3e;
        --kit-field-line: #6b7790;            /* 3.4:1 */

        --kit-bar: #060a14;
        --kit-bar-ink: #e7ecf5;
        --kit-bar-muted: #aeb8ca;

        --kit-accent: #3d66ff;                /* white text 4.6:1 */
        --kit-accent-strong: #9db3ff;         /* links: 8:1 on surface */
        --kit-accent-soft: #1b2850;
        --kit-accent-line: #3a4f94;
        --kit-focus: #9db3ff;

        --kit-good: #7fe0b0;   --kit-good-soft: #10301f;   /* 9:1 */
        --kit-wait: #ffc979;   --kit-wait-soft: #35260b;   /* 10:1 */
        --kit-bad: #ffa3a7;    --kit-bad-soft: #3a1518;    /* 8:1 */
        --kit-quiet-soft: #212b3e;

        --kit-scrim: rgba(0, 0, 0, .65);
        --kit-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .25);
    }
}

/* The same dark, fixed by the page. Kept in step with the block above. */
:root[data-kit-theme="dark"] {
    color-scheme: dark;

    --kit-page: #0b1220;
    --kit-surface: #131c2e;
    --kit-raised: #1a2438;
    --kit-ink: #eef2f8;
    --kit-body: #c9d1de;
    --kit-muted: #9eaabd;
    --kit-line: #2a3549;
    --kit-line-soft: #212b3e;
    --kit-field-line: #6b7790;

    --kit-bar: #060a14;
    --kit-bar-ink: #e7ecf5;
    --kit-bar-muted: #aeb8ca;

    --kit-accent: #3d66ff;
    --kit-accent-strong: #9db3ff;
    --kit-accent-soft: #1b2850;
    --kit-accent-line: #3a4f94;
    --kit-focus: #9db3ff;

    --kit-good: #7fe0b0;   --kit-good-soft: #10301f;
    --kit-wait: #ffc979;   --kit-wait-soft: #35260b;
    --kit-bad: #ffa3a7;    --kit-bad-soft: #3a1518;
    --kit-quiet-soft: #212b3e;

    --kit-scrim: rgba(0, 0, 0, .65);
    --kit-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .25);
}

@media (prefers-contrast: more) {
    :root { --kit-muted: var(--kit-body); --kit-line: var(--kit-field-line); }
}

/* ---- Foundations, inside the shell ------------------------------------------------------------- */

/* The page behind the shell takes the shell's colours, so nothing white shows past its edge in dark. */
body:has(> .kit), body:has(> * > .kit) { margin: 0; background: var(--kit-page); }

.kit, .kit *, .kit *::before, .kit *::after { box-sizing: border-box; }

.kit {
    min-height: 100vh; min-height: 100dvh;
    font: 15px/1.55 var(--kit-font);
    color: var(--kit-ink);
    background: var(--kit-page);
    -webkit-font-smoothing: antialiased;
}

.kit a { color: var(--kit-accent-strong); text-decoration: none; }
.kit a:hover { text-decoration: underline; }

.kit h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; }
.kit h2 { font-size: 18px; line-height: 1.3; font-weight: 600; margin: 0 0 4px; }
.kit p { margin: 0 0 12px; }

/* After moving to another page Blazor may put the focus on its heading, so a screen reader says where the person
   arrived. A heading is not something to act on, so it gets no frame. */
.kit h1:focus { outline: none; }

/* One focus ring for everything that takes the focus, from the keyboard. */
.kit :focus-visible, .kit-updating :focus-visible, .kit-install-dialog :focus-visible { outline: 3px solid var(--kit-focus); outline-offset: 2px; }

.kit-muted { color: var(--kit-muted); }
.kit-small { font-size: 13px; }

/* Codes, numbers and dates read left to right inside, but line up with the rest: on the right in Hebrew. */
.kit-ltr { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .kit-ltr { text-align: right; }

.kit-visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Header and menu --------------------------------------------------------------------------- */

.kit-header { position: sticky; top: 0; z-index: 20; background: var(--kit-bar); color: var(--kit-bar-ink); }
.kit-header-in {
    max-width: 1240px; margin: 0 auto; padding: 8px 20px; min-height: 64px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
}
.kit .kit-name {
    display: inline-flex; align-items: center; min-height: 44px;
    color: var(--kit-bar-ink); font-weight: 600; font-size: 17px; letter-spacing: -.01em;
}
.kit .kit-name:hover { color: #fff; text-decoration: none; }

.kit-menu { display: flex; flex-wrap: wrap; gap: 4px; }
.kit .kit-menu-link {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--kit-radius-control);
    color: var(--kit-bar-muted); font-weight: 500;
}
.kit .kit-menu-link:hover { background: var(--kit-bar-fill-hover); color: #fff; text-decoration: none; }
.kit .kit-menu-link.active { background: var(--kit-bar-fill); color: #fff; }

.kit-header-end { margin-inline-start: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--kit-bar-muted); }
.kit-header-end form { margin: 0; }
/* A quiet button in the dark header. */
.kit-header .kit-button.quiet { background: var(--kit-bar-fill); color: var(--kit-bar-ink); border-color: transparent; }
.kit-header .kit-button.quiet:hover:not(:disabled) { background: var(--kit-bar-fill-hover); color: #fff; }

/* ---- Page -------------------------------------------------------------------------------------- */

.kit-main { max-width: 1240px; margin: 0 auto; padding: 26px 20px 64px; }
.kit-main:focus { outline: none; }

.kit-page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 12px 20px; margin-bottom: 18px;
}
.kit-lead { color: var(--kit-muted); font-size: 16px; margin: 0; }
.kit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.kit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 18px; margin-bottom: 18px; }

.kit-card {
    background: var(--kit-surface); border-radius: var(--kit-radius); padding: 20px 22px;
    box-shadow: var(--kit-shadow); min-width: 0; margin-bottom: 18px;
}
.kit-grid > .kit-card { margin-bottom: 0; }
.kit-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 12px; }
.kit-card-head h2 { margin: 0; }

.kit-empty { color: var(--kit-muted); background: var(--kit-raised); border-radius: 14px; padding: 14px 16px; margin: 4px 0; }

/* A centred card on its own, for a sign-in page. */
.kit-narrow { max-width: 440px; margin: 6vh auto 0; }

/* ---- Tables ------------------------------------------------------------------------------------ */

.kit-table-frame { overflow-x: auto; border-radius: 4px; }
.kit-table { width: 100%; border-collapse: collapse; }
.kit-table th { font-size: 13px; color: var(--kit-muted); font-weight: 500; text-align: start; padding: 0 10px 8px; white-space: nowrap; }
.kit-table td { padding: 12px 10px; border-top: 1px solid var(--kit-line-soft); vertical-align: middle; text-align: start; }
.kit-table th:first-child, .kit-table td:first-child { padding-inline-start: 0; }
.kit-table th:last-child, .kit-table td:last-child { padding-inline-end: 0; }
.kit-table .kit-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.kit-table .kit-sub { display: block; font-size: 13px; color: var(--kit-muted); }

/* ---- Status ------------------------------------------------------------------------------------ */

/* A status is a coloured dot and its word, so the colour is never the only signal. */
.kit-chip {
    display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
    padding: 2px 10px; border-radius: 999px; white-space: nowrap; background: var(--kit-quiet-soft); color: var(--kit-muted);
}
.kit-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.kit-chip.good { background: var(--kit-good-soft); color: var(--kit-good); }
.kit-chip.wait { background: var(--kit-wait-soft); color: var(--kit-wait); }
.kit-chip.bad { background: var(--kit-bad-soft); color: var(--kit-bad); }
.kit-chip.info { background: var(--kit-accent-soft); color: var(--kit-accent-strong); }

.kit-notice { padding: 12px 16px; border-radius: 14px; margin: 0 0 16px; background: var(--kit-quiet-soft); color: var(--kit-body); }
.kit-notice.good { background: var(--kit-good-soft); color: var(--kit-good); }
.kit-notice.wait { background: var(--kit-wait-soft); color: var(--kit-wait); }
.kit-notice.bad { background: var(--kit-bad-soft); color: var(--kit-bad); }
.kit-notice.info { background: var(--kit-accent-soft); color: var(--kit-accent-strong); }
.kit-notice a { color: inherit; text-decoration: underline; }

/* ---- Buttons ----------------------------------------------------------------------------------- */

.kit-button {
    font: inherit; font-family: var(--kit-font); font-weight: 600; font-size: 15px; min-height: 44px; min-width: 44px;
    padding: 0 20px; border-radius: var(--kit-radius-control); border: 1px solid transparent;
    background: var(--kit-accent); color: var(--kit-on-accent); cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.kit-button:hover:not(:disabled) { background: var(--kit-accent-strong); color: var(--kit-on-accent); text-decoration: none; }
.kit-button:disabled { opacity: .55; cursor: default; }
.kit-button[aria-busy="true"] { opacity: 1; cursor: progress; }
.kit-button.quiet { background: var(--kit-surface); color: var(--kit-accent-strong); border-color: var(--kit-accent-line); }
.kit-button.quiet:hover:not(:disabled) { background: var(--kit-accent-soft); color: var(--kit-accent-strong); }
.kit-button.danger { background: var(--kit-surface); color: var(--kit-bad); border-color: currentColor; }
.kit-button.danger:hover:not(:disabled) { background: var(--kit-bad-soft); color: var(--kit-bad); }
/* A link drawn as a button keeps the button's colours, not a link's. */
.kit a.kit-button, .kit a.kit-button:hover { color: var(--kit-on-accent); text-decoration: none; }
.kit a.kit-button.quiet, .kit a.kit-button.quiet:hover { color: var(--kit-accent-strong); }
.kit a.kit-button.danger, .kit a.kit-button.danger:hover { color: var(--kit-bad); }
/* Smaller to look at, but the target stays 44px tall: the padding shrinks, not the height. */
.kit-button.small { font-size: 14px; padding: 0 14px; }

.kit-spinner {
    width: 16px; height: 16px; border-radius: 50%; flex: none;
    border: 2px solid currentColor; border-inline-end-color: transparent;
    animation: kit-spin .8s linear infinite;
}
.kit-spinner.large { width: 36px; height: 36px; border-width: 3px; color: var(--kit-accent); }
@keyframes kit-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .kit-spinner { animation-duration: 2.4s; }
}

/* ---- Forms ------------------------------------------------------------------------------------- */

.kit-form { display: flex; flex-direction: column; gap: 16px; }
.kit-field { display: flex; flex-direction: column; gap: 6px; }
.kit-field label { font-weight: 500; color: var(--kit-ink); }
.kit-hint { margin: 0; font-size: 13px; color: var(--kit-muted); }
.kit-error { margin: 0; font-size: 14px; color: var(--kit-bad); font-weight: 500; }

.kit-input {
    font: inherit; font-family: var(--kit-font); color: var(--kit-ink); background: var(--kit-surface);
    min-height: 44px; width: 100%; padding: 0 12px;
    border: 1px solid var(--kit-field-line); border-radius: var(--kit-radius-control);
}
.kit-input:focus { outline: none; border-color: var(--kit-focus); box-shadow: 0 0 0 3px var(--kit-accent-line); }
.kit-input.invalid, .kit-input[aria-invalid="true"] { border-color: var(--kit-bad); }

/* ---- "המערכת מתעדכנת" -------------------------------------------------------------------------- */

/* A modal <dialog>: it takes the focus, and the page behind it cannot be used while it is open. */
.kit-updating {
    border: 0; padding: 0; background: transparent; color: var(--kit-ink);
    max-width: min(420px, calc(100vw - 32px));
}
.kit-updating::backdrop { background: var(--kit-scrim); }
.kit-updating-box {
    background: var(--kit-surface); border-radius: var(--kit-radius); box-shadow: var(--kit-shadow);
    padding: 28px 26px; text-align: center; font-family: var(--kit-font);
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.kit-updating-box h2 { margin: 6px 0 0; font-size: 20px; font-weight: 700; }
.kit-updating-box p { margin: 0; color: var(--kit-body); line-height: 1.55; }

/* ---- The app on a phone (D4): "התקן כאפליקציה" and the iPhone's instruction -------------------- */

/* Hidden until kit-app.js finds the phone can install the screens; never shown in the installed app itself. */
.kit .kit-install { display: none; gap: 8px; border: 0; background: var(--kit-bar-fill); color: var(--kit-bar-ink); font: inherit; font-weight: 600; cursor: pointer; }
[data-kit-install] .kit .kit-install { display: inline-flex; }
.kit .kit-install:hover { background: var(--kit-bar-fill-hover); color: #fff; }

.kit-install-dialog {
    border: 0; padding: 0; background: transparent; color: var(--kit-ink);
    max-width: min(420px, calc(100vw - 32px));
}
.kit-install-dialog::backdrop { background: var(--kit-scrim); }
.kit-install-box {
    background: var(--kit-surface); border-radius: var(--kit-radius); box-shadow: var(--kit-shadow);
    padding: 26px 24px; font-family: var(--kit-font); display: flex; flex-direction: column; gap: 14px;
}
.kit-install-box h2 { margin: 0; font-size: 20px; font-weight: 700; }
.kit-install-box ol { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 12px; }
.kit-install-box li {
    counter-increment: step; display: flex; align-items: center; gap: 12px; line-height: 1.5; color: var(--kit-body);
}
.kit-install-box li::before {
    content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center;
    justify-content: center; background: var(--kit-accent-soft); color: var(--kit-accent-strong); font-weight: 700; font-size: 14px;
}
.kit-install-box li span { flex: 1; }
.kit-install-share { flex: none; color: var(--kit-accent); }
.kit-install-box .kit-button { align-self: stretch; }

/* ---- Phones ------------------------------------------------------------------------------------ */

@media (max-width: 640px) {
    .kit-header-in { padding: 6px 16px; gap: 4px 12px; }
    .kit-main { padding: 18px 16px 48px; }
    .kit h1 { font-size: 24px; }
    .kit-card { padding: 16px; border-radius: 16px; }
    .kit-page-head { align-items: stretch; }
    .kit-page-head .kit-actions, .kit-page-head .kit-actions .kit-button { width: 100%; }
}

/* ---- When the screen fails (KitErrorBar) ------------------------------------------------------- */

/* Hidden until Blazor shows it. */
#blazor-error-ui.kit-error-bar {
    display: none; position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
    padding: 12px 20px; background: var(--kit-bad-soft); color: var(--kit-bad);
    font: 600 15px/1.5 var(--kit-font); box-shadow: 0 -4px 16px rgba(0, 0, 0, .12);
}
#blazor-error-ui.kit-error-bar a { color: inherit; text-decoration: underline; display: inline-flex; align-items: center; min-height: 44px; margin-inline-start: 10px; }
