/* =================================================================================================
   EZ-Groups UI — the shared semantic palette and the few shapes that carry it.

   WHY THIS FILE EXISTS (2026-09-19). Stefaan, on the first Purchase Manager screens: "flets, kaal,
   ambtenaar-achtig" — and, in the same breath, the rule that matters more than the taste: "zorg dat
   het platformbreed herkenbaar blijft. Zelfde kleur voor zelfde zaken & taken." Measured that day:
   no app on the platform shared a palette; every app.css carried its own hex codes. The koepel's
   config pages (and Relation Manager, which copied them as .cfg-*) had the most consistent set, so
   THAT set is the palette below — nothing new was invented, it was written down.

   THE RULE
     • MEANING colours are the platform's: green = good / on / in stock, amber = attention / changed /
       rounding, red = error / refused, teal = information, grey = muted. Same colour, same meaning,
       in every app.
     • The APP colour (--mg-app) is the app's own tile tint from the favicon system — the bar wears it,
       and so does the PRIMARY action button (white text on the app colour). Each host sets --mg-app
       and --mg-app-deep once, in :root, nothing else.
     • Typography is the platform line: Verdana (Stefaan 2026-10-26, erp-platform Blok 50), no bold in
       data, no weight 300 (Verdana has no light cut). Depth comes from surface,
       shadow and colour, never from weight.

   HOW TO USE
     <link rel="stylesheet" href="_content/MeninGate.Web.UI/mg-ui.css">  (before the app's own css)
     :root { --mg-app: #1f3a5f; --mg-app-deep: #16293f; }               (the app's tint)
   Then either use the tokens (var(--mg-ok)) in app classes, or the shapes below directly.

   System of record: .claude/docs/brand/ui-palette.md. Adoption per app: erp-platform PLAN.
   ================================================================================================= */

:root {
    /* ink & surfaces */
    --mg-ink:        #1f2d32;
    --mg-muted:      #55666b;
    --mg-rule:       #dfe4ea;
    --mg-rule-soft:  #eef1f4;
    --mg-surface:    #ffffff;
    --mg-bg:         #eef1f5;
    --mg-shadow:     0 1px 2px rgba(20, 40, 70, .06), 0 2px 8px rgba(20, 40, 70, .06);
    --mg-radius:     6px;

    /* meaning */
    --mg-ok:         #1d6a3a;  --mg-ok-bg:     #eaf6ee;  --mg-ok-line:     #bfe3cd;
    --mg-warn:       #8a6d3b;  --mg-warn-bg:   #fdf6e8;  --mg-warn-line:   #f0dfb8;
    --mg-danger:     #c0392b;  --mg-danger-bg: #fbeaea;  --mg-danger-line: #f0c7c9;
    --mg-info:       #14607a;  --mg-info-bg:   #e3eef2;  --mg-info-line:   #bfd6df;
    --mg-muted-bg:   #eef3f3;

    /* tables */
    --mg-thead:      #f1f4f8;  --mg-thead-ink: #4a5a66;
    --mg-zebra:      #f7f9fb;
    --mg-hover:      #fff9e6;

    /* the app's own tint — OVERRIDDEN by every host; these defaults are the platform teal */
    --mg-app:        #1d5666;
    --mg-app-deep:   #0e2b33;
}

/* ---- alerts: one shape, four meanings ------------------------------------------------------- */
.mg-alert {
    padding: .45rem .7rem;
    border: 1px solid var(--mg-rule);
    border-left: 4px solid var(--mg-info);
    border-radius: var(--mg-radius);
    background: var(--mg-info-bg);
    color: var(--mg-ink);
    font-size: .82rem;
}
.mg-alert strong { font-weight: 400; }
.mg-alert--ok     { border-left-color: var(--mg-ok);     background: var(--mg-ok-bg);     border-color: var(--mg-ok-line); }
.mg-alert--warn   { border-left-color: var(--mg-warn);   background: var(--mg-warn-bg);   border-color: var(--mg-warn-line); }
.mg-alert--danger { border-left-color: var(--mg-danger); background: var(--mg-danger-bg); border-color: var(--mg-danger-line); }

