/* Kikaku Sensei portal theme — layered on top of Django admin's CSS variables. */

html[data-theme="light"], :root {
  --primary: #14b8a6;
  --secondary: #0f766e;
  --accent: #fb7185;
  --primary-fg: #fff;

  --body-fg: #1f2937;
  --body-bg: #f6f7f9;
  --body-quiet-color: #6b7280;
  --body-medium-color: #374151;
  --body-loud-color: #111827;

  --header-color: #e6fffb;
  --header-branding-color: #fff;
  --header-bg: #0f766e;
  --header-link-color: #fff;

  --breadcrumbs-fg: #6b7280;
  --breadcrumbs-link-fg: #0f766e;
  --breadcrumbs-bg: #ffffff;

  --link-fg: #0f766e;
  --link-hover-color: #115e59;
  --link-selected-fg: #0f766e;

  --hairline-color: #e5e7eb;
  --border-color: #d1d5db;
  --error-fg: #be123c;

  --message-info-bg: #e0f2fe;
  --message-success-bg: #dcfce7;
  --message-warning-bg: #fef9c3;
  --message-error-bg: #ffe4e6;

  --darkened-bg: #f3f4f6;
  --selected-bg: #e6f5f3;
  --selected-row: #f0fdfa;

  --button-fg: #fff;
  --button-bg: #0f766e;
  --button-hover-bg: #115e59;
  --default-button-bg: #0d9488;
  --default-button-hover-bg: #0f766e;
  --close-button-bg: #6b7280;
  --close-button-hover-bg: #374151;
  --delete-button-bg: #e11d48;
  --delete-button-hover-bg: #be123c;
  --object-tools-bg: #0f766e;
  --object-tools-hover-bg: #115e59;

  --font-family-primary: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --pt-card: #ffffff;
  --pt-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --pt-radius: 12px;
  --pt-hard-bg: #ffe4e6;
  --pt-hard-fg: #be123c;
  --pt-soft-bg: #e0f2fe;
  --pt-soft-fg: #0369a1;
  --pt-chip-bg: #f3f4f6;
  --pt-chip-on-bg: #ccfbf1;
  --pt-chip-on-fg: #115e59;
  --pt-ok: #16a34a;
  --pt-warn: #d97706;
  --pt-low: #e11d48;
  --pt-chart: #0d9488;
  --pt-chart-track: #ccfbf1;
  --pt-overlay: rgba(15, 23, 42, .45);
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #2dd4bf;
    --secondary: #134e4a;
    --body-fg: #e5e7eb;
    --body-bg: #0f1418;
    --body-quiet-color: #9ca3af;
    --body-medium-color: #d1d5db;
    --body-loud-color: #f9fafb;
    --header-bg: #134e4a;
    --breadcrumbs-fg: #9ca3af;
    --breadcrumbs-link-fg: #5eead4;
    --breadcrumbs-bg: #151c21;
    --link-fg: #5eead4;
    --link-hover-color: #99f6e4;
    --link-selected-fg: #5eead4;
    --hairline-color: #263038;
    --border-color: #374151;
    --error-fg: #fb7185;
    --message-info-bg: #0c3b52;
    --message-success-bg: #14532d;
    --message-warning-bg: #713f12;
    --message-error-bg: #4c0519;
    --darkened-bg: #151c21;
    --selected-bg: #17332f;
    --selected-row: #12302c;
    --button-bg: #0f766e;
    --button-hover-bg: #0d9488;
    --default-button-bg: #0d9488;
    --default-button-hover-bg: #14b8a6;
    --pt-card: #151c21;
    --pt-shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --pt-hard-bg: #4c0519;
    --pt-hard-fg: #fda4af;
    --pt-soft-bg: #0c3b52;
    --pt-soft-fg: #7dd3fc;
    --pt-chip-bg: #1f2930;
    --pt-chip-on-bg: #134e4a;
    --pt-chip-on-fg: #99f6e4;
    --pt-chart-track: #134e4a;
    --pt-overlay: rgba(0, 0, 0, .6);
  }
}

