/* Brand: blue #13ADE4, dark #303435 (from the PJ Garment logo). */
:root {
  --pj-blue: #13ade4;
  --pj-blue-dark: #0e8ab8;
  --pj-dark: #303435;
  --pico-font-family-sans-serif: "Segoe UI", Tahoma, "Noto Sans Thai", sans-serif;
  --pico-font-family: var(--pico-font-family-sans-serif);
  --pico-primary: var(--pj-blue-dark);
  --pico-primary-background: var(--pj-blue-dark);
  --pico-primary-border: var(--pj-blue-dark);
  --pico-primary-hover: var(--pj-dark);
  --pico-primary-hover-background: var(--pj-dark);
  --pico-primary-focus: rgba(19, 173, 228, 0.35);
}
/* Pico defines its palette on :root:not([data-theme=dark]) (higher specificity than :root),
   so secondary overrides must use the same selector. Primary buttons intentionally keep
   Pico's rendered blue — the owner approved it as is (2026-11-15). */
:root:not([data-theme=dark]), [data-theme=light] {
  --pico-secondary: var(--pj-dark);
  --pico-secondary-background: var(--pj-dark);
  --pico-secondary-border: var(--pj-dark);
  --pico-secondary-underline: rgba(48, 52, 53, 0.5);
  --pico-secondary-hover: #1f2223;
  --pico-secondary-hover-background: #1f2223;
  --pico-secondary-hover-border: #1f2223;
  --pico-secondary-focus: rgba(48, 52, 53, 0.3);
}
body > header { background: var(--pj-dark); color: #fff; }
body > header a, body > header strong, body > header span { color: #fff; }
body > header .secondary.outline { color: #fff; border-color: rgba(255, 255, 255, 0.6); }
body > main, body > footer { padding-block: 1rem; }
body > header { padding-block: 0.25rem; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.brand .icon { color: var(--pj-blue); width: 1.5em; height: 1.5em; }
.site-nav strong { white-space: nowrap; }
.narrow { max-width: 26rem; margin-inline: auto; }
.error-box { color: var(--pico-del-color); }
/* Lucide sprite icons: stroke-based, inherit text colour. */
.icon {
  width: 1.15em; height: 1.15em; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
/* htmx indicator styles live here so CSP needs no inline <style>. */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---- Operate surfaces: lists, facts, forms (Phase 1) ---------------------- */
::selection { background: rgba(19, 173, 228, 0.25); }
:focus-visible { outline: 2px solid var(--pj-blue); outline-offset: 2px; }
main { padding-bottom: 3rem; }
h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.muted { color: #5b6467; }
.mono, .tag-cell, .tag-title, .asset-label-tag { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.inline-form { display: inline; margin: 0; }
.compact { padding: 0.35rem 0.7rem; margin: 0; width: auto; }
.link-button { all: unset; cursor: pointer; color: var(--pj-blue-dark); font-size: 0.85em; text-decoration: underline; text-underline-offset: 0.2em; }
.link-button:hover { color: var(--pj-dark); }

/* header nav */
.nav-links { gap: 0.25rem; flex-wrap: wrap; }
.nav-links a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--pj-blue); border-radius: 0; }
.nav-user { color: #fff; opacity: 0.9; }

/* page head */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head hgroup { margin: 0; }
.head-actions { display: flex; gap: 0.5rem; }
.head-actions [role="button"] { margin: 0; }
nav[aria-label="breadcrumb"] { margin-bottom: 0.5rem; font-size: 0.9rem; }

/* filters */
.filters { display: grid; grid-template-columns: minmax(12rem, 2fr) repeat(3, minmax(8rem, 1fr)) auto; gap: 0.5rem; align-items: start; margin-bottom: 1rem; }
.filters > * { margin: 0; }

/* data tables */
.data-table { font-size: 0.93rem; }
.data-table th { font-weight: 600; color: var(--pj-dark); white-space: nowrap; }
.data-table td { vertical-align: top; }
.tag-cell a { font-weight: 600; text-decoration: none; white-space: nowrap; }
.type-cell { white-space: nowrap; }
.type-cell .icon { color: var(--pj-blue-dark); }

/* status badges: tinted, never grey-on-grey */
.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: 0.1em; }
.badge-in_use { background: #e3f5fc; color: #075a7a; }
.badge-in_stock { background: #eceff7; color: #34406b; }
.badge-repair { background: #fff1d6; color: #7a4b00; }
.badge-retired { background: #ececec; color: #3f4446; }
.badge-lost { background: #fde4e1; color: #8a1f12; }
.badge-review { background: #fff1d6; color: #7a4b00; }
.badge-stale { background: #fde4e1; color: #8a1f12; }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #4a5254; }
.empty-state .icon { width: 2.5rem; height: 2.5rem; color: var(--pj-blue); }
.empty-state p { max-width: 36rem; margin: 0.75rem auto 1rem; }

/* asset detail */
.asset-head { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-start; margin-bottom: 1rem; }
.tag-title { font-size: 2.1rem; margin: 0; color: var(--pj-dark); }
.asset-sub { margin: 0.25rem 0 0; color: #3f4446; }
.asset-sub .icon { color: var(--pj-blue-dark); }
.qr-mini { margin: 0; text-align: center; }
.qr-mini > svg { width: 96px; height: 96px; display: block; margin-inline: auto; }
.qr-mini figcaption { font-size: 0.85rem; margin-top: 0.25rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.75rem 2rem; margin: 0 0 1.5rem; padding: 1rem 0; border-block: 1px solid #e3e6e7; }
.facts div { margin: 0; }
.facts dt { font-size: 0.8rem; color: #5b6467; margin: 0; font-weight: 500; }
.facts dd { margin: 0.1rem 0 0; font-weight: 500; }
.facts .wide { grid-column: 1 / -1; }
.facts .note { white-space: pre-line; font-weight: 400; }
.action-row { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 2rem; }
.action-panel { margin: 0; }
.action-panel > summary[role="button"] { width: auto; display: inline-flex; gap: 0.4rem; align-items: center; }
.action-panel[open] > form { margin-top: 1rem; padding: 1rem 1.25rem; border: 1px solid #e3e6e7; border-radius: var(--pico-border-radius); background: #fafbfb; }
.section-title { font-size: 1.15rem; margin: 2rem 0 0.75rem; display: flex; gap: 0.4rem; align-items: center; }
.section-title .icon { color: var(--pj-blue-dark); }
.form-error { padding: 0.75rem 1rem; border-radius: var(--pico-border-radius); background: #fde4e1; color: #8a1f12; }
.form-error small { color: #8a1f12; opacity: 0.8; }

/* forms */
.form-panel fieldset { margin-bottom: 1.25rem; }
.form-panel legend { font-weight: 600; color: var(--pj-dark); margin-bottom: 0.5rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.form-actions > * { width: auto; margin: 0; }

/* settings */
.settings-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 2.5rem; }
.settings-block { margin-bottom: 1.75rem; }
.inline-edit { display: flex; gap: 0.5rem; align-items: center; }
.inline-edit input { margin: 0; }
.plain-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.plain-list li { list-style: none; padding: 0.35rem 0; border-bottom: 1px solid #eef0f1; display: flex; gap: 0.4rem; align-items: center; }
.plain-list li .inline-form { margin-left: auto; }
.plain-list .inactive { color: #6d7578; }
.home-links { list-style: none; padding: 0; display: flex; gap: 1rem; flex-wrap: wrap; }
.home-links li { list-style: none; }

/* printable label: 50 x 30 mm */
.label-page { background: #f4f5f5; padding: 1.5rem; font-family: "Segoe UI", Tahoma, "Noto Sans Thai", sans-serif; color: var(--pj-dark); }
.label-toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: 1.5rem; font-size: 0.9rem; }
.label-toolbar button { width: auto; margin: 0; padding: 0.4rem 1rem; background: var(--pj-blue-dark); color: #fff; border: 0; border-radius: 0.25rem; cursor: pointer; }
.asset-label { width: 50mm; height: 30mm; box-sizing: border-box; padding: 2mm; background: #fff; display: flex; gap: 2mm; align-items: center; border: 1px dashed #b9c0c2; }
.asset-label-qr svg { width: 25mm; height: 25mm; display: block; }
.asset-label-text { display: flex; flex-direction: column; gap: 0.6mm; min-width: 0; }
.asset-label-org { font-size: 2.6mm; font-weight: 700; color: var(--pj-blue-dark); }
.asset-label-tag { font-size: 4.2mm; line-height: 1.1; }
.asset-label-meta { font-size: 2.3mm; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media print {
  @page { size: 50mm 30mm; margin: 0; }
  .no-print { display: none !important; }
  .label-page { background: #fff; padding: 0; }
  .asset-label { border: 0; }
}

/* narrow screens */
.hide-sm { display: inline; }
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input[type="search"] { grid-column: 1 / -1; }
  .asset-head { flex-direction: row; }
  .qr-mini > svg { width: 72px; height: 72px; }
  .settings-grid { grid-template-columns: 1fr; gap: 1rem; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { padding: 0.6rem 0; border-bottom: 1px solid #e3e6e7; }
  .data-table td { border: 0; padding: 0.1rem 0; }
  .asset-table td.tag-cell { font-size: 1.05rem; }
  .site-nav { flex-wrap: wrap; }
}

/* devices */
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.host-cell strong { margin-right: 0.25rem; }
.count-pill { display: inline-block; min-width: 1.4em; padding: 0 0.4em; border-radius: 999px; background: #fff; color: var(--pj-dark); font-size: 0.8em; font-weight: 700; text-align: center; }
.filters-devices { grid-template-columns: minmax(12rem, 3fr) minmax(10rem, 1fr) auto; }
.review-list { list-style: none; padding: 0; margin: 1rem 0; }
.review-item { list-style: none; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 1.5rem; padding: 1rem 0; border-bottom: 1px solid #e3e6e7; }
.review-main { min-width: 0; }
.review-meta { font-size: 0.85rem; margin-top: 0.25rem; }
.review-actions { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.merge-box { margin: 0; }
.merge-box summary { list-style: none; padding-top: 0.35rem; }
.merge-box summary::-webkit-details-marker { display: none; }
.merge-box[open] form { margin: 0.5rem 0 0.25rem; }
.upload-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; padding: 1rem; border: 1px dashed #b9c0c2; border-radius: var(--pico-border-radius); background: #fafbfb; }
.upload-form input[type="file"] { margin: 0; flex: 1 1 16rem; }
.upload-form button { width: auto; margin: 0; }
.device-panel { margin-top: 1rem; }
.spec-sections details { border-bottom: 1px solid #eef0f1; padding: 0.5rem 0; margin: 0; }
.spec-sections summary { font-weight: 600; display: flex; gap: 0.4rem; align-items: center; }
.spec-sections summary .icon { color: var(--pj-blue-dark); }
.compact-table { font-size: 0.85rem; margin: 0.75rem 0; }
.spec-lines { font-size: 0.8rem; white-space: pre-wrap; background: #f6f7f7; padding: 0.75rem; border-radius: var(--pico-border-radius); }
@media (max-width: 720px) {
  .filters-devices { grid-template-columns: 1fr auto; }
  .filters-devices input[type="search"] { grid-column: 1 / -1; }
}
.status-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 0.25rem 0 0.75rem; }
.status-actions .inline-edit { gap: 0.4rem; }
.compact-select { margin: 0; width: auto; padding: 0.35rem 2rem 0.35rem 0.6rem; }
.danger-link { color: #8a1f12; }
.conflict-line { font-size: 0.85rem; color: #7a4b00; margin-top: 0.25rem; }

/* guest welcome */
.guest { max-width: 52rem; margin: 1.5rem auto 0; }
.guest-logo { display: block; margin-bottom: 1rem; height: auto; }
.guest h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.guest-lead { font-size: 1.1rem; color: #3f4446; max-width: 40rem; }
.guest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin: 2rem 0 1.5rem; }
.guest-grid article { margin: 0; padding: 1.25rem 1.5rem; border: 1px solid #e3e6e7; border-radius: var(--pico-border-radius); box-shadow: none; }
.guest-grid h2 { font-size: 1.1rem; display: flex; gap: 0.4rem; align-items: center; }
.guest-grid h2 .icon { color: var(--pj-blue-dark); }
.contact-list dt { font-weight: 600; margin: 0; }
.contact-list dd { margin: 0.1rem 0 0.75rem; }
.guest-login { font-size: 0.9rem; }
@media (max-width: 720px) { .guest-grid { grid-template-columns: 1fr; } .guest h1 { font-size: 1.6rem; } }

/* 2FA */
.wide-narrow { max-width: 36rem; }
.code-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem 1.5rem; font-size: 1.1rem; }
.code-grid li { list-style: none; }
.setup-steps li { margin-bottom: 1rem; }
.qr-setup { margin: 0.75rem 0; }
.qr-setup svg { width: 180px; height: 180px; display: block; }
.nav-user a { text-decoration: none; }
