/* Shipo shared UI (app.css) — design tokens, base element rules, the app shell
 * (sidebar + header), the shared components (panels, forms, buttons, pills, data
 * tables) and the dialog primitives. login.html links it too. Only styling one
 * page alone needs stays in that page's <style>. No build step — served as-is
 * from backend/src/public/. */

:root { --bg:#17181b; --panel:#1e1f23; --card:#28292e; --line:rgba(255,255,255,.10); --txt:#f2f3f5; --muted:#aeb2b7; --accent:#3398a9; --accent-hover:#78c8d6; --accent-fill:#217684; --accent-fill-hover:#1b6370; --accent-text:#4fb0c0; --green:#37c172; --amber:#f1b324; --red:#ec6742; --on-fill:#fff; --input-bg:#141517; --fs-xs:11px; --fs-sm:12px; --fs-md:13px; --fs-base:14px; --fs-lg:16px; --fs-key:18px; --fs-xl:22px; }
/* --accent stays the brand colour for borders, icons and focus rings. Filled
   teal surfaces under white text use --accent-fill (5.26:1), which goes darker
   on hover (--accent-fill-hover); teal text on dark uses --accent-text (5.74:1
   on --card). White on --accent is only 3.38:1, below WCAG AA.
   The --fs-* tokens are the whole type scale: no other font size is used. */
* { box-sizing:border-box; }
html { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
::-webkit-scrollbar { width:10px; height:10px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:rgba(255,255,255,.14); border-radius:8px; border:2px solid transparent; background-clip:padding-box; }
::-webkit-scrollbar-thumb:hover { background:rgba(51,152,169,.6); border:2px solid transparent; background-clip:padding-box; }
::-webkit-scrollbar-corner { background:transparent; }
body { margin:0; font:var(--fs-base)/1.5 'Space Grotesk',-apple-system,Segoe UI,Roboto,sans-serif; background:var(--bg); color:var(--txt); }
a { color:var(--accent-text); }
/* One focus ring for every control. The offset keeps it visible on anything
   teal-filled (.nav-item.active, accent buttons, the active tab). */
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
/* Shared input reset — the board's card-background variant is canonical (the
   old pricing/suppliers --bg variant was copy-paste drift); font-family:inherit
   keeps inputs/textareas off the UA default font (suppliers already did this). */
input, select, button, textarea { background:var(--card); color:var(--txt); border:1px solid var(--line); border-radius:7px; padding:7px 10px; font-size:var(--fs-md); font-family:inherit; }
select, button { cursor:pointer; }
button:hover, select:hover { border-color:var(--accent); }
/* Buttons come in three variants: the default outline (secondary), .btn-primary
   and .btn-danger. A text button is 32px tall, .btn-sm 26px; min-height, so a long
   label wraps instead of spilling. Icon buttons, tabs and chips size themselves
   and reset min-height. */
button { min-height:32px; padding:4px 12px; }
.btn-sm { min-height:26px; padding:2px 8px; font-size:var(--fs-sm); }
.btn-primary { background:var(--accent-fill); border-color:var(--accent-fill); color:var(--on-fill); font-weight:600; }
.btn-primary:hover:not(:disabled) { background:var(--accent-fill-hover); border-color:var(--accent-fill-hover); }
.btn-danger, .btn-danger:hover { border-color:var(--red); color:var(--red); }
button:disabled { opacity:.45; cursor:not-allowed; border-color:var(--line); }
textarea { background:var(--bg); padding:8px 10px; line-height:1.5; resize:vertical; color-scheme:dark; }
label { color:var(--muted); font-size:var(--fs-sm); }
.muted { color:var(--muted); }
/* Status text; colour only, each place sets its own layout. */
.ok { color:var(--green); }
.warn { color:var(--amber); }
.err { color:var(--red); }
/* Keyboard focus is visible everywhere; a mouse click shows no ring. */
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
/* Help text under a form field (UI.field and static forms). */
.field-help { margin:0; font-size:var(--fs-xs); line-height:1.4; color:var(--muted); }
/* UI.field: the heading of a group of controls, and a heading with a badge beside it. */
.field-label { color:var(--muted); font-size:var(--fs-sm); }
.field-head { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
/* A checkbox group, laid out like the .f field next to it. */
fieldset.f, fieldset.bare { border:none; margin:0; padding:0; min-width:0; }
fieldset.f > legend, fieldset.bare > legend { padding:0; margin-bottom:4px; color:var(--muted); font-size:var(--fs-sm); }
/* Names something for a screen reader only. */
.sr-only { position:absolute; width:1px; height:1px; margin:-1px; padding:0; border:0; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }

/* Page content column and its panels. */
.wrap { padding:18px; max-width:1100px; }
.panel { background:var(--panel); border:1px solid var(--line); border-radius:11px; padding:16px 18px; margin-bottom:16px; scroll-margin-top:64px; }
.panel h2 { font-size:var(--fs-md); text-transform:uppercase; letter-spacing:.5px; color:var(--muted); margin:0 0 12px; }
/* A form line (.row) of labelled fields (.f). */
.row { display:flex; gap:10px; align-items:end; flex-wrap:wrap; }
.f { display:flex; flex-direction:column; gap:4px; }

/* Status pill: neutral, or one of the three tones. */
.pill { font-size:var(--fs-xs); font-weight:500; padding:2px 7px; border-radius:20px; border:1px solid var(--line); color:var(--muted); white-space:nowrap; }
.pill--ok { color:var(--green); border-color:rgba(55,193,114,.45); }
.pill--warn { color:var(--amber); border-color:rgba(241,179,36,.45); }
.pill--info { color:var(--accent-text); border-color:rgba(51,152,169,.5); }

/* Data table. */
table.data { width:100%; border-collapse:collapse; font-size:var(--fs-md); margin-top:6px; }
table.data td, table.data th { text-align:left; padding:6px 9px; border-bottom:1px solid var(--line); }
table.data th { color:var(--muted); font-weight:500; }

/* Tab bar (/suppliers directories, /pricing sections). Scoped to the tablist role:
   the board has its own .tabs. */
.tabs[role=tablist] { display:flex; gap:8px; margin:2px 0 14px; flex-wrap:wrap; }
.tab-btn { min-height:0; padding:8px 18px; border:1px solid var(--line); border-radius:20px; background:none; color:var(--muted); cursor:pointer; font:inherit; font-size:var(--fs-md); }
.tab-btn:hover { color:var(--txt); }
.tab-btn.active { border-color:var(--accent); color:var(--accent-text); background:rgba(51,152,169,.1); }

/* ── App shell: sidebar + header (identical on board/pricing/suppliers) ── */
.layout { display:flex; min-height:100vh; }
.sidebar { width:250px; flex:0 0 auto; display:flex; flex-direction:column; background:var(--panel); border-right:1px solid var(--line); padding:14px 12px; position:sticky; top:0; height:100vh; overflow:hidden auto; transition:width .18s ease; }
.sidebar.collapsed { width:62px; padding:14px 8px; }
.side-head { display:flex; align-items:flex-end; justify-content:space-between; gap:6px; margin-bottom:14px; }
.sidebar.collapsed .side-head { justify-content:center; }
.sidebar .brand { display:flex; align-items:flex-end; gap:7px; min-width:0; flex:0 1 auto; }
.sidebar.collapsed .brand { display:none; }
.sidebar .brand img { height:30px; width:auto; display:block; position:relative; top:-3px; flex:0 0 auto; }
.sidebar .brand .wm { font-size:var(--fs-xl); font-weight:700; letter-spacing:2px; line-height:1; color:var(--on-fill); margin-bottom:6px; white-space:nowrap; overflow:hidden; min-width:0; }
.collapse-btn { flex:0 0 auto; width:24px; height:24px; min-height:0; border-radius:6px; background:var(--card); color:var(--muted); border:1px solid var(--line); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:var(--fs-base); line-height:1; padding:0; position:relative; top:-6px; }
.collapse-btn:hover { color:var(--txt); border-color:var(--accent); }
.sidebar.collapsed .collapse-btn { top:0; }
.nav-item { display:flex; align-items:center; gap:11px; padding:9px 11px; border-radius:8px; color:var(--muted); text-decoration:none; font-weight:500; margin-bottom:3px; white-space:nowrap; overflow:hidden; }
.nav-item:hover { background:var(--card); color:var(--txt); }
.nav-item.active { background:var(--accent-fill); color:var(--on-fill); }
.nav-item .ico { flex:0 0 auto; width:20px; height:20px; display:flex; align-items:center; justify-content:center; }
.nav-item .ico svg { width:19px; height:19px; display:block; }
.sidebar.collapsed .nav-item { justify-content:center; padding:9px 0; }
.sidebar.collapsed .nav-item .label { display:none; }
.main { flex:1; min-width:0; }
header { display:flex; align-items:center; gap:14px; height:56px; padding:0 18px; background:var(--panel); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:5; }
header h1 { font-size:var(--fs-lg); margin:0; font-weight:600; flex:0 1 auto; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
header > .muted { flex:0 1 auto; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* UI.mountShell (ui.js): the same right side of the header on every page. */
.hdr-actions { margin-left:auto; display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.icon-btn { width:36px; height:36px; padding:0; display:flex; align-items:center; justify-content:center; color:var(--muted); }
.icon-btn:hover { color:var(--txt); }
.icon-btn svg { width:19px; height:19px; display:block; }
.icon-btn.has-unread { border-color:var(--accent); color:var(--accent-text); }
.bell { position:relative; }
.badge-count { position:absolute; top:-6px; right:-6px; background:var(--red); color:var(--bg); font-size:var(--fs-xs); min-width:17px; height:17px; border-radius:9px; padding:0 4px; display:flex; align-items:center; justify-content:center; font-weight:700; pointer-events:none; }

/* User menu: language, role and logout, at the foot of the sidebar. The rail
   keeps all three reachable, icons only. */
.side-foot { margin-top:auto; padding-top:12px; border-top:1px solid var(--line); display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; }
.side-logout { flex:1 1 100%; display:flex; align-items:center; gap:11px; padding:4px 11px; background:none; color:var(--muted); white-space:nowrap; text-align:left; }
.side-logout:hover { color:var(--txt); }
.side-logout .ico { flex:0 0 auto; width:20px; height:20px; display:flex; align-items:center; justify-content:center; }
.side-logout svg, .role-chip svg { display:block; flex:0 0 auto; }
.side-logout svg { width:19px; height:19px; }
.role-chip svg { width:14px; height:14px; }
.sidebar.collapsed .side-foot { flex-direction:column; flex-wrap:nowrap; justify-content:flex-start; }
.sidebar.collapsed .side-logout { flex:0 0 auto; width:36px; height:36px; padding:0; justify-content:center; }
.sidebar.collapsed .side-logout .label, .sidebar.collapsed .role-chip .label { display:none; }
.sidebar.collapsed .role-chip { padding:5px; }
.sidebar.collapsed .lang-toggle { flex-direction:column; }

/* Below 900px the sidebar is an off-canvas drawer behind the header's hamburger.
   .table-scroll takes a table's sideways scroll, so the page itself never does. */
.menu-btn { display:none; flex:0 0 auto; width:40px; height:40px; padding:0; align-items:center; justify-content:center; color:var(--txt); }
.menu-btn svg { width:21px; height:21px; display:block; }
.scrim { display:none; position:fixed; inset:0; z-index:14; background:rgba(0,0,0,.55); }
@media (max-width:899.98px) {
  .sidebar { position:fixed; left:0; top:0; bottom:0; z-index:15; height:auto; max-width:85vw; visibility:hidden; transform:translateX(-100%); transition:transform .18s ease, visibility .18s; }
  .sidebar.open { visibility:visible; transform:none; transition:transform .18s ease; }
  .scrim.open { display:block; }
  .menu-btn { display:flex; }
  .collapse-btn { display:none; }
  header { gap:8px; padding:0 10px; }
  header > .muted { display:none; }
  /* relative: a table's .sr-only spans are absolute, and without a positioned
     scroller they escape it and widen the page. */
  .table-scroll { position:relative; overflow-x:auto; max-width:100%; }
  .wrap { padding:12px; max-width:100%; }
  .wrap input:not([type=checkbox]):not([type=radio]), .wrap select, .wrap textarea { width:100% !important; max-width:100%; }
  .wrap .row .f { flex:1 1 100%; min-width:0; }
}

/* ── Role-aware chrome (WP-U1) ──
   Anything marked data-perm="resource:action" starts hidden and is revealed by
   ui.js only when /api/me says this session holds that permission; otherwise
   the element is removed outright. Hidden-by-default is the safe direction: a
   page that never gets an answer shows less, not more. Server-side gating is
   the real control (middleware/require-role.ts) — this only stops us offering
   panels whose data endpoints would answer 403.
   .role-chip names the signed-in role in the sidebar's user menu. */
[data-perm] { display:none !important; }
.role-chip { display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:999px; border:1px solid var(--line); background:var(--card); color:var(--muted); font-size:var(--fs-sm); white-space:nowrap; }
.role-chip.privileged { border-color:var(--accent); color:var(--accent-text); }

/* ── Dialog primitives ──
   .dlg-overlay: full-screen dimmer, opened and closed through UI.openDialog /
   UI.closeDialog (ui.js) only; per-dialog z-index / alignment overridden by id
   rules where needed.
   .dlg-box: the small centered dialog shell (UI.confirm).
   .dlg-field: themed form field inside dialogs — replaces the old repeated
   inline "background:var(--bg);color:var(--txt);border:1px solid var(--line);
   border-radius:7px;padding:8px 10px" string. color-scheme:dark keeps native
   widgets (date pickers, number spinners) dark without per-field hacks. */
.dlg-overlay { position:fixed; inset:0; background:rgba(0,0,0,.55); display:none; align-items:flex-start; justify-content:center; padding:5vh 16px; z-index:25; overflow-y:auto; }
.dlg-box { background:var(--panel); border:1px solid var(--line); border-radius:12px; width:420px; max-width:100%; padding:18px; box-shadow:0 14px 34px rgba(0,0,0,.45); }
.dlg-field { background:var(--bg); color:var(--txt); border:1px solid var(--line); border-radius:7px; padding:8px 10px; color-scheme:dark; }

/* UI.confirm (ui.js) — centered, above every other overlay. */
#ui-confirm-overlay { align-items:center; padding:16px; z-index:40; }
#ui-confirm-overlay h3 { margin:0 0 8px; font-size:var(--fs-base); }
#ui-confirm-msg { font-size:var(--fs-md); margin-bottom:16px; white-space:pre-line; }

/* UI.toast (ui.js): persistent themed error toast (audit U2). Lives OUTSIDE
   any polled container so an innerHTML rebuild can never wipe it; dismissed by
   a click on the toast itself or the ~6s auto-timer — never by random clicks. */
#ui-toast { display:none; position:fixed; right:18px; bottom:18px; z-index:400; max-width:440px;
  background:var(--panel); border:1px solid var(--red); color:var(--red); border-radius:9px;
  padding:10px 14px; font-size:var(--fs-md); box-shadow:0 8px 28px rgba(0,0,0,.5); overflow-wrap:anywhere; cursor:pointer; }
/* Non-error toast (opts.kind='info'): accent border, normal text colour. */
#ui-toast.info { border-color:var(--accent); color:var(--txt); }
/* Inline toast action (opts.action): the board's "Geri al" after a delete. */
#ui-toast .toast-action { margin-left:12px; vertical-align:middle; }