html[data-theme="dark"] {
  --primary: #2dd4bf;
  --secondary: #134e4a;
  --body-fg: #e5e7eb;
  --body-bg: #0f1418;
  --body-quiet-color: #9ca3af;
  --body-medium-color: #d1d5db;
  --body-loud-color: #f9fafb;
  --header-bg: #134e4a;
  --breadcrumbs-fg: #9ca3af;
  --breadcrumbs-link-fg: #5eead4;
  --breadcrumbs-bg: #151c21;
  --link-fg: #5eead4;
  --link-hover-color: #99f6e4;
  --link-selected-fg: #5eead4;
  --hairline-color: #263038;
  --border-color: #374151;
  --error-fg: #fb7185;
  --message-info-bg: #0c3b52;
  --message-success-bg: #14532d;
  --message-warning-bg: #713f12;
  --message-error-bg: #4c0519;
  --darkened-bg: #151c21;
  --selected-bg: #17332f;
  --selected-row: #12302c;
  --button-bg: #0f766e;
  --button-hover-bg: #0d9488;
  --default-button-bg: #0d9488;
  --default-button-hover-bg: #14b8a6;
  --pt-card: #151c21;
  --pt-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --pt-hard-bg: #4c0519;
  --pt-hard-fg: #fda4af;
  --pt-soft-bg: #0c3b52;
  --pt-soft-fg: #7dd3fc;
  --pt-chip-bg: #1f2930;
  --pt-chip-on-bg: #134e4a;
  --pt-chip-on-fg: #99f6e4;
  --pt-chart-track: #134e4a;
  --pt-overlay: rgba(0, 0, 0, .6);
}

/* Slightly larger type: admin sizes are rem-based, so this scales the whole UI */
html { font-size: 106.25%; }
body { background: var(--body-bg); font-size: .9375rem; }
select { height: auto; min-height: 2.25rem; }

/* ── Header ─────────────────────────────────────────────────────────────── */
#header { padding: 10px 32px; box-shadow: 0 1px 0 rgba(0, 0, 0, .08); }
#site-name a.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; }
#site-name a.brand img { border-radius: 50%; background: #fff; padding: 2px; }
#site-name .brand-text { display: flex; flex-direction: column; line-height: 1.1; font-weight: 600; font-size: 1.15rem; }
#site-name .brand-text small { font-size: .72rem; font-weight: 400; opacity: .8; letter-spacing: .04em; text-transform: uppercase; }
div.breadcrumbs { border-bottom: 1px solid var(--hairline-color); padding: 12px 32px; }

/* ── Cards / modules ────────────────────────────────────────────────────── */
#content { padding: 24px 32px; }
.module, fieldset.module, .inline-group, #changelist .results, #changelist-filter {
  background: var(--pt-card);
  border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow);
  border: 1px solid var(--hairline-color);
}
fieldset.module, .inline-group { overflow: hidden; margin-bottom: 20px; }
.module h2, .module caption, .inline-group h2, fieldset.module h2 {
  background: transparent;
  color: var(--body-loud-color);
  font-size: .95rem;
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline-color);
  text-transform: none;
  letter-spacing: 0;
}
.module h2 a, .module caption a { color: inherit; }
fieldset .description { padding: 10px 18px 0; color: var(--body-quiet-color); }
.form-row { padding: 12px 18px; }
input[type=text], input[type=number], input[type=password], input[type=email], input[type=url],
textarea, select, .vTextField {
  border-radius: 8px;
  border: 1px solid var(--border-color);
  padding: 7px 10px;
  background: var(--body-bg);
  color: var(--body-fg);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.button, input[type=submit], input[type=button], .submit-row input, a.button {
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 500;
  transition: background .15s, transform .05s;
}
.button:active, input[type=submit]:active { transform: translateY(1px); }
.submit-row { border-radius: var(--pt-radius); border: 1px solid var(--hairline-color); background: var(--pt-card); }
.object-tools a { border-radius: 999px; padding: 6px 14px; }

/* ── Changelist ─────────────────────────────────────────────────────────── */
#changelist .results { overflow-x: auto; }
#result_list thead th { background: var(--darkened-bg); font-weight: 600; }
#result_list tbody tr:hover td, #result_list tbody tr:hover th { background: var(--selected-row); }
#changelist-filter { overflow: hidden; }
#changelist #toolbar { background: transparent; border: 0; }
#changelist #toolbar #searchbar { min-width: 260px; }
.muted { color: var(--body-quiet-color); font-size: .85em; }

.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; letter-spacing: .03em;
}
.pill-hard { background: var(--pt-hard-bg); color: var(--pt-hard-fg); }
.pill-soft { background: var(--pt-soft-bg); color: var(--pt-soft-fg); }

