/* BSLAW shared UI: tokens and components of docs/design/UI_UX_RULES.md (living reference docs/design/style-guide.html).
   Served publicly at /ui.css?v=… (the login page uses it before sign-in); no secrets here. Colours only as tokens. */
:root {
  --bg: #ffffff; --bg-subtle: #f7f8fa; --bg-hover: #eef1f5;
  --text: #111418; --text-muted: #4b5563; --text-subtle: #6b7280;
  --border: #e3e6eb; --border-control: #7a8494;
  --primary: #1c2f54; --primary-hover: #142341; --primary-soft: #eef1f6; --primary-soft-hover: #dfe5ef; --on-primary: #ffffff;
  --ring: rgba(28,47,84,.28); --gold: #c8913f; --mark: #fbeccd;
  --ok: #1f7a3a; --ok-soft: #e8f4ec; --warn: #9a5b00; --warn-soft: #fbf1e1; --bad: #b3261e; --bad-soft: #fbe9e7;
  --scrim: rgba(17,20,24,.32); --shadow-pop: 0 8px 24px rgba(17,20,24,.12); --shadow-sheet: 0 -8px 24px rgba(17,20,24,.16);
  --r-control: 8px; --r-card: 12px; --r-tag: 6px; --r-sheet: 16px;
  --h: 40px; --h-sm: 32px; --h-lg: 48px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .3, 1);
  color-scheme: light;
}

/* ---------- base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; font-weight: 600; line-height: 1.3; }
h2 { font-size: 17px; font-weight: 600; line-height: 1.4; }
h3 { font-size: 14px; font-weight: 600; }
b, strong { font-weight: 600; }
a { color: var(--primary); }
.muted { color: var(--text-muted); }
.data-asof { margin: 0; padding: 6px 18px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.subtle { color: var(--text-subtle); font-size: 13px; }
.small { font-size: 13px; }
.num, .mono { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
a:focus-visible { border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ---------- buttons (7.1): primary, secondary, ghost, danger; sm = 32 px */
.btn { all: unset; box-sizing: border-box; cursor: pointer; height: var(--h); padding: 0 16px; border-radius: var(--r-control); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 500; line-height: 1.2; border: 1px solid var(--border-control); background: var(--bg); color: var(--text); white-space: nowrap; text-decoration: none; transition: background .12s var(--ease), border-color .12s var(--ease); }
.btn:hover { background: var(--bg-hover); }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { border-color: transparent; color: var(--primary); background: transparent; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { height: var(--h-sm); padding: 0 12px; font-size: 13px; }
.btn.lg { height: var(--h-lg); padding: 0 20px; font-size: 15px; }
.btn.block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn svg.i { width: 16px; height: 16px; }
.icon-btn { all: unset; box-sizing: border-box; cursor: pointer; width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--r-control); color: var(--text-muted); flex: none; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ui-spin .8s linear infinite; flex: none; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
/* an action inside a sentence: the "light" button, inline (rule 7.1: underlined links only change page) */
.linkish { all: unset; cursor: pointer; color: var(--primary); font-weight: 500; border-radius: 4px; padding: 6px 2px; margin: -6px -2px; }  /* 32 px tall where it stands alone */
.linkish:hover { background: var(--primary-soft); }
.linkish:focus-visible { box-shadow: 0 0 0 3px var(--ring); }

/* ---------- fields (7.2) */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.input { height: var(--h); width: 100%; min-width: 0; padding: 0 12px; border: 1px solid var(--border-control); border-radius: var(--r-control); background: var(--bg); font-size: 15px; transition: border-color .12s var(--ease), box-shadow .12s var(--ease); }
.input::placeholder { color: var(--text-subtle); }
.input:focus, .input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input[disabled] { background: var(--bg-subtle); cursor: not-allowed; }
.input.sm { height: var(--h-sm); font-size: 14px; padding: 0 10px; }
.input.lg { height: var(--h-lg); padding: 0 14px; }
.input.err, .input[aria-invalid="true"] { border-color: var(--bad); }
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
textarea.input.mono { font: 13px/1.5 var(--mono); }
select.input { appearance: none; padding-right: 36px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%234b5563' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center; cursor: pointer; }
.hint-err { font-size: 13px; color: var(--bad); }
.check { display: inline-flex; gap: 8px; align-items: center; min-height: var(--h-sm); cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); flex: none; cursor: pointer; }
.search { position: relative; flex: 1; min-width: 0; display: block; }
.search > svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search .input { padding-left: 42px; padding-right: 44px; }
.search .input::-webkit-search-cancel-button { display: none; }
.search .clear-x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

/* ---------- switch (button role=switch, label inside) and segmented control */
.switch { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; min-height: var(--h); font-size: 14px; border-radius: var(--r-control); padding-right: 4px; }
.switch .track { width: 36px; height: 20px; border-radius: 99px; background: var(--border-control); position: relative; flex: none; transition: background .12s var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); transition: left .12s var(--ease); box-shadow: 0 1px 2px var(--scrim); }
.switch[aria-checked="true"] .track { background: var(--primary); }
.switch[aria-checked="true"] .track::after { left: 18px; }
.switch:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.switch.sm { min-height: var(--h-sm); font-size: 13px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-control); border-radius: var(--r-control); overflow: hidden; min-height: var(--h); max-width: 100%; }
.seg.sm { min-height: var(--h-sm); }
.seg button { all: unset; box-sizing: border-box; cursor: pointer; padding: 0 14px; font-size: 14px; display: grid; place-items: center; min-height: calc(var(--h) - 2px); }
.seg.sm button { min-height: var(--h-sm); padding: 0 12px; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border-control); }
.seg button:hover { background: var(--bg-hover); }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.seg button:focus-visible { box-shadow: inset 0 0 0 3px var(--ring); }

