/* Base elements: reset, typography, forms, buttons, alerts, cards, tables. Logical properties
   (margin-inline-start, padding-block ...) keep right-to-left languages working without changes. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--brand); }
p { margin: 0 0 12px; }
img { max-inline-size: 100%; }
.muted { color: var(--text-muted); }
.spacer { flex: 1; }
.mono, code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--brand); color: var(--brand-contrast); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { inset-inline-start: 8px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.icon { inline-size: 18px; block-size: 18px; flex: none; vertical-align: middle; }

/* Forms */
label { display: block; font-size: 13px; color: var(--text-muted); margin-block: 14px 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  inline-size: 100%; min-block-size: var(--control-h); padding: 8px 11px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-line); border-color: var(--brand); }
input[aria-invalid=true], .has-error input { border-color: var(--err); }
.field-error { color: var(--err); font-size: 12px; margin-block-start: 3px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-block-size: var(--control-h); padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.block { inline-size: 100%; margin-block-start: 18px; }
.btn.danger { color: var(--err); }
.btn.small { min-block-size: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; inline-size: 36px; block-size: 36px; border: 0; background: transparent; color: inherit; border-radius: var(--radius-sm); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* Alerts and badges */
.alert { padding: 10px 12px; border-radius: var(--radius-sm); margin-block: 12px; font-size: 14px; border: 1px solid; }
.alert.err { background: color-mix(in srgb, var(--err) 10%, transparent); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.alert.ok { background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.alert.warn { background: color-mix(in srgb, var(--warn) 10%, transparent); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.err { color: var(--err); }

/* Cards and layout helpers */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.card + .card { margin-block-start: var(--gap); }
.card > h2:first-child, .card > h3:first-child { margin-block-end: 12px; }
.stack > * + * { margin-block-start: var(--gap); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: var(--gap); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.kpis, .kpis { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpis { margin-block: 12px; }
a.kpi { display: block; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--text-muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 650; margin-block-start: 2px; }

/* Plain pages (sign-in, setup before the shell exists) */
body.plain { min-block-size: 100vh; display: grid; place-items: center; padding: 24px; }
.plain .card { inline-size: min(420px, 100%); padding: 28px; }
.plain .card.wide { inline-size: min(560px, 100%); }
.brand { display: flex; align-items: center; gap: 10px; margin-block-end: 18px; font-weight: 600; font-size: 18px; }
.brand i { inline-size: 34px; block-size: 34px; border-radius: 9px; background: var(--brand); display: inline-block; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-block: 12px; }
.codes code { text-align: center; padding: 8px; }
.lang-links { margin-block-start: 16px; display: flex; gap: 10px; justify-content: center; font-size: 13px; }

/* Plain tables (the data table component adds its own look) */
table.simple { inline-size: 100%; border-collapse: collapse; }
table.simple th { text-align: start; font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 8px 10px; border-block-end: 1px solid var(--border); }
table.simple td { padding: 9px 10px; border-block-end: 1px solid var(--border); }

/* Small helpers used by templates (inline style attributes are blocked by the CSP) */
.narrow { max-inline-size: 360px; }
.narrow-card { max-inline-size: 560px; }
.form-gap { margin-block-start: 14px; }
.small { font-size: 13px; }
.block-btn { inline-size: 100%; justify-content: flex-start; padding-block: 12px; }

/* Tables with actions, permission matrix */
table.simple td.num, table.simple th.num { text-align: end; font-variant-numeric: tabular-nums; }
table.simple td.actions { text-align: end; white-space: nowrap; }
table.simple td.actions .btn + form, table.simple td.actions form + .btn { margin-inline-start: 6px; }
.center { text-align: center !important; }
.matrix th { white-space: nowrap; }
.matrix thead th:not(:first-child):not(:last-child) { cursor: pointer; }
.matrix td, .matrix th { padding-inline: 8px; }
.row-toggle { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 14px; }
.matrix select.scope { min-block-size: 30px; padding-block: 3px; inline-size: auto; }
.check { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 14px; }
.stack-sm > * + * { margin-block-start: 8px; }
.special-title { margin-block: 16px 8px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
input[type=checkbox] { inline-size: 16px; block-size: 16px; accent-color: var(--brand); }

/* Seat meter, indented option groups */
.seat-meter { display: flex; align-items: center; gap: 12px; margin-block-start: 6px; }
.seat-meter progress { inline-size: 220px; block-size: 10px; accent-color: var(--brand); }
.indent { margin-inline-start: 26px; }
select.narrow { max-inline-size: 260px; }

/* Form and filter layouts: fields side by side on wide screens, one under the other on a phone (decision 154) */
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: start; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: start; }
.grid.cols-2 { align-items: start; }
.grid > div > label:not(.check) { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-block-end: 4px; }
.grid > div > input:not([type=checkbox]):not([type=radio]), .grid > div > select, .grid > div > textarea { inline-size: 100%; }
form.inline, .inline { display: inline; margin: 0; }
.alert.info { background: color-mix(in srgb, var(--brand) 9%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); }

/* Tables: a calmer, easier to scan look for every plain list and report */
table.simple { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table.simple thead th { background: color-mix(in srgb, var(--text-muted) 8%, var(--surface)); text-transform: none; }
table.simple tbody tr:nth-child(even) { background: color-mix(in srgb, var(--text-muted) 4%, var(--surface)); }
table.simple tbody tr:hover { background: color-mix(in srgb, var(--brand) 7%, var(--surface)); }
table.simple tbody tr:last-child td { border-block-end: 0; }
.card > table.simple, .card > .table-wrap > table.simple { border: 0; border-radius: 0; }
.table-wrap { overflow-x: auto; }

/* Item pictures (decision 158) */
.item-thumb { inline-size: 36px; block-size: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); vertical-align: middle; }
.pic-col { inline-size: 48px; padding-inline-end: 0; }
.item-picture { flex: none; inline-size: 96px; min-block-size: 96px; display: grid; place-items: center; text-align: center; border: 1px dashed var(--border-strong); border-radius: 10px; overflow: hidden; margin-inline-end: 16px; }
.item-picture img { inline-size: 96px; block-size: 96px; object-fit: cover; }

/* Item pictures on the till (decision 164) */
.pos-thumb { inline-size: 32px; block-size: 32px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); vertical-align: middle; margin-inline-end: 8px; }

/* "E-mail" drop-down on document screens (decision 167) */
.email-box { position: relative; display: inline-block; }
.email-box > summary { list-style: none; cursor: pointer; }
.email-box > summary::-webkit-details-marker { display: none; }
.email-box > .email-form { position: absolute; inset-inline-end: 0; margin-block-start: 6px; z-index: 20; inline-size: min(380px, 90vw); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 14px; text-align: start; }
.email-history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.email-history li { padding: 3px 0; }
