/* DK components. Version 1.0 (2026-10-17). Needs dk-tokens.css first.
   Every class starts with dk- so it never clashes with Tailwind or an app's own CSS.
   Markup for each component is in STYLE-GUIDE.md and dk-preview.html. */

.dkc-body {
  margin: 0;
  font: var(--dkc-text)/1.45 var(--dkc-font);
  background: var(--dkc-canvas);
  color: var(--dkc-ink);
}
.dkc-body *, .dkc-body *::before, .dkc-body *::after { box-sizing: border-box; }
.dkc-h1 { font: 650 25px/1.2 var(--dkc-font-display); letter-spacing: -0.012em; margin: 0; }
.dkc-h2 { font: 650 15.5px/1.3 var(--dkc-font-display); letter-spacing: -0.012em; margin: 0; }
.dkc-muted { color: var(--dkc-muted); }
.dkc-focusable:focus-visible,
.dkc-body :focus-visible { outline: 2px solid var(--dkc-accent); outline-offset: 2px; }
.dkc-h1:focus, .dkc-h1:focus-visible { outline: none; }

/* ---------- Top bar: logo, nav, user. The rainbow line sits under it, always. ---------- */
.dkc-header {
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px; min-height: 58px;
  background: var(--dkc-surface);
}
.dkc-brand {
  display: flex; align-items: center; gap: 11px;
  color: var(--dkc-ink); text-decoration: none;
  font-weight: 650; font-size: 16px; letter-spacing: -0.01em;
}
.dkc-brand img, .dkc-brand svg { width: 34px; height: 34px; display: block; }
.dkc-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.dkc-nav a, .dkc-navlink {
  display: inline-flex; align-items: center; font-size: var(--dkc-text); line-height: 1.45;
  padding: 6px 12px; border-radius: var(--dkc-r);
  color: var(--dkc-muted); text-decoration: none; font-weight: 550;
}
.dkc-nav a:hover, .dkc-navlink:hover { background: var(--dkc-surface-2); color: var(--dkc-ink); }
/* Selected item: a background, never an underline. The underline fights the rainbow. */
.dkc-nav a.is-active, .dkc-nav a[aria-current="page"], .dkc-navlink.is-active,
.dkc-nav a.is-active:hover, .dkc-navlink.is-active:hover { background: var(--dkc-canvas); color: var(--dkc-ink); }
.dkc-user { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.dkc-who { text-align: right; line-height: 1.25; color: inherit; text-decoration: none; }
.dkc-who b { display: block; font-weight: 600; }
.dkc-who span { color: var(--dkc-muted); font-size: 12.5px; }
.dkc-rule { height: 3px; background: var(--dkc-spectrum); }
.dkc-main { max-width: 1480px; margin: 0 auto; padding: var(--dkc-s5); }

/* Environment badge: right of the top bar, next to the user. Same place in every app. */
.dkc-env {
  --env: var(--dkc-env-grey);
  display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px;
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
  color: #fff; background: var(--env); border: 0; border-radius: var(--dkc-r-sm);
}
.dkc-env.green { --env: var(--dkc-env-green); }
.dkc-env.blue { --env: var(--dkc-env-blue); }
.dkc-env.amber { --env: var(--dkc-env-amber); }
.dkc-env.red { --env: var(--dkc-env-red); }
.dkc-env.purple { --env: var(--dkc-env-purple); }
.dkc-env.readonly { background: #fff; color: #7a1f1f; border: 1px solid #7a1f1f; }

/* ---------- Page head ---------- */
.dkc-pagehead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.dkc-pagehead .dkc-sub { color: var(--dkc-muted); margin-top: 2px; }
.dkc-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons: sentence case, say what they do ---------- */
.dkc-btn {
  font: inherit; font-weight: 550;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 14px;
  border: 1px solid var(--dkc-line-strong); border-radius: var(--dkc-r);
  background: var(--dkc-surface); color: var(--dkc-ink);
  cursor: pointer; text-decoration: none;
}
.dkc-btn:hover:not(:disabled) { background: var(--dkc-surface-2); }
.dkc-btn.primary { background: var(--dkc-primary-bg); border-color: var(--dkc-primary-bg); color: var(--dkc-primary-ink); }
.dkc-btn.primary:hover:not(:disabled) { background: var(--dkc-primary-bg); filter: brightness(1.12); }
.dkc-btn.ghost { border-color: transparent; background: transparent; color: var(--dkc-muted); }
.dkc-btn.ghost:hover:not(:disabled) { background: var(--dkc-surface-2); color: var(--dkc-ink); }
.dkc-btn.danger { color: var(--dkc-err-text); }
.dkc-btn.sm { min-height: 28px; padding: 0 10px; font-size: 13px; }
.dkc-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Fields ---------- */
.dkc-label { display: block; font-size: 12.5px; font-weight: 550; color: var(--dkc-muted); margin: 0 0 4px; }
.dkc-input, .dkc-select, .dkc-textarea {
  font: inherit; min-height: 36px; padding: 0 10px;
  border: 1px solid var(--dkc-line-strong); border-radius: var(--dkc-r);
  background: var(--dkc-surface); color: var(--dkc-ink);
}
.dkc-textarea { width: 100%; min-height: 120px; padding: 8px 10px; }
.dkc-input.is-invalid, .dkc-select.is-invalid { border-color: var(--dkc-err); }
.dkc-help-error { margin-top: 4px; font-size: 12.5px; color: var(--dkc-err-text); font-weight: 550; }

/* ---------- Cards and panels ---------- */
.dkc-card {
  background: var(--dkc-surface); border: 1px solid var(--dkc-line);
  border-radius: var(--dkc-r-lg); overflow: hidden;
}
.dkc-card > .dkc-h2 { padding: 14px 20px; border-bottom: 1px solid var(--dkc-line); }
.dkc-card-body { padding: 16px 20px; }

/* ---------- Tables ---------- */
.dkc-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.dkc-table th, .dkc-table td {
  padding: 10px 14px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--dkc-line);
}
.dkc-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--dkc-surface-2); color: var(--dkc-muted);
  font-size: 12.5px; font-weight: 650; border-bottom: 1px solid var(--dkc-line-strong);
}
.dkc-table tbody tr:last-child td { border-bottom: 0; }
.dkc-table.clickable tbody tr { cursor: pointer; }
.dkc-table.clickable tbody tr:hover { background: var(--dkc-tint); }
.dkc-empty { padding: 36px 18px; text-align: center; color: var(--dkc-muted); }