/* ---- pills: small state chips, colour carries the meaning ---------------------------------- */
.mg-pill {
    display: inline-block;
    padding: 0 .45rem;
    border-radius: 10px;
    font-size: .68rem;
    line-height: 1.5;
    white-space: nowrap;
    color: var(--mg-muted);
    background: var(--mg-muted-bg);
}
.mg-pill--ok     { color: var(--mg-ok);     background: #e3f2e8; }
.mg-pill--warn   { color: var(--mg-warn);   background: #f6ead9; }
.mg-pill--danger { color: var(--mg-danger); background: var(--mg-danger-bg); }
.mg-pill--info   { color: var(--mg-info);   background: var(--mg-info-bg); }

/* ---- buttons: the primary action wears the app colour --------------------------------------- */
.mg-btn {
    font-family: inherit; font-size: .8rem; line-height: 1;
    padding: .35rem .7rem;
    border: 1px solid var(--mg-rule); border-radius: var(--mg-radius);
    background: var(--mg-surface); color: var(--mg-ink);
    cursor: pointer;
}
.mg-btn:hover { background: #f3f6fa; border-color: #c3cfdc; }
/* The primary button wears the Frontdoor tile colour (--mg-tile, set by Identity's AppTint) - Stefaan 2026-10-02:
   "in iedere app past het kleur van de knop zich aan aan het kleur van de tegel". --mg-app is the fallback. */
.mg-btn--primary { background: var(--mg-tile, var(--mg-app)); border-color: var(--mg-tile, var(--mg-app)); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.mg-btn--primary:hover { background: var(--mg-tile-ink, var(--mg-app-deep)); border-color: var(--mg-tile-ink, var(--mg-app-deep)); }
.mg-btn:disabled { opacity: .5; cursor: default; }

/* ---- a panel: white, rounded, lifted ------------------------------------------------------- */
.mg-panel {
    background: var(--mg-surface);
    border: 1px solid var(--mg-rule);
    border-radius: var(--mg-radius);
    box-shadow: var(--mg-shadow);
}

/* ---- small-caps label, for definition lists and table heads --------------------------------- */
.mg-label {
    font-size: .68rem;
    color: var(--mg-muted);
}

/* ---- .mg-grid: the platform data table ------------------------------------------------------
   Stefaan, 2026-11-19, on the margin calculator's cost screen: "ik ben voorstander van een
   Excel-achtige tabel ... de tabel [mag] niet groter zijn dan dat die moet zijn ... als je een
   scherm hebt waar er heel veel ruimte op is, dan moet die tabel niet de breedte van het scherm
   aannemen ... horizontale en verticale scheidingslijnen."

   THREE THINGS BOOTSTRAP GETS WRONG HERE, and they are why this class exists rather than another
   `.table` override per app:
     1. `.table` is `width: 100%`. On a wide screen that stretches eight short columns across
        1900 px, so the eye has to travel the whole screen to connect a row's first cell to its
        last. `width: auto` makes every column hug its content (UI pillar 12) and the table ends
        where its data ends.
     2. `.table` draws horizontal rules only. Without vertical ones a wide row is a smear; with
        them it reads as a spreadsheet, which is the shape the office already knows.
     3. `.table-sm` is still .25rem/.5rem and `--bs-table-bg` ignores the platform palette.

   Colours and the face are NOT set here: the face comes from /frontdoor/look.css (Blok 51) and the
   colours from the --mg-* tokens above, so a change on the Settings screen still reaches this table
   without a release.

   USE: <table class="mg-grid">, `.mg-grid--fill` when a table really must span (a comparison that
   is meant to be read edge to edge), `.mg-r` on a numeric cell.
   --------------------------------------------------------------------------------------------- */
.mg-grid {
    width: auto;
    max-width: 100%;
    border-collapse: collapse;
    background: var(--mg-surface);
    border: 1px solid var(--mg-rule);
    font-size: .82rem;
    color: var(--mg-ink);
}
.mg-grid--fill { width: 100%; }

/* Every cell carries its own rule, so horizontal AND vertical lines come out of one declaration
   and a colspan cannot leave a gap in the grid. */
.mg-grid th,
.mg-grid td {
    padding: .15rem .4rem;
    border: 1px solid var(--mg-rule-soft);
    vertical-align: middle;
    white-space: nowrap;
    font-weight: inherit;   /* no bold in data - the platform line */
    text-align: left;
}
.mg-grid thead th {
    background: var(--mg-thead);
    color: var(--mg-thead-ink);
    border-color: var(--mg-rule);
    font-size: .72rem;
}
.mg-grid tfoot th,
.mg-grid tfoot td { background: var(--mg-thead); border-color: var(--mg-rule); }
.mg-grid tbody tr:hover > * { background: var(--mg-hover); }

/* Numbers line up or nobody adds them up by eye (UI pillar 12). */
.mg-grid .mg-r { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- <SortTh> (UI pillar 14): its look lives in SortTh.razor.css, so it travels with the component into
   every app — also the ones that never link this file (measured 29/11: RM, invoicing, the koepel). */

/* The face, with the platform default as a fallback (2026-12-02). The face itself comes from
   /frontdoor/look.css (Settings screen, Blok 51) and still wins: it sets --mg-font-sans and loads after
   this file. The fallback is for the one failure mode that otherwise lands a page in Times New Roman -
   look.css not loading (a local run without the Frontdoor, a host it cannot reach). Measured that day:
   CPM locally rendered every grid, select included, in Times 11.5 px; production, with look.css, did
   not. Same rule PortalShell.razor.css follows: the fallback is the documented default, not a second
   palette. */
body { font-family: var(--mg-font-sans, verdana, Geneva, "DejaVu Sans", sans-serif); }
button, input, select, textarea { font-family: inherit; }

/* Form fields inside a grid take the row's height, not their own: a 34 px Bootstrap input in a
   22 px row is what makes a dense table tall again. */
.mg-grid input,
.mg-grid select,
.mg-grid textarea {
    font-family: inherit;
    font-size: inherit;
    padding: .05rem .25rem;
    line-height: 1.35;
    height: auto;
}

/* ---- .mg-grid--edit: a grid you TYPE in, like Excel or Access ------------------------------
   Stefaan, 2026-11-24, on Relation Manager's staff list: "maak er een Excel of Access-achtige tabel
   van die inline kan aangepast worden ... Hij is niet handig om aan te passen en pakt meer dan 2 keer
   teveel plaats in." And the same day, as a platform rule (erp-platform): every list in every app,
   existing or future, is compact, inline editable, with vertical AND horizontal lines.

   What made the old shape tall was two frames per value: a rounded, padded input inside a padded
   cell (~60 px a row). Here the CELL is the field. The input has no frame of its own and fills the
   cell, the grid's rules are the only lines, and focus shows as the cell's outline - the way a
   spreadsheet shows its active cell. A disabled input (read-only user) reads as plain text.

   WIDTH: give each input a `size` = the longest value in its column (UI pillar 11). The input keeps
   that width (width:auto) and min-width:100% lets the shorter values in that column fill the same cell
   instead of leaving a ragged edge. `size` is ignored by type="number": use type="text" with
   inputmode="numeric" for a short number column.

   NEVER CUT, SCROLL (Stefaan 2026-11-25, on a phone: "Primu", "Cahil", "accommodation@ang"). The first
   version had width:100% + min-width:0 on the input and max-width:100% on the table. A percentage width
   counts as ZERO when a table sizes its columns, so a narrow screen squeezed every column below its
   value and clipped the text. Now the columns keep their values and the TABLE scrolls sideways inside
   its own box; the page itself never scrolls sideways.

   WIDTH IS MIN-CONTENT, NOT FIT-CONTENT (measured 2026-12-02, CPM Seasons, Edge, 1920 px). With
   fit-content the box took the anonymous table's max-content, which Chrome computes from the inputs'
   own preferred widths, not from the columns: 1222 px around 848 px of columns, a third of the grid
   empty on the right. CPM had patched it locally (a scroll wrapper + display:table). min-content is the
   sum of the columns because every cell is nowrap: 851 px at 1920, and at 390 px the box stays 345 px
   wide and scrolls its 849 px inside, page scroll 0. Rejected: width:max-content and inline-block (both
   still 1222), display:table on the grid (right width, but a table cannot be its own scroll box, so
   every app would need a wrapper again). Caveat: a cell that opts back into wrapping (white-space:
   normal) is squeezed to its longest word; give that column a width.

   USE: <table class="mg-grid mg-grid--edit">. `.mg-act` on a cell of row icons (save, withdraw ...),
   `.mg-c` on a centred cell (a tick box, a marker), `tr.mg-dirty` on a row with unsaved edits.
   --------------------------------------------------------------------------------------------- */
.mg-grid--edit {
    display: block;          /* the scroll box; the browser wraps the rows in an anonymous table inside it */
    width: min-content;      /* = the sum of the columns; see WIDTH IS MIN-CONTENT above */
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.mg-grid--edit td { padding: 0; }
.mg-grid--edit td > input:not([type="checkbox"]):not([type="radio"]),
.mg-grid--edit td > select,
.mg-grid--edit td input.mg-tel-input {
    display: block;
    width: auto;
    min-width: 100%;
    margin: 0;
    padding: .15rem .4rem;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    outline: none;
    background: transparent;
    color: inherit;
}
.mg-grid--edit td input::placeholder { color: var(--mg-muted); opacity: .6; }
.mg-grid--edit td > input:disabled,
.mg-grid--edit td > select:disabled,
.mg-grid--edit td input.mg-tel-input:disabled { background: transparent; color: inherit; cursor: default; }
.mg-grid--edit td:focus-within { outline: 2px solid var(--mg-app); outline-offset: -2px; background: var(--mg-surface); }
.mg-grid--edit td.mg-act:focus-within,
.mg-grid--edit td.mg-c:focus-within { outline: none; }
/* Blok 69h (mg-excel.js): a selected RECTANGLE of cells (drag, Shift+click, Shift+arrow) and a cell that refused a
   pasted value (a red flash, no words - the module has no text of its own). */
.mg-grid--edit td.mg-xsel { background: color-mix(in srgb, var(--mg-app) 16%, var(--mg-surface)); }
.mg-grid--edit td.mg-xsel:focus-within { background: color-mix(in srgb, var(--mg-app) 24%, var(--mg-surface)); }
.mg-grid--edit td.mg-xbad { box-shadow: inset 0 0 0 2px #c0392b; background: #fdecea; transition: background .3s; }

/* The telephone field (<PhoneField/>) keeps its +32 hint and its call icon, at row height. */
.mg-grid--edit td .mg-tel { gap: .15rem; padding: 0 .15rem 0 .4rem; }
.mg-grid--edit td .mg-tel input.mg-tel-input { padding-left: 0; flex: 1 0 auto; min-width: 0; }
.mg-grid--edit td .mg-tel .mg-tel-call { width: 1.35rem; height: 1.3rem; }

/* Row icons: bare shapes at row height, framed only on hover - a strip of controls, not buttons. */
.mg-grid--edit td.mg-act { padding: 0 .2rem; text-align: right; }
.mg-grid--edit td.mg-c { padding: 0 .3rem; text-align: center; }
.mg-grid--edit td.mg-act button,
.mg-grid--edit td.mg-c button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.5rem; height: 1.3rem; padding: 0; margin: 0;
    border: 1px solid transparent; border-radius: 3px; background: transparent;
    vertical-align: middle; line-height: 1;
}
.mg-grid--edit td.mg-act button:hover:not(:disabled),
.mg-grid--edit td.mg-c button:hover:not(:disabled) { border-color: var(--mg-rule); background: var(--mg-surface); }
.mg-grid--edit td.mg-c input[type="checkbox"] { margin: 0; vertical-align: middle; }

/* Unsaved edits are visible on the row itself, before anybody walks away from them. */
.mg-grid tr.mg-dirty > td { background: var(--mg-warn-bg); }

/* ---- Excel/Access all the way (Pillar 13, extended 2026-11-26; erp-platform Blok 69f) ---------
   <RowSelector/> renders `td.mg-sel`: the narrow grey strip at the left of every row, as in Access.
   A click selects the row (triangle), Delete on the focused strip asks to remove it; the new row
   shows an asterisk. Give the header an empty `<th class="mg-sel"></th>`.
   `tr.mg-new` is the always-present empty row at the bottom (no "+" button): dimmed until it is
   typed in or has the focus, so it reads as an invitation, not as a record.
   <RowDelete/> sits in `.mg-act`: the bin icon, or the one confirmation (question, yes, no).
   --------------------------------------------------------------------------------------------- */
.mg-grid th.mg-sel,
.mg-grid td.mg-sel {
    width: .9rem; min-width: .9rem; padding: 0;
    background: var(--mg-thead); color: var(--mg-thead-ink);
    text-align: center; font-size: .7rem; line-height: 1; cursor: pointer; user-select: none;
}
.mg-grid td.mg-sel:focus { outline: 2px solid var(--mg-app); outline-offset: -2px; }
.mg-grid td.mg-sel--on::before { content: "\25B6"; font-size: .55rem; }
.mg-grid td.mg-sel--new::before { content: "*"; }
.mg-grid tr:has(> td.mg-sel--on) > td:not(.mg-sel) { background: var(--mg-info-bg); }
.mg-grid tbody tr:hover > td.mg-sel { background: var(--mg-rule); }
.mg-grid tr.mg-new:not(.mg-dirty):not(:focus-within) > td:not(.mg-sel) { opacity: .6; }

.mg-grid td.mg-act .mg-del-ask { margin-right: .25rem; white-space: nowrap; color: var(--mg-danger); }
.mg-grid td.mg-act { white-space: nowrap; }
.mg-grid td.mg-act button.mg-del,
.mg-grid td.mg-act button.mg-del-yes { color: var(--mg-danger); }
.mg-grid td.mg-act button.mg-del-yes:focus { outline: 2px solid var(--mg-danger); outline-offset: -1px; }

/* ---- .mg-seg: a choice of two or three, as icon buttons side by side (weerstation 2026-11-29) ----------------
   Pillar 7 (a toggle shows its state) + pillar 9 (actions are icons): every option is visible, the chosen one wears
   the app colour, so the control says what is ON without a word. The buttons carry aria-pressed and a title/aria-label;
   the icon is never the only carrier of meaning. Markup:
     <div class="mg-seg" role="group" aria-label="..."><button type="button" aria-pressed="true" title="...">icon</button>...</div> */
.mg-seg { display: inline-flex; border: 1px solid var(--mg-rule); border-radius: var(--mg-radius); overflow: hidden;
    background: var(--mg-surface); flex: none; }
.mg-seg > button { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent;
    color: var(--mg-muted); padding: .15rem .35rem; line-height: 1; cursor: pointer; }
.mg-seg > button + button { border-left: 1px solid var(--mg-rule); }
.mg-seg > button:hover { color: var(--mg-ink); background: var(--mg-hover); }
.mg-seg > button[aria-pressed="true"] { background: var(--mg-app); color: #fff; cursor: default; }
.mg-seg > button:focus-visible { outline: 2px solid var(--mg-app); outline-offset: -2px; }
/* Words instead of icons, when the options are words by nature (Day / Week / Month / Year - weerstation history). */
.mg-seg--text > button { padding: .3rem .55rem; font-size: .8rem; }
.mg-seg > button:disabled { opacity: .4; cursor: default; background: transparent; }
