/* MASAR shared tokens and primitives */
:root {
  color-scheme: dark;
  --bg: #0C0D0F;
  --surface: #15171B;
  --surface-2: #1B1D22;
  --line: #2A2D33;
  --ink: #EDEEF0;
  --muted: #9BA1AA;
  --faint: #9299A3;
  --cobalt: #396CB5;
  --cobalt-bright: #5A86CF;
  --glow: rgba(90, 134, 207, .55);
  --ok: #3FB27F;
  --warn: #E0A23B;
  --danger: #E06B6B;
  --r-sm: 8px;
  --r: 12px;
  --font: 'MasarDigits', 'MasarAR', 'Segoe UI', Tahoma, sans-serif;
  --num: 'MasarLat', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 700; }
a { color: var(--cobalt-bright); }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--cobalt-bright); outline-offset: 2px; border-radius: 4px; }

/* forms */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cobalt-bright); box-shadow: 0 0 0 3px rgba(90,134,207,.2); }
input[type=date] { font-family: var(--num); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; flex: none; accent-color: var(--cobalt-bright); }
input.num, .num input { text-align: left; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: 15px; min-height: 42px; padding: 0 18px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn.primary:hover { background: #4275BA; border-color: #4275BA; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: 18px;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn:disabled { opacity: .25; cursor: not-allowed; border-color: transparent; color: var(--muted); }

/* toasts */
#toasts { position: fixed; inset-inline: 0; bottom: 20px; display: grid; justify-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-inline-start: 3px solid var(--ok); padding: 10px 16px; border-radius: var(--r-sm); max-width: min(92vw, 480px); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.err { border-inline-start-color: var(--danger); }

/* status chip: color comes from data-color → --c */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c, var(--muted)) 16%, transparent); color: color-mix(in srgb, var(--c, var(--muted)) 70%, white); white-space: nowrap; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(100%, 380px); }
.login .brand { font-size: 40px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 4px; }
.login p { margin: 0 0 28px; color: var(--muted); }
.login .btn { width: 100%; margin-top: 6px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 22px; margin: 4px 0 0; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* shared widgets: uploads, requests, conversation */
.att { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); display: block; }
.att .doc { display: inline-flex; align-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px; }
.uploader { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.uploader label.btn { cursor: pointer; }
.upchip { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; padding-inline-start: 10px; border: 1px solid var(--line); border-radius: 999px; max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.upchip .icon-btn { width: 28px; height: 28px; font-size: 13px; }
.newreq > summary { cursor: pointer; list-style: none; }
.newreq > summary::-webkit-details-marker { display: none; }
.newreq > summary h2 { display: inline; font-size: 18px; }
.newreq > summary::before { content: '+ '; color: var(--cobalt-bright); font-weight: 700; }
.newreq[open] > summary { margin-bottom: 14px; }
.reqs { display: grid; gap: 14px; }
.req { margin: 0; }
.req.attn { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.req header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.req .sub { color: var(--muted); font-size: 13px; }
.req-amt { font-size: 20px; font-weight: 600; margin-top: 8px; }
.req-amt .num { font-size: 22px; }
.req-body { margin: 8px 0 0; white-space: pre-wrap; }
.thread { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.thread li { padding: 8px 0; font-size: 15px; border-bottom: 1px dashed var(--line); }
.thread li.system, .thread li i { color: var(--muted); }
.thread time { color: var(--faint); font-size: 12px; margin-inline-start: 6px; }
.reply { display: flex; gap: 8px; margin-top: 10px; }
.reply input { min-height: 38px; }
textarea { resize: vertical; }
.convo { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 12px; }
.msg { max-width: 82%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--cobalt) 22%, var(--surface)); border-color: color-mix(in srgb, var(--cobalt) 40%, var(--line)); }
.msg.internal { border-style: dashed; background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .who time { color: var(--faint); margin-inline-start: 4px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.compose { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.compose select { max-width: 260px; }
.compose-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.compose-row .uploader { margin: 0; }
.def { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }

@font-face { font-family: MasarAR; src: url('/db-guide/fonts/MasarAR-400.otf') format('opentype'); font-weight: 400 500; font-display: swap; }
@font-face { font-family: MasarAR; src: url('/db-guide/fonts/MasarAR-700.otf') format('opentype'); font-weight: 600 900; font-display: swap; }
@font-face { font-family: MasarLat; src: url('/db-guide/fonts/MasarLat-600.ttf') format('truetype'); font-weight: 400 600; font-display: swap; }
@font-face { font-family: MasarLat; src: url('/db-guide/fonts/MasarLat-700.ttf') format('truetype'); font-weight: 700 900; font-display: swap; }
.masar-brand { display: inline-flex; align-items: center; max-width: 100%; text-decoration: none; }
.masar-brand img { display: block; width: 132px; height: auto; }
.login .masar-brand { margin-bottom: 16px; }
.login .masar-brand img { width: 190px; }
.btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; }

@font-face { font-family: MasarDigits; src: url('/db-guide/fonts/MasarLat-600.ttf') format('truetype'); font-weight: 100 900; unicode-range: U+0030-0039; font-display: swap; }
input[type=date], input[type=time], input[type=datetime-local] { font-family: var(--num); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