/* ---------- Badges and tags ---------- */
.dkc-badge {
  --c: var(--dkc-muted);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 2px 11px 2px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  color: color-mix(in srgb, var(--c) 72%, var(--dkc-ink));
  background: color-mix(in srgb, var(--c) 14%, transparent);
}
.dkc-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.dkc-badge.ok { --c: var(--dkc-ok); }
.dkc-badge.warn { --c: var(--dkc-warn); }
.dkc-badge.err { --c: var(--dkc-err); }
.dkc-badge.info { --c: var(--dkc-accent); }
.dkc-tag {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  background: var(--dkc-surface-2); border: 1px solid var(--dkc-line);
  font-size: 12.5px; font-weight: 600;
}

/* ---------- Messages ---------- */
.dkc-msg {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 16px; border-radius: 10px; margin-bottom: 16px;
  border-left: 4px solid transparent;
}
.dkc-msg.ok { background: var(--dkc-ok-bg); color: var(--dkc-ok-text); border-left-color: var(--dkc-ok); }
.dkc-msg.warn { background: var(--dkc-warn-bg); color: var(--dkc-warn-text); border-left-color: var(--dkc-warn); }
.dkc-msg.err { background: var(--dkc-err-bg); color: var(--dkc-err-text); border-left-color: var(--dkc-err); }

