/* Shoji design tokens and element overrides.
 *
 * Loaded AFTER DaisyUI in renderHead() so these variable redefinitions win.
 * DaisyUI v4.12+ stores theme tokens in OKLCH (`<l>% <c> <h>`) and wraps
 * references in `oklch(var(--x))`, so every value here is OKLCH too.
 *
 * Aim: flat surfaces, hairline borders instead of shadows, a warm coral
 * accent, and a vertical sidebar shell on app pages.
 */

/* --- Typography ----------------------------------------------------- */
/* The webfont import + --shoji-font stack now live in shoji-brand.css,
   loaded before this file in renderHead(). Keep these here referencing
   the token so the brand file stays the single source of truth. */

html,
body {
  font-family: var(--shoji-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Force Tailwind's font-mono utility (used liberally for domains, IPs,
   version strings, mailbox addresses, etc.) onto Zalando Sans. The
   Play CDN injects font-mono's default ui-monospace stack into the
   page dynamically, so a normal-cascade rule loses; !important is the
   only reliable hammer here. Log surfaces below re-assert monospace
   with !important + a more specific selector so they win against this
   rule on .shoji-log-table td.font-mono cells (which exist in the
   wild). The pattern is intentional — keep both !important together
   when editing either side. */
.font-mono {
  font-family: var(--shoji-font) !important;
}

/* --- Theme tokens (OKLCH) ------------------------------------------- */

:root[data-theme="light"],
[data-theme="light"] {
  color-scheme: light;

  --p: 71% 0.165 25;
  /* coral primary */
  --pc: 100% 0 0;
  --pf: 64% 0.20 25;

  --s: 40% 0.012 258;
  --sc: 100% 0 0;
  --sf: 32% 0.012 258;

  --a: 68% 0.10 195;
  /* muted teal accent */
  --ac: 100% 0 0;
  --af: 62% 0.10 195;

  --n: 22% 0.005 264;
  --nc: 98% 0 0;
  --nf: 16% 0.005 264;

  --b1: 100% 0 0;
  --b2: 98% 0.002 264;
  --b3: 95% 0.003 264;
  --bc: 20% 0.005 264;

  --in: 65% 0.15 245;
  --inc: 100% 0 0;
  --su: 62% 0.14 145;
  --suc: 100% 0 0;
  --wa: 79% 0.15 80;
  --wac: 25% 0.04 85;
  --er: 63% 0.21 25;
  --erc: 100% 0 0;

  --rounded-box: 1rem;
  --rounded-btn: 0.625rem;
  --rounded-badge: 9999px;
  --animation-btn: 0;
  --animation-input: 0;
  --btn-focus-scale: 1;
  --border-btn: 1px;
  --tab-radius: 0.5rem;
}

:root[data-theme="dark"],
[data-theme="dark"] {
  color-scheme: dark;

  --p: 74% 0.165 25;
  --pc: 100% 0 0;
  --pf: 68% 0.20 25;

  --s: 78% 0.01 258;
  --sc: 18% 0.005 264;
  --sf: 70% 0.01 258;

  --a: 75% 0.085 195;
  --ac: 18% 0.005 264;
  --af: 68% 0.085 195;

  --n: 25% 0.005 264;
  --nc: 98% 0 0;
  --nf: 20% 0.005 264;

  --b1: 17% 0.004 264;
  --b2: 21% 0.004 264;
  --b3: 27% 0.004 264;
  --bc: 94% 0.003 264;

  --in: 72% 0.14 245;
  --inc: 100% 0 0;
  --su: 72% 0.13 145;
  --suc: 100% 0 0;
  --wa: 82% 0.14 80;
  --wac: 25% 0.04 85;
  --er: 72% 0.18 25;
  --erc: 100% 0 0;

  --rounded-box: 1rem;
  --rounded-btn: 0.625rem;
  --rounded-badge: 9999px;
  --animation-btn: 0;
  --animation-input: 0;
  --btn-focus-scale: 1;
  --border-btn: 1px;
  --tab-radius: 0.5rem;
}

body {
  background: oklch(var(--b2));
  color: oklch(var(--bc));
}

/* --- Flat: kill every Tailwind shadow utility. --------------------- */

.shadow,
.shadow-sm,
.shadow-md,
.shadow-lg,
.shadow-xl,
.shadow-2xl,
.shadow-inner,
.drop-shadow,
.drop-shadow-sm,
.drop-shadow-md,
.drop-shadow-lg,
.drop-shadow-xl {
  box-shadow: none !important;
  filter: none !important;
}

/* --- Replace the missing shadow with hairline borders. ------------- */

.card,
.modal-box,
.alert {
  border: 1px solid oklch(var(--bc) / 0.08);
  background: oklch(var(--b1));
}

/* The rule above strips DaisyUI's semantic alert background, which left
   the (light-on-color) content text invisible on the b1 base — unreadable
   in light mode. Restore readable success/error styling that works in
   both themes: a low-alpha tint over the page plus base-content text. */
.alert-success {
  background: oklch(var(--su) / 0.12);
  border-color: oklch(var(--su) / 0.4);
  color: oklch(var(--bc));
}

.alert-error {
  background: oklch(var(--er) / 0.12);
  border-color: oklch(var(--er) / 0.4);
  color: oklch(var(--bc));
}

/* Flash toast: lay it out as flex so the dismiss button sits flush right
   and the message takes the remaining width. */
.shoji-flash {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.shoji-flash>span {
  flex: 1 1 auto;
}

.shoji-flash-close {
  flex-shrink: 0;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: oklch(var(--bc) / 0.55);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.shoji-flash-close:hover {
  background: oklch(var(--bc) / 0.1);
  color: oklch(var(--bc));
}

/* shojiChoices may stack 4+ buttons in the action row; let them wrap
   to a second line instead of overflowing the modal-box. */
.modal-action {
  flex-wrap: wrap;
}

/* --- Sidebar shell -------------------------------------------------- */

.shoji-shell {
  min-height: 100vh;
  display: flex;
}

.shoji-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.shoji-sidebar {
  width: 15rem;
  flex-shrink: 0;
  background: oklch(var(--b1));
  border-right: 1px solid oklch(var(--bc) / 0.08);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.shoji-brand {
  padding: 1.75rem 1.5rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.shoji-brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: oklch(var(--p));
  color: oklch(var(--pc));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.shoji-brand-text {
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.shoji-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.shoji-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5625rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: oklch(var(--bc) / 0.6);
  transition: background 0.15s ease, color 0.15s ease;
}

.shoji-nav a:hover {
  color: oklch(var(--bc));
  background: oklch(var(--bc) / 0.04);
}

.shoji-nav a.is-active,
.shoji-nav a.is-active:hover {
  color: oklch(var(--bc));
  background: oklch(var(--bc) / 0.08);
}

.shoji-nav a svg {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
}

/* Small coloured dot rendered next to a nav label when something in
   that section needs attention. Toggled via `has-update` (yellow —
   upstream update available) or `has-down` (red — a managed/tenant
   container isn't running). Both are driven by the background
   /services-updates fetch so classes can be added/removed without
   touching the DOM. When both apply, has-down wins via source order
   (below): a down service is more urgent than an available update. */
.shoji-nav a.has-update::after,
.shoji-nav a.has-down::after {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: -0.25rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

.shoji-nav a.has-update::after {
  background: oklch(var(--wa));
  box-shadow: 0 0 0 2px oklch(var(--wa) / 0.25);
}

.shoji-nav a.has-down::after {
  background: oklch(var(--er));
  box-shadow: 0 0 0 2px oklch(var(--er) / 0.25);
}

/* Inline copy-on-click chip used inside dl rows (Server details on
   /settings, Site details on /sitemanage). Reads as plain text until
   hovered; click copies and briefly turns success-green. */
.shoji-sys-info-copy {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shoji-sys-info-copy:hover {
  color: oklch(var(--bc) / 0.75);
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.shoji-sys-info-copy.is-copied {
  color: oklch(var(--su));
}

/* Copy-to-confirm chip: icon + literal word, used in destructive
   confirmation dialogs. Clicking copies the word and briefly swaps
   the copy icon for a check (see shoji.js [data-copy] handler). */
.shoji-copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  vertical-align: baseline;
  margin: 0 0.1rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid oklch(var(--bc) / 0.2);
  border-radius: 0.375rem;
  background: oklch(var(--bc) / 0.06);
  color: inherit;
  font-family: var(--shoji-font);
  font-size: 0.875em;
  line-height: 1.5;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.shoji-copy-chip:hover {
  background: oklch(var(--bc) / 0.12);
  border-color: oklch(var(--bc) / 0.35);
}

.shoji-copy-chip:focus-visible {
  outline: 2px solid oklch(var(--p));
  outline-offset: 2px;
}

.shoji-copy-chip-ico {
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
  opacity: 0.65;
}

.shoji-copy-chip-ico-done {
  display: none;
  color: oklch(var(--su));
  opacity: 1;
}

.shoji-copy-chip.is-copied .shoji-copy-chip-ico-copy {
  display: none;
}

.shoji-copy-chip.is-copied .shoji-copy-chip-ico-done {
  display: inline;
}

.shoji-copy-chip-word {
  white-space: nowrap;
}

.shoji-sidebar-foot {
  padding: 0.75rem 0.75rem 1rem;
  border-top: 1px solid oklch(var(--bc) / 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* --- Shared list-surface chrome (was duplicated in filemanager.css) -- */

/* Sortable column header. The clickable host carries data-sort-key
   (typically a <th>); the label and its triangle indicator live
   together inside a `.shoji-sort-label` span. Bundling them in the
   span gives "label + chevron" one inline-flex bound, so on a
   right-aligned column the chevron sits inside the cell padding
   rather than overflowing past the cell edge.
   The triangle uses CSS-border tricks — no SVG. Idle is a muted
   down-arrow; .is-sort-asc on the host flips it up; .is-sort-desc
   keeps it pointing down at full opacity. */
[data-sort-key] {
  cursor: pointer;
  user-select: none;
}
.shoji-sort-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.shoji-sort-label::after {
  content: '';
  display: inline-block;
  border: 4px solid transparent;
  border-top-color: currentColor;
  opacity: 0.25;
  transform: translateY(2px);
}
.is-sort-asc .shoji-sort-label::after {
  border-top-color: transparent;
  border-bottom-color: currentColor;
  opacity: 1;
  transform: translateY(-2px);
}
.is-sort-desc .shoji-sort-label::after {
  border-top-color: currentColor;
  opacity: 1;
}
/* Subtle background hover only when the sortable lives inside a real
   table header — for free-floating sort links the colour change
   comes from the link rules, not this. */
thead th[data-sort-key]:hover {
  background: oklch(var(--b2));
}

/* Selection bar — shown when one or more rows are checked. Pink-tinted
   strip with a "N selected" count on the left, action buttons in the
   middle, and a "Clear" / "Cancel" link pushed to the right via
   .spacer. Visibility is toggled by JS via the [hidden] attribute. */
.shoji-selbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  background: oklch(var(--p) / 0.08);
  border-bottom: 1px solid oklch(var(--b3));
  font-size: 0.875rem;
  flex: 0 0 auto;
}
.shoji-selbar[hidden] {
  display: none;
}
.shoji-selbar .count {
  flex: 0 0 auto;
  font-weight: 600;
  margin-right: 0.25rem;
}
.shoji-selbar .spacer {
  flex: 1 1 auto;
}

/* Toolbar action group — flex row of icon buttons + optional primary
   CTA at the end. Used by the file manager's top-bar cluster and the
   webmail bar (Mark all read / Empty / Compose). Distinct from the
   pre-existing `.shoji-actions` class used by table row-action
   columns (Edit / Delete buttons) — the two were colliding when
   they shared a name. */
.shoji-toolbar-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex: 0 0 auto;
}

/* Square icon toolbar button — file-manager-style row of tools.
   Going through DaisyUI's `.btn .btn-square` silently shrinks the
   inner SVG, so we own the cascade. Sized to DaisyUI's default
   `.btn` height (3rem) so an icon button can sit next to a primary
   button (Upload / Compose) without a height mismatch. */
.shoji-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid oklch(var(--b3));
  border-radius: var(--rounded-btn, 0.5rem);
  background: oklch(var(--b2));
  color: oklch(var(--bc));
  cursor: pointer;
  flex-shrink: 0;
}
.shoji-tool-btn:hover {
  background: oklch(var(--b3));
}
.shoji-tool-btn:focus-visible {
  outline: 2px solid oklch(var(--p));
  outline-offset: 2px;
}
.shoji-tool-btn svg {
  width: 1em;
  height: 1em;
}
.shoji-tool-btn.is-on {
  color: oklch(var(--p));
}

/* Search input wrapper used in toolbars across the panel (file
   manager, webmail, etc). Sizes the embedded input and positions an
   optional magnifying-glass button on the right edge inside the
   input — clickable, dispatches the form's submit (or a click event
   for non-form callers). Standard webpage pattern; the affordance
   is in the input itself rather than a separate Go button. */
.shoji-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.shoji-search input[type="search"] {
  width: 16rem;
  padding-right: 2.25rem;
}
.shoji-search-go {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  padding: 0.25rem;
  margin: 0;
  cursor: pointer;
  color: oklch(var(--bc) / 0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
}
/* No hover effect — the icon is decoration that happens to be
   clickable, not a button-shaped target. The cursor:pointer is
   enough affordance; a bg/colour change reads as a separate widget. */
.shoji-search-go svg {
  width: 1rem;
  height: 1rem;
}


/* --- Page footer ---------------------------------------------------- */

/* Wrapper for layout-bare pages (login / change-password) so the footer
   can sit at the bottom of the viewport below the centred card. */
.shoji-bare {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* The "Powered by Shoji" line. Pushed to the bottom of the flex-column
   main pane by margin-top:auto, right-aligned, no bar/border — it sits
   over the page background as plain muted text. */
.shoji-footer {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1.5rem 1rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: oklch(var(--bc) / 0.55);
}

.shoji-user-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: oklch(var(--bc) / 0.5);
}

.shoji-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Profile popover. Floats above the circle-button trigger in the sidebar
   footer; margin-bottom sets the gap between trigger and menu. The header
   and action list are visually separated by a thin divider so the
   non-clickable "Signed in as" line reads as context, not a menu item. */
.shoji-user-menu {
  margin-bottom: 0.375rem;
  min-width: 12rem;
  background: oklch(var(--b1));
  border: 1px solid oklch(var(--bc) / 0.1);
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px -10px oklch(0% 0 0 / 0.35);
  overflow: hidden;
  z-index: 20;
}

.shoji-user-menu-header {
  padding: 0.625rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  border-bottom: 1px solid oklch(var(--bc) / 0.08);
}

.shoji-user-menu-items {
  list-style: none;
  margin: 0;
  padding: 0.25rem;
}

.shoji-user-menu-items li>a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 0.375rem;
  color: oklch(var(--bc) / 0.75);
}

.shoji-user-menu-items li>a:hover,
.shoji-user-menu-items li>a:focus-visible {
  background: oklch(var(--bc) / 0.06);
  color: oklch(var(--bc));
}

/* The services tables are table-fixed (percentage colgroup), so they
   never overflow horizontally — we keep the wrapper overflow visible so
   a row's ⋯ menu can escape past the table's bottom edge instead of
   being clipped by a scroll container. */
.shoji-svc-table-wrap {
  overflow: visible;
}

/* Per-row actions menu on /services. The ⋯ trigger keeps the Actions
   column a fixed width regardless of how many actions a row offers; the
   menu itself reuses the profile-popover look. */
.shoji-row-menu-trigger {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.shoji-row-menu-items {
  min-width: 11rem;
  background: oklch(var(--b1));
  border: 1px solid oklch(var(--bc) / 0.1);
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px -10px oklch(0% 0 0 / 0.35);
  padding: 0.25rem;
  margin-top: 0.25rem;
  list-style: none;
  z-index: 20;
}
/* Each menu row is a submit button (or the Update trigger) styled to
   look like a flat list item. Reset the native button chrome first. */
.shoji-row-menu-items li>form>button,
.shoji-row-menu-items li>button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0.375rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: oklch(var(--bc) / 0.78);
  cursor: pointer;
}
.shoji-row-menu-items li>form>button:hover:not(:disabled),
.shoji-row-menu-items li>button:hover {
  background: oklch(var(--bc) / 0.06);
  color: oklch(var(--bc));
}
.shoji-row-menu-items li>form>button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.shoji-row-menu-items .shoji-row-menu-update {
  color: oklch(var(--p));
}
.shoji-row-menu-items .shoji-row-menu-danger {
  color: oklch(var(--er));
}
.shoji-row-menu-sep {
  height: 1px;
  margin: 0.25rem 0;
  background: oklch(var(--bc) / 0.08);
}

/* --- Tables: lighter separators, softer headers. ------------------- */

.table :where(thead) {
  background: transparent;
}

.table :where(thead tr, tbody tr) {
  border-bottom-color: oklch(var(--bc) / 0.06);
}

.table :where(th) {
  font-weight: 600;
  text-transform: none;
  font-size: 0.8125rem;
  letter-spacing: 0;
  color: oklch(var(--bc) / 0.6);
}

.table :where(th, td) {
  padding-block: 1rem;
}

/* --- Inputs: thin border, coral focus halo. ----------------------- */

.input,
.select,
.textarea {
  border-color: oklch(var(--bc) / 0.15);
  background: oklch(var(--b1));
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: oklch(var(--bc) / 0.25);
}

.input:focus,
.input:focus-visible,
.select:focus,
.select:focus-visible,
.textarea:focus,
.textarea:focus-visible {
  outline: none;
  border-color: oklch(var(--p));
  box-shadow: 0 0 0 3px oklch(var(--p) / 0.18);
}

/* --- Buttons: a touch more padding, flatter. ---------------------- */

.btn {
  padding-inline: 1.25rem;
  font-weight: 600;
}

/* `.shoji-actions` stays as a layout hook on row-action cells (used
   for spacing / wrapping rules) but no longer changes button size.
   Row actions render at the panel-wide default 3rem `.btn` height,
   so the panel has one button size everywhere. */

/* --- Toggle: green when on, muted track when off. ----------------- */

.toggle {
  --tglbg: oklch(var(--bc) / 0.15);
}

.toggle:checked {
  --tglbg: oklch(var(--su));
}

/* --- Modal backdrop: softer than DaisyUI's default. --------------- */

.modal-backdrop {
  background: oklch(0% 0 0 / 0.55);
  backdrop-filter: blur(2px);
}

/* --- Code: inline-kbd look. --------------------------------------- */

code {
  background: oklch(var(--bc) / 0.06);
  padding: 0.1em 0.35em;
  border-radius: 0.375rem;
  font-size: 0.9em;
}

/* --- Links: subtle. ----------------------------------------------- */

.link-hover {
  text-underline-offset: 3px;
}

/* --- Site sidebar: back link + domain header. --------------------- */

.shoji-back {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.25rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: oklch(var(--bc) / 0.55);
  transition: color 0.15s ease;
}

.shoji-back:hover {
  color: oklch(var(--bc));
}

.shoji-back svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.shoji-site-brand {
  padding: 0.375rem 1.5rem 1.25rem;
}

/* When there's more than one site, .shoji-site-brand is a DaisyUI
   .dropdown wrapper. Override .dropdown's inline-block so we still fill
   the sidebar column, and zero out its padding — the padding lives on
   the inner trigger so the whole rectangle is clickable. */
.shoji-site-brand.dropdown {
  display: block;
  padding: 0;
}

.shoji-site-brand-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: oklch(var(--bc) / 0.45);
  margin-bottom: 0.125rem;
}

.shoji-site-brand-domain {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shoji-site-brand-trigger {
  display: block;
  padding: 0.375rem 1.5rem 1.25rem;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s ease;
}

.shoji-site-brand-trigger:hover,
.shoji-site-brand-trigger:focus-visible {
  background: oklch(var(--bc) / 0.04);
  outline: none;
}

.shoji-site-brand-trigger:hover .shoji-site-brand-caret,
.shoji-site-brand-trigger:focus-visible .shoji-site-brand-caret {
  opacity: 0.9;
}

.shoji-site-brand-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
}

.shoji-site-brand-row .shoji-site-brand-domain {
  flex: 1 1 auto;
}

.shoji-site-brand-caret {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  opacity: 0.4;
  color: oklch(var(--bc) / 0.6);
  transition: opacity 0.15s ease;
}

/* Dropdown menu: floats over the nav below, extends slightly past the
   sidebar so longer domains fit without wrapping. max-height + scroll
   keeps it usable once the operator accumulates a lot of sites. */
.shoji-site-brand-menu {
  margin-top: 0.25rem;
  padding: 0.25rem;
  min-width: 14rem;
  max-height: 60vh;
  overflow-y: auto;
  background: oklch(var(--b1));
  border: 1px solid oklch(var(--bc) / 0.1);
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px -10px oklch(0% 0 0 / 0.35);
  z-index: 20;
}

.shoji-site-brand-menu li>a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  border-radius: 0.375rem;
  color: oklch(var(--bc) / 0.75);
}

.shoji-site-brand-menu li>a:hover,
.shoji-site-brand-menu li>a:focus-visible {
  background: oklch(var(--bc) / 0.06);
  color: oklch(var(--bc));
}

.shoji-site-brand-menu li>a.is-current {
  color: oklch(var(--bc));
  background: oklch(var(--bc) / 0.06);
  font-weight: 600;
}

.shoji-site-brand-menu-domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.shoji-site-brand-menu-check {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  opacity: 0.7;
}

/* --- Caddyfile editor textarea. ----------------------------------- */

.shoji-caddy-editor {
  display: block;
  width: 100%;
  min-height: 20rem;
  font-family: var(--shoji-font);
  font-size: 0.8125rem;
  line-height: 1.6;
  padding: 0.75rem 1rem;
  border-radius: var(--rounded-btn, 0.625rem);
  border: 1px solid oklch(var(--bc) / 0.15);
  background: oklch(var(--b2));
  color: oklch(var(--bc));
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.shoji-caddy-editor:hover {
  border-color: oklch(var(--bc) / 0.25);
}

.shoji-caddy-editor:focus {
  outline: none;
  border-color: oklch(var(--p));
  box-shadow: 0 0 0 3px oklch(var(--p) / 0.18);
}

/* Structured site-config editor — one box per section card, so it sits
   shorter than the whole-file raw editor. */
.shoji-uc-editor {
  min-height: 7rem;
}

/* --- Folder picker -------------------------------------------------
   Modal directory tree shared by the file manager (Copy to / Move to)
   and the Security page's Password protection path picker. Driven by
   folderpicker.js + the "folder-picker" template partial. */
.shoji-fm-picker-tree {
  max-height: 22rem;
  overflow: auto;
  border: 1px solid oklch(var(--b3));
  background: oklch(var(--b1));
  border-radius: 0.4rem;
  padding: 0.25rem 0;
}

.shoji-fm-picker-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shoji-fm-picker-tree .pf-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
}

.shoji-fm-picker-tree .pf-row:hover {
  background: oklch(var(--bc) / 0.06);
}

.shoji-fm-picker-tree .pf-row.is-selected {
  background: oklch(var(--p) / 0.18);
  font-weight: 600;
}

.shoji-fm-picker-tree .pf-twist {
  font-size: 0.7rem;
  opacity: 0.6;
  width: 0.75rem;
  display: inline-block;
  text-align: center;
}

.shoji-fm-picker-tree .pf-name {
  font-family: var(--shoji-font);
}

.shoji-fm-picker-tree .pf-error {
  padding: 0.4rem 0.75rem;
  color: oklch(var(--er));
  font-size: 0.8rem;
}

/* File leaves in the file-picker: dimmer twist glyph, regular pointer. */
.shoji-fm-picker-tree .pf-row.pf-file .pf-twist {
  opacity: 0.35;
}

/* --- Path-scope chip editor (path-scope partial + pathscope.js) ---- */

.shoji-pathscope .ps-x {
  color: oklch(var(--bc) / 0.6);
  font-size: 0.85em;
  line-height: 1;
  cursor: pointer;
}
.shoji-pathscope .ps-x:hover,
.shoji-pathscope .ps-x:focus-visible {
  color: oklch(var(--er));
}

/* --- Logs viewer --------------------------------------------------- */

/* The toolbar can't ride DaisyUI's .card-body because that already sets
   flex-direction: column — adding `flex flex-wrap items-end` to it
   keeps the column direction and the items-end silently becomes a
   right-align. Use our own horizontal flex row instead. */
.shoji-log-toolbar {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.shoji-log-toolbar-break {
  flex-basis: 100%;
  height: 0;
}

.shoji-log-toolbar-filter {
  flex: 1 1 12rem;
  min-width: 12rem;
}

/* Push the timezone picker to the far right of its flex row. On the
   aggregate /logs toolbar it sits next to Target; on the per-site
   toolbar it's alone on its row thanks to a following break. */
.shoji-log-toolbar-tz {
  margin-left: auto;
}

.shoji-log-count {
  padding: 0.75rem 1.25rem;
  font-size: 0.8125rem;
  color: oklch(var(--bc) / 0.6);
  border-top: 1px solid oklch(var(--bc) / 0.08);
}

.shoji-log-table {
  width: 100%;
}

.shoji-log-table td {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, 'Cascadia Code',
    'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace !important;
  font-size: 0.8125rem;
  padding-block: 0.5rem;
  white-space: nowrap;
}

/* Long free-text cells (URI, Message) flex-shrink to whatever space the
   fixed-width columns leave behind, then ellipsis-truncate — so a long
   URL can't push Duration or Size off the card's right edge. The
   `max-width: 0 + width: 100%` pair is the canonical HTML-table trick
   for "take remaining space, nothing more". */
.shoji-log-table td[data-kind="uri"],
.shoji-log-table td[data-kind="msg"] {
  max-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* WAF rule lists can grow long when a request trips many CRS rules
   (XSS payloads commonly hit 4-5 rules + the anomaly evaluator).
   Wrap on the comma+space between IDs so each rule number stays
   together — without overflow-wrap:normal, the URI column's width:100%
   would squeeze this cell narrow enough to break inside individual
   rule IDs. min-width keeps room for ~3 IDs on one line; URI absorbs
   the squeeze and ellipsis-truncates instead. */
.shoji-log-table td[data-kind="wafrules"] {
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  min-width: 12rem;
  max-width: 16rem;
}

/* Log table sortable headers now use the shared [data-sort-key] +
   .is-sort-asc / .is-sort-desc pattern in shoji.css (top of file).
   The bespoke .shoji-log-sort anchor + text-arrow styles that used to
   live here have been retired. */

.shoji-log-row {
  cursor: pointer;
}

.shoji-log-row:hover {
  background: oklch(var(--bc) / 0.04);
}

.shoji-log-ts {
  color: oklch(var(--bc) / 0.6);
  white-space: nowrap;
}

.shoji-log-lvl {
  font-weight: 600;
}

.shoji-log-lvl-error {
  color: oklch(var(--er));
}

.shoji-log-lvl-warn {
  color: oklch(var(--wa));
}

.shoji-log-lvl-info {
  color: oklch(var(--in));
}

.shoji-log-lvl-debug {
  color: oklch(var(--bc) / 0.5);
}

.shoji-log-msg {
  max-width: 42rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shoji-log-msg-more {
  color: oklch(var(--bc) / 0.5);
  margin-left: 0.25rem;
}

.shoji-log-detail td {
  padding: 0;
  background: oklch(var(--b2));
  border-bottom: 1px solid oklch(var(--bc) / 0.06);
}

.shoji-log-detail-pre {
  margin: 0;
  padding: 0.875rem 1.25rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace !important;
  font-size: 0.75rem;
  line-height: 1.55;
  color: oklch(var(--bc) / 0.85);
  white-space: pre-wrap;
  word-break: break-word;
  background: transparent;
}

.shoji-log-raw {
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace !important;
  font-size: 0.75rem;
  line-height: 1.55;
  color: oklch(var(--bc) / 0.85);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: calc(100vh - 18rem);
  overflow: auto;
  padding: 0.25rem 0;
}

/* --- Page header (used on /sites, /dashboard). -------------------- */

.shoji-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.shoji-page-title {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.shoji-page-subtitle {
  margin-top: 0.375rem;
  font-size: 0.875rem;
  color: oklch(var(--bc) / 0.6);
}

/* Typographic scale — five sizes, three weights, sentence case only.
   Sizes: text-3xl (page title + big stat) · text-lg (section/card title)
        · text-base (default body) · text-sm (secondary body / labels)
        · text-xs (helper / disclaimer, usually opacity-60).
   Weights: 700 (page title only) · 600 (font-semibold, headings + button text)
          · 400 (font-normal, body). Don't add font-medium / font-light /
   font-bold elsewhere. */

/* Underline-style tab bar — shared by /dbadmin and /firewall. */
.shoji-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  border-bottom: 1px solid oklch(var(--bc) / 0.08);
  margin-bottom: 0.5rem;
}

.shoji-tabs a {
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: oklch(var(--bc) / 0.6);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.shoji-tabs a:hover {
  color: oklch(var(--bc));
}

.shoji-tabs a.is-active {
  color: oklch(var(--bc));
  border-bottom-color: oklch(var(--p));
}

/* ---- pager: shared pagination bar -----------------------------------
   Consumed by the {{template "pager"}} partial. Buttons on the left,
   jump-to-page form + page-size dropdown on the right. Wraps to
   multiple rows on narrow screens. */
.shoji-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.shoji-pager-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.shoji-pager-gap {
  padding: 0 0.25rem;
  opacity: 0.5;
  font-size: 0.875rem;
}

.shoji-pager-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.875rem;
}

.shoji-pager-jump,
.shoji-pager-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---- pwInput: password field with inline refresh ----------------------
   Used by the shared {{template "pwInput"}} / {{template "pwModal"}}
   partials. The input is readonly + auto-populated; the operator can
   cycle a new value via the refresh icon. */
.shoji-pw-field {
  position: relative;
}

.shoji-pw-field .input {
  padding-right: 2.5rem;
}

.shoji-pw-refresh {
  position: absolute;
  top: 50%;
  right: 0.375rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0.375rem;
  color: oklch(var(--bc) / 0.55);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}

.shoji-pw-refresh:hover,
.shoji-pw-refresh:focus-visible {
  color: oklch(var(--bc));
  background: oklch(var(--bc) / 0.08);
  outline: none;
}

.shoji-pw-refresh svg {
  width: 1rem;
  height: 1rem;
}

/* ---- filter-chips: shared "Filtered: chip chip × clear all" bar -------
   Used by /logs and /dbadmin to display active free-text filter terms
   above a result list. Clickable chips drop just that term (built via
   filter.Chips); static chips render the same shape without a × icon
   for filters that don't support individual clearing.
   Exclude tokens render in the error palette. */
.shoji-filter-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
}

.shoji-filter-summary-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.6875rem;
  color: oklch(var(--bc) / 0.55);
}

.shoji-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  background: oklch(var(--p) / 0.14);
  color: oklch(var(--bc));
  font-family: var(--shoji-font);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color 0.1s ease, border-color 0.1s ease;
}

a.shoji-filter-chip:hover,
a.shoji-filter-chip:focus-visible {
  background: oklch(var(--p) / 0.22);
  border-color: oklch(var(--p) / 0.45);
}

.shoji-filter-chip-exclude {
  background: oklch(var(--er) / 0.14);
}

a.shoji-filter-chip-exclude:hover,
a.shoji-filter-chip-exclude:focus-visible {
  background: oklch(var(--er) / 0.22);
  border-color: oklch(var(--er) / 0.5);
}

.shoji-filter-chip-prefix {
  color: oklch(var(--er));
  font-weight: 700;
}

.shoji-filter-chip-x {
  color: oklch(var(--bc) / 0.55);
  font-size: 0.95em;
  line-height: 1;
}

a.shoji-filter-chip:hover .shoji-filter-chip-x,
a.shoji-filter-chip:focus-visible .shoji-filter-chip-x {
  color: oklch(var(--er));
}

.shoji-filter-clear {
  color: oklch(var(--bc) / 0.55);
  font-size: 0.75rem;
}

.shoji-filter-clear:hover {
  color: oklch(var(--er));
}

/* DaisyUI badges use per-variant `--*c` content colours; several of
   those resolve to white in our dark palette, which reads as muddy
   on a coloured pill at the small sizes Shoji uses. Force black text
   on every filled-colour badge variant in dark mode for legibility.
   Ghost / outline variants are skipped — they sit on the page
   background, so black text on a dark page would be unreadable. */
[data-theme="dark"] :where(.badge-primary, .badge-secondary, .badge-accent,
                            .badge-neutral, .badge-info, .badge-success,
                            .badge-warning, .badge-error) {
  color: #000;
}

/* Analytics — chart host gives every Overview canvas a stable aspect-
   ratio + height (Chart.js defaults to 0px when its parent is flex/grid
   without an intrinsic height) and the inline bar widget renders the
   per-row share in each breakdown table. */
.shoji-chart-host {
  position: relative;
  height: 260px;
  width: 100%;
}

.shoji-bar {
  position: relative;
  height: 0.5rem;
  border-radius: 0.25rem;
  background: oklch(var(--bc) / 0.08);
  overflow: hidden;
}

.shoji-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: oklch(70% 0.165 230);
  border-radius: inherit;
}

/* Settings toggle row: a switch with a title + description beside it.
   Deliberately NOT a <label> wrapping the whole row — only the switch
   itself flips the control, so clicking the descriptive text can't
   toggle it by accident. Edge padding is trimmed by Tailwind
   first:pt-0 / last:pb-0 in the markup. */
.shoji-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-block: 1rem;
}

/* Drag-and-drop upload zone (e.g. the YARA rules upload modal). A
   <label> wrapping a hidden file input, so a click opens the browser
   while JS handles dropped files. .is-dropzone is toggled on dragover. */
.shoji-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  border: 2px dashed oklch(var(--bc) / 0.25);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.shoji-dropzone:hover {
  border-color: oklch(var(--bc) / 0.4);
}
.shoji-dropzone.is-dropzone {
  border-color: oklch(var(--p));
  background: oklch(var(--p) / 0.08);
}
