/* Data display, overlays and messages. Markup for each is in references/components.md. */

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font: 500 12.5px/16px var(--font-sans); color: var(--muted-fg); background: var(--surface);
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table tr.sel td { background: var(--accent); }
.table tr.dim td { color: var(--subtle-fg); }
.table tr.warn td { background: color-mix(in oklab, var(--warn) 6%, var(--bg)); }
.table tr.bad td { background: color-mix(in oklab, var(--bad) 5%, var(--bg)); }
.table td.changed { background: color-mix(in oklab, var(--warn) 12%, var(--bg)); }
.table td.invalid { background: color-mix(in oklab, var(--bad) 10%, var(--bg)); box-shadow: inset 0 0 0 1.5px var(--bad); }
.table.grid-lines td, .table.grid-lines th { border: 1px solid var(--border); }
.table.compact td { padding: 6px 10px; }

/* Lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item.unread { background: var(--accent); }
.list-item:hover { background: var(--surface); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; font-size: 13.5px; }
.kv > dt { color: var(--muted-fg); } .kv > dd { margin: 0; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline > div { position: relative; display: flex; gap: 12px; padding: 0 0 16px 0; }
.timeline > div::before { content: ""; position: absolute; left: 4px; top: 14px; bottom: 0; width: 1px; background: var(--border); }
.timeline > div:last-child::before { display: none; }
.timeline .dot { margin-top: 6px; width: 9px; height: 9px; }

/* People and media */
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0;
  background: var(--accent); color: var(--primary); font: 600 12.5px/1 var(--font-sans); }
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; } .avatar.lg { width: 44px; height: 44px; font-size: 15px; }
/* Image placeholder. Default 4:3. Set colours with style="--a:#hex;--b:#hex". Optional <span class="ph-l">label</span>. */
.ph { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; flex-shrink: 0;
  background: radial-gradient(120% 80% at 30% 20%, rgb(255 255 255 / .35), transparent 55%),
              linear-gradient(160deg, var(--a, #e6e4df), var(--b, #c9c6bf)); }
.ph::after { content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, rgb(255 255 255 / .07) 0 2px, transparent 2px 8px); }
.ph.sq { aspect-ratio: 1; } .ph.tall { aspect-ratio: 4 / 5; } .ph.wide { aspect-ratio: 16 / 7; } .ph.video { aspect-ratio: 16 / 9; }
.ph .ph-l { position: absolute; left: 8px; bottom: 8px; z-index: 1; font: 500 11px/16px var(--font-mono);
  color: rgb(255 255 255 / .95); text-shadow: 0 1px 2px rgb(0 0 0 / .3); }
.logo-ph { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--primary);
  color: var(--primary-fg); font: 700 13px/1 var(--font-display); flex-shrink: 0; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 999px; background: var(--a, #ccc);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12); vertical-align: -2px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.chart > i { flex: 1; border-radius: 4px 4px 0 0; background: var(--primary); opacity: .85; min-height: 2px; }
.chart > i.dim { background: var(--border-strong); }
.spark { display: block; width: 100%; height: 40px; }

/* Changes */
.diff-old { color: var(--subtle-fg); text-decoration: line-through; }
.diff-new { color: var(--fg); font-weight: 600; }
.added { background: color-mix(in oklab, var(--ok) 10%, var(--bg)); }
.removed { background: color-mix(in oklab, var(--bad) 8%, var(--bg)); }

/* Overlays. Put these after <!--overlay--> in a fragment; the build places them over the page. */
.scrim { position: absolute; inset: 0; z-index: 50; background: var(--scrim); }
.dialog { position: absolute; z-index: 51; top: 120px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100% - 32px));
  background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.dialog.wide { width: min(760px, calc(100% - 32px)); }
.dialog-head { padding: 20px 22px 6px; display: flex; flex-direction: column; gap: 6px; }
.dialog-body { padding: 10px 22px 18px; display: flex; flex-direction: column; gap: 12px; }
.dialog-foot { padding: 14px 22px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }
.drawer { position: absolute; z-index: 51; top: 0; right: 0; bottom: 0; width: min(480px, 100%); background: var(--bg);
  border-left: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.drawer-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.sheet { position: absolute; z-index: 51; left: 0; right: 0; bottom: 0; background: var(--bg); border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow); padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.sheet::before { content: ""; align-self: center; width: 40px; height: 4px; border-radius: 999px; background: var(--border-strong); }
.menu { position: absolute; z-index: 52; min-width: 200px; padding: 6px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.menu > a, .menu > span { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13.5px; }
.menu > .on, .menu > a:hover { background: var(--muted); }
.menu > .danger { color: var(--bad); }
.toast { position: absolute; z-index: 53; right: 24px; bottom: 24px; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius); background: var(--fg); color: var(--bg); box-shadow: var(--shadow); font-size: 13.5px; }
.toast .link { color: inherit; text-decoration: underline; }
.tip { position: absolute; z-index: 52; max-width: 260px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--fg);
  color: var(--bg); font-size: 12.5px; line-height: 17px; }

/* Messages: chat, email, notifications drawn as content (WhatsApp, SMS, email previews) */
.chat { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--surface); border-radius: var(--radius); }
.bubble { max-width: 82%; padding: 8px 10px; border-radius: 12px 12px 12px 4px; background: var(--bg); font-size: 13.5px;
  line-height: 19px; box-shadow: 0 1px 1px rgb(0 0 0 / .06); }
.bubble.me { align-self: flex-end; border-radius: 12px 12px 4px 12px; background: color-mix(in oklab, var(--ok) 16%, var(--bg)); }
.bubble .t { display: block; margin-top: 2px; text-align: right; font-size: 11px; color: var(--subtle-fg); }
.mail { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.mail-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.mail-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.code { font: 400 12.5px/19px var(--font-mono); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; white-space: pre-wrap; overflow-x: auto; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px;
  border-top: 1px solid var(--border); font-size: 13px; color: var(--muted-fg); }