/* ---------- Dialog ---------- */
.dkc-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(15, 17, 20, 0.55); padding: 16px; }
.dkc-dialog { width: min(600px, 100%); max-height: 86vh; display: flex; flex-direction: column; background: var(--dkc-surface); border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); }
.dkc-dialog > .dkc-h2 { padding: 18px 22px 6px; font-size: 18px; }
.dkc-dialog .dkc-dialog-body { padding: 4px 22px 14px; overflow: auto; }
.dkc-dialog .dkc-dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--dkc-line); }

/* ---------- Admin: sidebar on the left, content on the right ---------- */
.dkc-shell { display: flex; gap: var(--dkc-s5); align-items: flex-start; }
.dkc-sidebar {
  width: 224px; flex: none; position: sticky; top: var(--dkc-s4);
  background: var(--dkc-surface); border: 1px solid var(--dkc-line);
  border-radius: var(--dkc-r-lg); padding: 12px;
}
.dkc-side-top, .dkc-side-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: var(--dkc-r-sm);
  color: var(--dkc-ink); text-decoration: none; font-weight: 650; font-size: 14px;
}
.dkc-side-top:hover { background: var(--dkc-surface-2); }
.dkc-side-top.is-active { background: var(--dkc-tint); color: var(--dkc-accent); }
.dkc-side-group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--dkc-line); }
.dkc-side-head {
  padding: 4px 8px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--dkc-ink);
}
.dkc-side-head svg, .dkc-side-top svg { width: 18px; height: 18px; flex: none; color: var(--dkc-muted); fill: none; stroke: currentColor; stroke-width: 1.5; }
.dkc-side-top.is-active svg { color: var(--dkc-accent); }
.dkc-side-items { list-style: none; margin: 4px 0 0 16px; padding: 0 0 0 12px; border-left: 1px solid var(--dkc-line); }
.dkc-side-items a {
  display: block; margin-left: -13px; padding: 6px 8px 6px 11px;
  border-left: 2px solid transparent; border-radius: 0 var(--dkc-r-sm) var(--dkc-r-sm) 0;
  color: var(--dkc-muted); text-decoration: none; font-size: 14px;
}
.dkc-side-items a:hover { color: var(--dkc-ink); background: var(--dkc-surface-2); border-left-color: var(--dkc-line-strong); }
.dkc-side-items a.is-active, .dkc-side-items a[aria-current="page"] {
  border-left-color: var(--dkc-accent); background: var(--dkc-tint); color: var(--dkc-accent); font-weight: 600;
}
.dkc-shell-content { flex: 1; min-width: 0; }
.dkc-group { margin: 0 0 var(--dkc-s5); }
.dkc-group > h3 {
  margin: 0 0 var(--dkc-s3); font-size: 12px; font-weight: 650;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--dkc-muted);
}
.dkc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--dkc-s4); }
.dkc-tile {
  display: block; padding: 18px 20px; background: var(--dkc-surface);
  border: 1px solid var(--dkc-line); border-radius: var(--dkc-r-lg);
  color: var(--dkc-ink); text-decoration: none; box-shadow: var(--dkc-shadow);
}
.dkc-tile:hover { border-color: var(--dkc-accent); }
.dkc-tile b { display: block; font-size: 15.5px; margin-bottom: 4px; }
.dkc-tile span { color: var(--dkc-muted); font-size: 13.5px; line-height: 1.4; }

/* ---------- Small screens: sidebar folds above the content ---------- */
@media (max-width: 860px) {
  .dkc-shell { flex-direction: column; }
  .dkc-sidebar { width: 100%; position: static; }
  .dkc-header { gap: 12px; padding: 8px 14px; flex-wrap: wrap; }
  .dkc-main { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { .dkc-body * { transition: none !important; animation: none !important; } }

/* Row of nav links inside an app that has its own container classes (for example Tailwind). */
.dkc-navgap { gap: 4px; align-items: center; }