.seat-bar { width: 96px; height: 8px; border-radius: 999px; background: var(--pt-chip-bg); overflow: hidden; }
.seat-bar span { display: block; height: 100%; border-radius: 999px; }
.seat-ok { background: var(--pt-ok); }
.seat-warn { background: var(--pt-warn); }
.seat-low { background: var(--pt-low); }

/* ── Chip checkboxes (operators, rule values) ───────────────────────────── */
div.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
div.chip-group > div { margin: 0; }
div.chip-group label {
  display: inline-flex; align-items: center; gap: 6px;
  width: auto; padding: 6px 12px; margin: 0;
  border-radius: 999px; border: 1px solid var(--border-color);
  background: var(--pt-chip-bg); color: var(--body-fg);
  font-weight: 500; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s;
}
div.chip-group label:hover { border-color: var(--primary); }
div.chip-group input[type=checkbox] { accent-color: var(--secondary); margin: 0; }
div.chip-group label:has(input:checked) {
  background: var(--pt-chip-on-bg); color: var(--pt-chip-on-fg); border-color: var(--primary);
}
div.chip-group > div[hidden] { display: none; }

.rule-tools { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.rule-tools input[type=search] { border-radius: 999px; padding: 6px 12px; min-width: 200px; border: 1px solid var(--border-color); background: var(--body-bg); color: var(--body-fg); }
.rule-tools button { background: none; border: 0; color: var(--link-fg); cursor: pointer; padding: 0; font-size: .85rem; }
.rule-tools .rule-count { color: var(--body-quiet-color); font-size: .85rem; }
.rule-empty { color: var(--body-quiet-color); font-style: italic; padding: 4px 0; }

/* Stacked rule inlines read as cards */
.rule-inline .inline-related { border-bottom: 1px solid var(--hairline-color); }
.rule-inline .inline-related h3 {
  background: var(--darkened-bg); color: var(--body-loud-color);
  padding: 10px 18px; font-size: .85rem; border: 0;
}
.rule-inline .inline-related h3 .inline_label { font-weight: 600; }
.rule-inline .add-row { padding: 14px 18px; background: var(--darkened-bg); }
.rule-inline .add-row a { font-weight: 600; }

/* ── Links: underline only inside running text ─────────────────────────── */
#container :is(#header a, .breadcrumbs a, #nav-sidebar a, .object-tools a, .pt-actions a, a.pt-stat,
  .pt-section a, .pt-alerts a, #result_list a, #changelist-filter a, .submit-row a,
  .inline-related h3 a, .pt-bar-track, .add-row a):is(:link, :visited, :hover, :focus) { text-decoration: none; }
#container :is(#result_list a, .pt-section a.model, .pt-alerts a):hover { text-decoration: underline; }
#result_list th.field-name { white-space: nowrap; }
.form-row input.vTextField { width: min(100%, 36rem); }

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.dashboard #content { width: auto; }
.dashboard #content-main { float: none; width: 100%; margin: 0; }
.pt-hero { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.pt-hero h1 { margin: 0; font-size: 1.6rem; font-weight: 700; color: var(--body-loud-color); }
.pt-hero p { margin: 4px 0 0; color: var(--body-quiet-color); }
.pt-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pt-actions a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; font-weight: 600;
  background: var(--button-bg); color: #fff; text-decoration: none;
}
.pt-actions a:hover { background: var(--button-hover-bg); color: #fff; }
.pt-actions a.secondary { background: var(--pt-card); color: var(--link-fg); border: 1px solid var(--border-color); }
.pt-actions a.secondary:hover { border-color: var(--primary); }

.pt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 28px; }
.pt-stat {
  background: var(--pt-card); border: 1px solid var(--hairline-color); border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow); padding: 16px 18px; text-decoration: none; color: inherit;
  transition: transform .15s, box-shadow .15s;
}
a.pt-stat:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 24, 40, .12); }
.pt-stat .label { font-size: .8rem; color: var(--body-quiet-color); text-transform: uppercase; letter-spacing: .05em; }
.pt-stat .value { font-size: 1.9rem; font-weight: 700; color: var(--body-loud-color); margin-top: 6px; }
.pt-stat .hint { font-size: .8rem; color: var(--body-quiet-color); margin-top: 2px; }