/* ---------- the four kinds (7.5): status tag, toggle chip, suggestion, citation */
.tag { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; max-width: 100%; padding: 0 8px; border-radius: var(--r-tag); font-size: 12px; font-weight: 500; line-height: 1.5; white-space: nowrap; background: var(--bg-subtle); color: var(--text-muted); vertical-align: baseline; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--primary-soft); color: var(--primary); }
.tag.long { white-space: normal; overflow-wrap: break-word; }  /* a sentence in a tag (a deadline): it wraps */
.chip { all: unset; box-sizing: border-box; cursor: pointer; min-height: var(--h-sm); padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-control); background: var(--bg); font-size: 13px; line-height: 1.3; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.chip:hover { background: var(--bg-hover); }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 500; }
.chip[aria-pressed="true"]::before { content: "✓"; }
.chip:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.chip[disabled] { opacity: .45; cursor: not-allowed; }
.sug { all: unset; box-sizing: border-box; cursor: pointer; padding: 8px 12px; border-radius: var(--r-control); border: 1px solid var(--border-control); background: var(--bg); font-size: 14px; line-height: 1.45; display: inline-flex; gap: 8px; align-items: flex-start; max-width: 100%; overflow-wrap: anywhere; }
.sug:hover { background: var(--bg-hover); border-color: var(--primary); }
.sug:focus-visible { box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }
.sug > svg.i { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--text-muted); }
.sug[disabled] { opacity: .45; cursor: not-allowed; }
.cite { all: unset; cursor: pointer; display: inline; font-size: 13px; font-weight: 500; line-height: 1.6; background: var(--primary-soft); color: var(--primary); padding: 1px 8px; border-radius: 999px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.cite:hover, .cite.on { background: var(--primary); color: var(--on-primary); }
.cite:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.cite.gone { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; cursor: default; }
/* a citation standing alone (a row of căn cứ, a table cell) is a 32 px pill; inside a sentence it stays inline */
.cites .cite, td .cite { display: inline-flex; align-items: center; min-height: var(--h-sm); padding: 2px 12px; line-height: 1.35; }

/* ---------- combobox (7.3): ui.js Combo */
.combo { position: relative; display: inline-flex; min-width: 0; max-width: 100%; }
.combo-btn { all: unset; box-sizing: border-box; cursor: pointer; height: var(--h); padding: 0 34px 0 12px; border: 1px solid var(--border-control); border-radius: var(--r-control); display: inline-flex; align-items: center; gap: 4px; font-size: 14px; max-width: 280px; min-width: 150px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%234b5563' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center; }
.combo-btn:hover { background-color: var(--bg-hover); }
.combo-btn:focus-visible, .combo-btn[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.combo-btn .k { color: var(--text-muted); flex: none; }
.combo-btn .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.combo.on .combo-btn { border-color: var(--primary); background-color: var(--primary-soft); color: var(--primary); padding-right: 66px; }
.combo.on .combo-btn .k { color: var(--primary); }
.combo-x { all: unset; box-sizing: border-box; cursor: pointer; position: absolute; right: 28px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-tag); color: var(--primary); font-size: 17px; }
.combo-x:hover { background: var(--primary-soft-hover); }
.combo-x:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.combo-pop { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: max(100%, 340px); background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); padding: 8px; display: grid; gap: 6px; animation: ui-pop .14s var(--ease); }
.combo-pop.right { left: auto; right: 0; }
.combo-pop .input { height: 36px; font-size: 14px; }
.combo-head { display: none; }
.combo-opts { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; display: grid; gap: 1px; }
.combo-opt { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-tag); cursor: pointer; font-size: 14px; line-height: 1.4; }
.combo-opt .ck { width: 16px; flex: none; color: var(--primary); font-weight: 600; }
.combo-opt .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.combo-opt .t b { font-weight: 600; background: var(--mark); border-radius: 2px; }
.combo-opt .c { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.combo-opt.act { background: var(--bg-hover); }
.combo-opt[aria-selected="true"] { color: var(--primary); font-weight: 500; }
.combo-note { font-size: 13px; color: var(--text-muted); padding: 2px 10px 4px; margin: 0; }
.combo-note:empty { display: none; }
@keyframes ui-pop { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- overlays (7.7): menu, popover, dialog, toast, scrim, bottom sheet */
.overlay, .menu { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.menu { position: absolute; z-index: 30; padding: 4px; min-width: 180px; animation: ui-pop .14s var(--ease); }
.menu [role="menuitem"] { all: unset; box-sizing: border-box; display: flex; gap: 8px; align-items: center; width: 100%; min-height: 36px; padding: 0 10px; border-radius: var(--r-tag); cursor: pointer; font-size: 14px; }
.menu [role="menuitem"]:hover, .menu [role="menuitem"]:focus-visible { background: var(--bg-hover); box-shadow: none; }
.menu [role="menuitem"]:focus-visible { box-shadow: inset 0 0 0 2px var(--ring); }
.menu .danger { color: var(--bad); }
.ui-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 49; }
.ui-scrim.top { z-index: 59; }
.bsheet { position: fixed; inset: auto 0 0 0; z-index: 50; background: var(--bg); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-sheet); max-height: 85vh; max-height: 85dvh; display: flex; flex-direction: column; animation: ui-sheet .18s var(--ease); }
.bsheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 16px 8px; font-weight: 600; font-size: 17px; }
.bsheet-body { overflow-y: auto; padding: 4px 16px 12px; display: grid; gap: 10px; }
.bsheet-foot { padding: 12px 16px 16px; border-top: 1px solid var(--border); }
@keyframes ui-sheet { from { transform: translateY(24px); opacity: .6; } }
dialog.dlg { border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); padding: 20px; width: min(440px, calc(100vw - 32px)); color: var(--text); background: var(--bg); }
dialog.dlg::backdrop { background: var(--scrim); }
dialog.dlg h2 { margin-bottom: 8px; }
dialog.dlg p { color: var(--text-muted); font-size: 14px; }
dialog.dlg .dlg-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.toasts { position: fixed; z-index: 70; left: 16px; bottom: 16px; display: grid; gap: 8px; justify-items: start; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { pointer-events: auto; display: inline-flex; gap: 12px; align-items: center; background: var(--text); color: var(--on-primary); border-radius: var(--r-control); padding: 10px 14px; font-size: 14px; box-shadow: var(--shadow-pop); animation: ui-pop .14s var(--ease); }
.toast.bad { background: var(--bad); }
.toast button { all: unset; cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.toast button:focus-visible { box-shadow: 0 0 0 3px var(--ring); border-radius: 4px; }

/* ---------- cards, tables, tabs (7.6) */
.card { border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px 20px; display: grid; gap: 12px; background: var(--bg); min-width: 0; }
.card > h2 { font-size: 17px; }
.tw { overflow-x: auto; }
table.t { border-collapse: collapse; width: 100%; font-size: 14px; }
table.t th { background: var(--bg-subtle); font-size: 13px; font-weight: 500; color: var(--text-muted); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; vertical-align: bottom; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tr:hover td { background: var(--bg-hover); }
table.t .r, table.t td.s { text-align: right; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs [role="tab"] { all: unset; box-sizing: border-box; cursor: pointer; padding: 0 10px; min-height: var(--h); font-size: 14px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.tabs [role="tab"]:focus-visible { box-shadow: inset 0 0 0 3px var(--ring); border-radius: var(--r-tag) var(--r-tag) 0 0; }
.count { display: inline-flex; align-items: center; min-height: 18px; font-size: 12px; font-weight: 500; background: var(--bg-hover); color: var(--text-muted); border-radius: 99px; padding: 0 7px; font-variant-numeric: tabular-nums; }
.count.new, [aria-selected="true"] > .count { background: var(--primary); color: var(--on-primary); }

/* ---------- screen states (7.8) */
.skel { display: grid; gap: 10px; }
.skel i { display: block; height: 14px; border-radius: var(--r-tag); background: linear-gradient(90deg, var(--bg-hover) 0, var(--bg-subtle) 50%, var(--bg-hover) 100%); background-size: 200% 100%; animation: ui-shine 1.2s infinite; }
.skel i.h { height: 18px; }
@keyframes ui-shine { to { background-position: -200% 0; } }
.state-empty { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 28px 16px; color: var(--text-muted); font-size: 14px; }
.alert { border-radius: var(--r-control); padding: 12px 14px; display: grid; gap: 8px; font-size: 14px; justify-items: start; overflow-wrap: anywhere; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--primary-soft); color: var(--primary); }

@media (max-width: 900px) {
  .btn.sm, .chip, .icon-btn, .switch.sm, .seg.sm button, .check { min-height: var(--h); }
  .icon-btn { width: 40px; height: 40px; }
  .input.sm { height: var(--h); }
  .combo-x { width: 40px; height: 40px; right: 26px; }
  .combo.on .combo-btn { padding-right: 72px; }
  .btn.sm { height: var(--h); }
  .tag { min-height: 24px; }
  .sug { min-height: var(--h); }
  .combo, .combo-btn { width: 100%; max-width: none; }
  .combo-pop { position: fixed; inset: auto 0 0 0; width: auto; top: auto; border-radius: var(--r-sheet) var(--r-sheet) 0 0; padding: 12px 16px 20px; max-height: 80vh; max-height: 80dvh; grid-template-rows: auto auto minmax(0, 1fr) auto; animation: ui-sheet .18s var(--ease); }
  .combo-pop.right { left: 0; right: 0; }
  .combo-pop .input { height: var(--h); font-size: 15px; }
  .combo-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 17px; }
  .combo-opts { max-height: none; }
  .combo-opt { min-height: 44px; }
  .menu [role="menuitem"] { min-height: var(--h); }
  .linkish { padding: 10px 2px; margin: -10px -2px; }
  .cites .cite, td .cite { min-height: var(--h); }
  .tabs [role="tab"] { min-height: 44px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; justify-items: stretch; }
}
