/* Styles for the brand portal (/) and shared report links (/r/…) */
:root {
  --ink: #282828;
  --ink-2: #454545;
  --muted: #6b6f7b;
  --line: #e4e7ef;
  --field: #d5dae6;
  --bg: #ffffff;
  --bg-soft: #f5f7fd;
  --blue: #1a4bff;
  --blue-dark: #0f37d4;
  --blue-tint: #edf2ff;
  --blue-line: #c9d6ff;
  --track: #eef1f8;
  --pink: #ff1159;
  --danger: #d4142a;
  --brand-line: linear-gradient(90deg, #ff1159 0%, #9b3cf0 50%, #1a4bff 100%);
  --bar-h: 60px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 "Kanit", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: "Inter", "Kanit", sans-serif; font-variant-numeric: tabular-nums; }

.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; flex: none; }
.brand img { display: block; }

.btn {
  appearance: none; cursor: pointer; white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 15px; font-weight: 400;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--field); background: var(--bg-soft); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- top bar ---------- */
.bar {
  position: relative; flex: none; height: var(--bar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 max(20px, env(safe-area-inset-left));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.bar::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--brand-line); }
.bar .sep { flex: none; width: 1px; height: 22px; background: var(--line); }
.bar .label { min-width: 0; color: var(--ink-2); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .label small { color: var(--muted); font-size: 13px; margin-left: 8px; }
.bar .spacer { flex: 1; }
.bar .btn { flex: none; }

.client-logo { flex: none; display: block; height: 26px; width: auto; max-width: 110px; object-fit: contain; }

/* ---------- team note above a dashboard ---------- */
.note {
  flex: none; position: relative; z-index: 2;
  padding: 10px max(20px, env(safe-area-inset-left)) 12px;
  background: var(--blue-tint); border-bottom: 1px solid var(--blue-line);
}
.note-head { display: flex; align-items: center; gap: 10px; }
.note-label { font-size: 13px; font-weight: 500; color: var(--blue); }
.note-btn { appearance: none; border: 0; background: none; margin-left: auto; padding: 2px 6px; border-radius: 6px; cursor: pointer; color: var(--blue); font-size: 13px; }
.note-btn:hover { background: rgba(26, 75, 255, .08); }
.note-text { margin: 4px 0 0; max-width: 980px; max-height: 28vh; overflow: auto; white-space: pre-line; color: var(--ink); font-size: 15px; line-height: 1.6; }
.note.folded { padding-bottom: 10px; }
.note.folded .note-text { display: none; }

/* ---------- report viewer ---------- */
.viewer { flex: 1; position: relative; background: var(--bg); }
.viewer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }
.loading {
  position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center; align-content: center; gap: 14px;
  color: var(--muted); background: var(--bg-soft); font-size: 15px;
}
.loading .track { width: 180px; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.loading .track span { display: block; width: 40%; height: 100%; background: var(--brand-line); border-radius: 3px; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.viewer-error { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; padding: 24px; color: var(--muted); }
.viewer-error strong { color: var(--ink); font: 500 20px/1.4 "Kanit", sans-serif; }

/* ---------- small pieces ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
dialog.dlg { border: 0; padding: 0; border-radius: 16px; width: min(460px, calc(100% - 32px)); box-shadow: 0 24px 60px rgba(16, 24, 64, .2); color: var(--ink); }
dialog.dlg::backdrop { background: rgba(20, 24, 40, .35); }
.dlg-body { padding: 22px; display: grid; gap: 12px; }
.dlg-body h3 { margin: 0; font: 500 18px/1.4 "Kanit", sans-serif; }
.dlg-body p { margin: 0; color: var(--ink-2); font-size: 15px; }
.dlg-body input { width: 100%; height: 44px; padding: 0 12px; border: 1.5px solid var(--field); border-radius: 10px; font: 400 14px/1 "Inter", sans-serif; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 640px) {
  :root { --bar-h: 56px; }
  .note { padding: 8px 12px 10px; }
  .note-text { font-size: 14px; max-height: 22vh; }
  .client-logo { height: 22px; max-width: 80px; }
  .bar { gap: 8px; padding: 0 12px; }
  .bar .wordmark, .bar .sep, .bar .hide-sm { display: none; }
  .bar .btn { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .loading .track span { animation: none; width: 100%; }
  * { transition: none !important; }
}