.pt-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; margin-bottom: 28px; }
.pt-section { background: var(--pt-card); border: 1px solid var(--hairline-color); border-radius: var(--pt-radius); box-shadow: var(--pt-shadow); overflow: hidden; }
.pt-section header { display: flex; align-items: center; gap: 14px; padding: 18px; border-bottom: 1px solid var(--hairline-color); }
.pt-section header .icon {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  background: var(--pt-chip-on-bg); color: var(--pt-chip-on-fg); flex: none;
}
.pt-section header h2 { margin: 0; font-size: 1.05rem; color: var(--body-loud-color); background: none; padding: 0; border: 0; }
.pt-section header p { margin: 2px 0 0; color: var(--body-quiet-color); font-size: .85rem; }
.pt-section ul { list-style: none; margin: 0; padding: 0; }
.pt-section li { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--hairline-color); }
.pt-section li:last-child { border-bottom: 0; }
.pt-section li a.model { font-weight: 600; font-size: .95rem; }
.pt-section li .links { display: flex; gap: 8px; }
.pt-section li .links a {
  font-size: .8rem; padding: 4px 10px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--border-color); color: var(--link-fg);
}
.pt-section li .links a.add { background: var(--button-bg); border-color: var(--button-bg); color: #fff; }

.pt-alerts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.pt-alerts .module ul { list-style: none; margin: 0; padding: 6px 0; }
.pt-alerts .module li { padding: 8px 18px; display: flex; justify-content: space-between; }
.pt-alerts .module p { padding: 12px 18px; margin: 0; color: var(--body-quiet-color); }

/* ── Login ──────────────────────────────────────────────────────────────── */
body.pt-login { min-height: 100vh; margin: 0; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--body-bg); }
.pt-login-brand {
  background: radial-gradient(circle at 20% 20%, #14b8a6 0, #0f766e 45%, #134e4a 100%);
  color: #fff; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  padding: 64px; position: relative; overflow: hidden;
}
.pt-login-brand::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px;
  border-radius: 50%; background: rgba(251, 113, 133, .18);
}
.pt-login-brand img { width: 112px; height: 112px; border-radius: 50%; background: #fff; padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.pt-login-brand h1 { font-size: 2.4rem; margin: 28px 0 8px; font-weight: 700; color: #fff; }
.pt-login-brand p { font-size: 1.05rem; max-width: 420px; line-height: 1.6; opacity: .9; margin: 0; }
.pt-login-brand .tag { margin-top: 28px; display: inline-flex; gap: 8px; align-items: center; background: rgba(255, 255, 255, .12); padding: 8px 14px; border-radius: 999px; font-size: .85rem; }
.pt-login-panel { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.pt-login-card { width: 100%; max-width: 380px; }
.pt-login-card .mobile-logo { display: none; }
.pt-login-card h2 { font-size: 1.6rem; margin: 0 0 6px; color: var(--body-loud-color); background: none; padding: 0; }
.pt-login-card .sub { color: var(--body-quiet-color); margin: 0 0 28px; }
.pt-login-card label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--body-medium-color); }
.pt-login-card .field { margin-bottom: 18px; }
.pt-login-card input[type=text], .pt-login-card input[type=password] { width: 100%; box-sizing: border-box; padding: 11px 14px; font-size: 1rem; }
.pt-login-card .errornote, .pt-login-card .errorlist { border-radius: 8px; }
.pt-login-card .errorlist { list-style: none; padding: 0; margin: 0 0 6px; color: var(--error-fg); }
.pt-login-card input[type=submit] { width: 100%; padding: 12px; font-size: 1rem; font-weight: 600; margin-top: 8px; background: var(--button-bg); color: #fff; border: 0; cursor: pointer; }
.pt-login-card input[type=submit]:hover { background: var(--button-hover-bg); }
.pt-login-card .foot { margin-top: 28px; font-size: .8rem; color: var(--body-quiet-color); text-align: center; }

@media (max-width: 860px) {
  body.pt-login { grid-template-columns: 1fr; }
  .pt-login-brand { display: none; }
  .pt-login-card .mobile-logo { display: block; width: 64px; height: 64px; margin-bottom: 20px; }
  #content { padding: 16px; }
  #header { padding: 10px 16px; }
}


/* ── Sidebar: two sections ──────────────────────────────────────────────── */
#nav-sidebar { padding: 16px 12px; background: var(--pt-card); border-right: 1px solid var(--hairline-color); }
.pt-nav-section { margin-bottom: 20px; }
.pt-nav-title {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-bottom: 4px;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--body-quiet-color);
}
.pt-nav-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--pt-chip-on-bg); color: var(--pt-chip-on-fg); }
.pt-nav-section ul { list-style: none; margin: 0; padding: 0; }
.pt-nav-section li { display: flex; align-items: center; border-radius: 8px; margin: 2px 0; }
.pt-nav-section li > a:first-child, .pt-nav-section li > span { flex: 1; padding: 8px 10px; color: var(--body-fg); font-weight: 500; border-radius: 8px; }
.pt-nav-section li:hover { background: var(--darkened-bg); }
.pt-nav-section li.current { background: var(--pt-chip-on-bg); }
.pt-nav-section li.current > a:first-child { color: var(--pt-chip-on-fg); font-weight: 600; }
.pt-nav-add {
  display: grid; place-items: center; width: 26px; height: 26px; margin-right: 6px; border-radius: 6px;
  color: var(--body-quiet-color); font-size: 1.1rem; line-height: 1; opacity: 0; transition: opacity .15s, background .15s;
}
.pt-nav-section li:hover .pt-nav-add, .pt-nav-add:focus-visible { opacity: 1; }
.pt-nav-add:hover { background: var(--button-bg); color: #fff; }
.toggle-nav-sidebar { background: var(--pt-card); border-right: 1px solid var(--hairline-color); }

/* ── Command palette ────────────────────────────────────────────────────── */
#header { gap: 16px; }
.pt-cmdk-trigger {
  display: inline-flex; align-items: center; gap: 10px; padding: 7px 10px 7px 12px; margin-left: 24px;
  min-width: 300px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .85); font: inherit; font-size: .85rem; cursor: pointer;
  transition: background .15s;
}
.pt-cmdk-trigger:hover { background: rgba(255, 255, 255, .18); }
.pt-cmdk-trigger span { flex: 1; text-align: left; }
kbd {
  display: inline-block; min-width: 1.4em; padding: 1px 6px; border-radius: 5px; font: 600 .72rem/1.5 var(--font-family-primary);
  text-align: center; border: 1px solid var(--border-color); background: var(--darkened-bg); color: var(--body-medium-color);
}
.pt-cmdk-trigger kbd { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .25); color: #fff; }
body.pt-modal-open { overflow: hidden; }
.pt-cmdk { position: fixed; inset: 0; z-index: 1000; }
.pt-cmdk[hidden] { display: none; }
.pt-cmdk-backdrop { position: absolute; inset: 0; background: var(--pt-overlay); backdrop-filter: blur(2px); animation: pt-fade .12s ease-out; }
.pt-cmdk-panel {
  position: relative; margin: 12vh auto 0; width: min(640px, calc(100% - 32px));
  background: var(--pt-card); border: 1px solid var(--hairline-color); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3); overflow: hidden; animation: pt-pop .14s ease-out;
}
.pt-cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--hairline-color); color: var(--body-quiet-color); }
.pt-cmdk-input input { flex: 1; border: 0; background: transparent; font-size: 1.05rem; padding: 4px 0; color: var(--body-fg); box-shadow: none; }
.pt-cmdk-input input:focus { box-shadow: none; }
.pt-cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.pt-cmdk-list li[data-index] { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.pt-cmdk-list li[aria-selected] { background: var(--pt-chip-on-bg); color: var(--pt-chip-on-fg); }
.pt-cmdk-list .label { font-weight: 500; }
.pt-cmdk-list .meta { color: var(--body-quiet-color); font-size: .8rem; white-space: nowrap; }
.pt-cmdk-section { padding: 10px 12px 4px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--body-quiet-color); }
.pt-cmdk-empty { padding: 14px 12px; color: var(--body-quiet-color); }
.pt-cmdk-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--hairline-color); font-size: .75rem; color: var(--body-quiet-color); background: var(--darkened-bg); }
.pt-cmdk-foot kbd { margin-right: 2px; }
.pt-help { padding: 20px 24px; }
.pt-help h2 { margin: 0 0 14px; font-size: 1.05rem; color: var(--body-loud-color); background: none; padding: 0; }
.pt-help dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; margin: 0; }
.pt-help dt { text-align: right; } .pt-help dt kbd { margin-left: 3px; }
.pt-help dd { margin: 0; color: var(--body-medium-color); }
@keyframes pt-fade { from { opacity: 0; } }
@keyframes pt-pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
.pt-sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pt-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100% - 40px)); }
.pt-toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: var(--pt-card); color: var(--body-fg); border: 1px solid var(--hairline-color);
  border-left: 4px solid var(--pt-chart); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); animation: pt-slide .2s ease-out;
}
.pt-toast.leaving { opacity: 0; transform: translateX(12px); transition: all .2s; }
.pt-toast-body { flex: 1; line-height: 1.45; }
.pt-toast-body a { font-weight: 600; }
.pt-toast-icon { width: 18px; height: 18px; border-radius: 50%; flex: none; margin-top: 1px; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.pt-toast-success { border-left-color: var(--pt-ok); } .pt-toast-success .pt-toast-icon { background: var(--pt-ok); } .pt-toast-success .pt-toast-icon::before { content: "✓"; }
.pt-toast-error { border-left-color: var(--pt-low); } .pt-toast-error .pt-toast-icon { background: var(--pt-low); } .pt-toast-error .pt-toast-icon::before { content: "!"; }
.pt-toast-warning { border-left-color: var(--pt-warn); } .pt-toast-warning .pt-toast-icon { background: var(--pt-warn); } .pt-toast-warning .pt-toast-icon::before { content: "!"; }
.pt-toast-info .pt-toast-icon { background: var(--pt-chart); } .pt-toast-info .pt-toast-icon::before { content: "i"; }
.pt-toast-close { background: none; border: 0; font-size: 1.2rem; line-height: 1; color: var(--body-quiet-color); cursor: pointer; padding: 0 2px; }
@keyframes pt-slide { from { opacity: 0; transform: translateY(8px); } }

/* ── Live switch ────────────────────────────────────────────────────────── */
.switch {
  position: relative; width: 38px; height: 22px; padding: 0; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--border-color); transition: background .18s; vertical-align: middle;
}
.switch span { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .18s; }
.switch[aria-checked="true"] { background: var(--pt-ok); }
.switch[aria-checked="true"] span { transform: translateX(16px); }
.switch.is-busy { opacity: .6; pointer-events: none; }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Busy buttons, sticky save bar, clickable rows ─────────────────────── */
.is-busy { position: relative; color: transparent !important; pointer-events: none; }
input.is-busy { background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0, rgba(255, 255, 255, .35) 50%, rgba(255, 255, 255, 0) 100%); background-size: 200% 100%; animation: pt-shimmer 1s linear infinite; color: rgba(255, 255, 255, .7) !important; }
@keyframes pt-shimmer { to { background-position: -200% 0; } }
.change-form #content-main form .submit-row { position: sticky; bottom: 12px; z-index: 20; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
#result_list.pt-clickable tbody tr { cursor: pointer; }

/* ── Rule cards ─────────────────────────────────────────────────────────── */
.rule-inline > h2 { display: flex; align-items: center; justify-content: space-between; }
.rule-bulk { display: flex; gap: 12px; }
.rule-bulk button, .pt-bulk-open { background: none; border: 0; color: var(--link-fg); font: 600 .8rem var(--font-family-primary); cursor: pointer; padding: 0; }
.rule-inline .inline-related > h3 { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.rule-inline .inline-related > h3::before {
  content: ""; width: 7px; height: 7px; flex: none; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); margin: 0 4px -2px 2px; transition: transform .15s; opacity: .6;
}
.rule-inline .inline-related.collapsed > h3::before { transform: rotate(-45deg); margin-bottom: 0; }
.rule-inline .inline-related.collapsed > fieldset { display: none; }
.rule-inline .inline-related > h3 > b { display: none; }
.rule-inline .inline-related > h3 .inline_label { display: none; }  /* the live summary replaces it */
.pill.js-rule-type { align-self: center; }
.rule-inline .inline-related > h3 .delete, .rule-inline .inline-related > h3 .inline-deletelink { margin-left: auto; }
.rule-summary { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; color: var(--body-fg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-summary .rule-op { font-size: .75rem; padding: 1px 8px; border-radius: 6px; background: var(--pt-chip-bg); color: var(--body-medium-color); }
.rule-inline .inline-related.rule-off > h3 .rule-summary { opacity: .55; }
.rule-inline .inline-related.rule-deleted { opacity: .5; }
.rule-inline .inline-related.rule-deleted > h3 .rule-summary { text-decoration: line-through; }
.rule-quickadd { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border-radius: 10px; background: var(--darkened-bg); border: 1px dashed var(--border-color); }
.rule-quickadd[hidden] { display: none; }
.rule-quickadd input { min-width: 180px; }
.rule-quickadd .qa-cancel { background: none; border: 0; color: var(--body-quiet-color); cursor: pointer; }
.rule-tools button[data-act="new"] { font-weight: 600; }

/* ── Seat meter preview ─────────────────────────────────────────────────── */
.pt-seat-preview { flex-basis: 100%; display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.pt-seat-preview .seat-bar { width: 220px; height: 10px; }
.pt-seat-text { font-size: .85rem; color: var(--body-quiet-color); }
.pt-seat-preview.invalid .pt-seat-text { color: var(--error-fg); font-weight: 600; }

/* ── Bulk values ────────────────────────────────────────────────────────── */
#values-group h2 { display: flex; align-items: center; gap: 10px; }
#values-group .pt-bulk-open { margin-left: auto; }
.pt-count { font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--pt-chip-on-bg); color: var(--pt-chip-on-fg); font-weight: 600; }
.pt-bulk { padding: 14px 18px; border-bottom: 1px solid var(--hairline-color); background: var(--darkened-bg); }
.pt-bulk[hidden] { display: none; }
.pt-bulk label { display: block; margin-bottom: 8px; color: var(--body-medium-color); }
.pt-bulk textarea { width: 100%; box-sizing: border-box; font-family: var(--font-family-monospace); }
.pt-bulk-actions { display: flex; gap: 12px; align-items: center; margin: 12px 0 4px; }
.pt-bulk-cancel { background: none; border: 0; color: var(--body-quiet-color); cursor: pointer; }

/* ── Dashboard charts ───────────────────────────────────────────────────── */
.pt-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; margin-bottom: 28px; }
.pt-chart { background: var(--pt-card); border: 1px solid var(--hairline-color); border-radius: var(--pt-radius); box-shadow: var(--pt-shadow); padding: 18px 20px; }
.pt-chart header h2 { margin: 0; font-size: 1rem; color: var(--body-loud-color); background: none; padding: 0; border: 0; }
.pt-chart header p { margin: 4px 0 14px; color: var(--body-quiet-color); font-size: .85rem; }
.pt-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pt-bars li { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 12px; }
.pt-bar-label { font-size: .85rem; color: var(--body-medium-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-bar-track { display: block; height: 22px; padding: 5px 0; box-sizing: border-box; border-radius: 4px; }
.pt-bar-track::before { content: ""; display: block; height: 12px; border-radius: 0 4px 4px 0; background: var(--pt-chart-track); }
.pt-bar-plain::before { background: transparent; border-left: 1px solid var(--hairline-color); border-radius: 0; }
.pt-bar-fill { display: block; height: 12px; margin-top: -12px; min-width: 2px; background: var(--pt-chart); border-radius: 0 4px 4px 0; transition: filter .15s; }
.pt-bar-track:hover .pt-bar-fill, .pt-bar-track:focus-visible .pt-bar-fill { filter: brightness(1.15); }
.pt-bar-track:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pt-bar-value { font-size: .85rem; font-weight: 600; color: var(--body-loud-color); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 64px; }
.pt-status { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; font-size: .7rem; font-weight: 700; }
.pt-status-critical { background: var(--pt-hard-bg); color: var(--pt-hard-fg); }
.pt-table-view { margin-top: 14px; font-size: .85rem; }
.pt-table-view summary { cursor: pointer; color: var(--link-fg); font-weight: 600; }
.pt-table-view table { width: 100%; margin-top: 10px; }
.pt-tip {
  position: absolute; z-index: 1200; pointer-events: none; max-width: 260px; padding: 8px 10px; border-radius: 8px;
  background: var(--body-loud-color); color: var(--body-bg); font-size: .8rem; line-height: 1.4; box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.pt-tip[hidden] { display: none; }

@media (max-width: 860px) {
  .pt-cmdk-trigger { min-width: 0; margin-left: 0; }
  .pt-cmdk-trigger span, .pt-cmdk-trigger kbd { display: none; }
  .pt-charts { grid-template-columns: 1fr; }
  .pt-bars li { grid-template-columns: 1fr auto; }
  .pt-bars li .pt-bar-track { grid-column: 1 / -1; grid-row: 2; }
}

#changelist .actions select { min-height: 0; }
#container button.pt-bulk-apply, #container button.qa-save { padding: 8px 16px; font-size: .875rem; border-radius: 8px; line-height: 1.2; }
