:root {
  --ground: #F4F2EC;
  --paper: #FFFFFF;
  --paper-2: #FBFAF7;
  --ink: #1B1A17;
  --muted: #5B5850;
  --line: #E2DED3;
  --line-strong: #CFCABD;
  --green: #1E5B47;
  --green-dark: #143F31;
  --green-soft: #E1EDE7;
  --green-line: #C5DACF;
  --amber-bg: #FFF4DA;
  --amber-ink: #5A4210;
  --amber-line: #E3C170;
  --red: #9A2B1B;
  --red-line: #D9A79B;
  --tag-bg: #FBE3DA;
  --tag-ink: #8A2E12;
  --display: 'Bricolage Grotesque', 'Segoe UI', 'Helvetica Neue', sans-serif;
  --body: 'Public Sans', 'Segoe UI', 'Helvetica Neue', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #6FA58E; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Header */
.top { background: var(--ink); color: #F4F2EC; }
.top-inner { max-width: 1120px; margin: 0 auto; padding: 28px 32px 18px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(30px, 4vw, 44px); line-height: 1.02; letter-spacing: -0.01em; }
.brand p { margin: 6px 0 0; color: #D6D2C6; font-size: 15px; }
.top-meta { display: flex; gap: 12px; align-items: center; font-size: 13px; color: #C9C4B6; flex-wrap: wrap; }
.badge-dirty { background: var(--amber-line); color: #3A2A06; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.tabs { max-width: 1120px; margin: 0 auto; padding: 0 32px; display: flex; gap: 4px; overflow-x: auto; }
.tab { appearance: none; border: 0; background: transparent; color: #D6D2C6; padding: 12px 18px 13px; border-radius: 10px 10px 0 0; font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: #FFFFFF; background: #2B2A26; }
.tab[aria-current="page"] { background: var(--ground); color: var(--ink); }

/* Page */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 32px 72px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.1; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--paper); font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--green); border-color: var(--green); color: #FFFFFF; }
.btn.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn.dashed { border-style: dashed; border-color: var(--green); color: var(--green); background: transparent; }
.btn.danger { color: var(--red); border-color: var(--red-line); }
.icon-btn { flex-shrink: 0; width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--paper); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover:not(:disabled) { border-color: var(--ink); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.danger { color: var(--red); border-color: var(--red-line); }
.summary { font-weight: 600; color: #3F3C36; margin: 0 0 14px; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.empty { color: var(--muted); font-style: italic; font-size: 14px; margin: 0; }
.help-text { margin: 0; font-size: 14px; color: var(--muted); }
.note { margin: 0; background: var(--amber-bg); color: var(--amber-ink); padding: 10px 14px; border-radius: 8px; font-size: 14px; }

/* Accordions */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.chev { flex-shrink: 0; transition: transform 0.18s; }
details[open] > summary .chev { transform: rotate(90deg); }
.dept { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.dept > summary { display: flex; align-items: center; gap: 16px; padding: 20px 24px; }
.dept > summary:hover { background: var(--paper-2); }
.dept-text { flex: 1; min-width: 0; }
.dept-name { font-family: var(--display); font-size: 23px; font-weight: 700; line-height: 1.2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dept-desc { color: var(--muted); font-size: 15px; margin-top: 2px; }
.count { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; font-family: var(--body); line-height: 1.5; }
.chip.warn { background: var(--tag-bg); color: var(--tag-ink); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.grey { background: #EFEDE6; color: var(--muted); font-weight: 600; }
.dept-body { border-top: 1px solid var(--line); background: var(--paper-2); }
.cat { border-bottom: 1px solid #ECE9E0; }
.cat:last-child { border-bottom: 0; }
.cat > summary, .cat-static { display: flex; align-items: flex-start; gap: 12px; padding: 13px 24px 13px 40px; min-height: 52px; color: var(--green); }
.cat > summary .chev { margin-top: 2px; }
.chev-space { width: 20px; flex-shrink: 0; }
.cat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cat-desc { font-size: 14px; color: var(--muted); line-height: 1.45; }
.cat .chip { margin-top: 2px; flex-shrink: 0; }
.cat > summary:hover { background: #F5F3ED; }
.cat-name { font-weight: 600; color: var(--ink); }
.cat-body { padding: 2px 24px 18px 72px; display: flex; flex-direction: column; gap: 12px; }
.cat-body p { margin: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 6px 12px; background: var(--paper); border: 1px solid var(--green-line); border-radius: 999px; font-size: 14px; }
.sub-label { font-size: 14px; font-weight: 700; color: var(--muted); }
.pg-rows { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.pg-rows li { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; padding: 10px 14px; border-top: 1px solid #ECE9E0; font-size: 14px; }
.pg-rows li:first-child { border-top: 0; }
.pg-rows li span { color: var(--muted); }
.list-row.pg textarea { flex: 1.6; }

/* Naming guide */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; }
.panel h3 { margin: 0 0 10px; font-family: var(--display); font-size: 21px; font-weight: 700; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.rules { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.tag-list { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.tag-item { display: flex; gap: 12px; align-items: flex-start; }
.tag-item p { margin: 0; font-size: 15px; }
.tag-code { font-weight: 800; background: var(--ink); color: #FFFFFF; border-radius: 6px; padding: 2px 8px; font-size: 13px; flex-shrink: 0; letter-spacing: 0.02em; }
.tag-item .tag-code { margin-top: 2px; min-width: 46px; text-align: center; }
.types { padding: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; border-top: 1px solid var(--line); background: var(--paper-2); }
.types > .type-card:only-child { grid-column: 1 / -1; }
.type-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.type-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.type-head h4 { margin: 0; font-size: 19px; font-family: var(--display); font-weight: 700; line-height: 1.2; }
.formula { margin: 0; font-weight: 600; font-size: 15px; }
.formula span { color: var(--muted); font-weight: 500; }
.breakdown { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; background: #F7F6F1; border-radius: 8px; padding: 10px 12px; }
.breakdown code { font-family: var(--body); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 8px; }
.breakdown .op { color: var(--muted); }
.breakdown strong { flex-basis: 100%; font-size: 16px; padding-top: 4px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.also { margin: 0; font-size: 14px; color: var(--muted); }
.also strong { color: var(--ink); }

/* Builder */
.builder { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.builder-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.field > label, .lbl { font-weight: 700; font-size: 15px; }
.opt { font-weight: 500; color: var(--muted); font-size: 13px; margin-left: 8px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); min-height: 44px; font-size: 16px; }
input:hover, select:hover, textarea:hover { border-color: #A8A294; }
input:disabled, select:disabled { background: #EFEDE6; color: #8C877B; border-color: var(--line); cursor: not-allowed; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
textarea { resize: vertical; min-height: 72px; }
.select-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.select-row label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 15px; }
.measure { display: flex; gap: 8px; }
.measure input { flex: 1; }
.measure select { width: auto; min-width: 96px; }
.unit-fixed { display: inline-flex; align-items: center; padding: 0 16px; border: 1px solid var(--line); border-radius: 8px; background: #F7F6F1; font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; font-size: 15px; color: var(--ink); }
.check input { width: 20px; height: 20px; accent-color: var(--green); flex-shrink: 0; margin: 0; }
.fixed-word { padding: 10px 12px; border-radius: 8px; background: #F7F6F1; border: 1px dashed var(--line-strong); font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 16px 14px; margin: 24px 0 0; }
legend { font-weight: 700; padding: 0 6px; }
.tag-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tag-row input[type="text"] { width: 140px; }
.form-foot { margin-top: 20px; display: flex; gap: 8px; }

.label-card { background: var(--paper); border: 1px solid var(--line); border-top: 8px solid var(--green); border-radius: 14px; padding: 18px 22px 20px; }
.label-small { margin: 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.label-name { margin: 6px 0 16px; font-family: var(--display); font-size: clamp(24px, 2.6vw, 34px); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.label-name.placeholder { color: #A09B8E; font-weight: 600; }
.label-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.counter { font-size: 13px; color: var(--muted); font-weight: 600; }
.counter.over { color: var(--red); }
.segments { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: flex; flex-direction: column; gap: 1px; padding: 7px 12px; border-radius: 8px; border: 1px solid transparent; min-width: 64px; }
.seg b { font-size: 15px; }
.seg small { font-size: 12px; color: var(--muted); font-weight: 600; }
.seg.filled { background: var(--green-soft); border-color: var(--green-line); }
.seg.tagseg { background: var(--ink); border-color: var(--ink); }
.seg.tagseg b { color: #FFFFFF; }
.seg.tagseg small { color: #C9C4B6; }
.seg.missing { border: 1px dashed #C99A2E; background: var(--amber-bg); }
.seg.skip { border: 1px dotted var(--line-strong); }
.seg.missing b, .seg.skip b { color: #6E6A60; font-weight: 600; }
.warnings { margin: 0; padding: 12px 16px 12px 34px; background: var(--amber-bg); border: 1px solid var(--amber-line); border-radius: 10px; color: var(--amber-ink); font-size: 14px; }
.ready { margin: 0; padding: 12px 16px; background: var(--green-soft); border-radius: 10px; color: var(--green); font-weight: 600; font-size: 14px; }

/* Settings */
.lock { max-width: 460px; margin: 32px auto; }
.lock .measure { margin-top: 12px; }
.error { color: var(--red); font-size: 14px; font-weight: 600; margin: 8px 0 0; }
.savebar { padding: 12px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; margin-bottom: 16px; background: #EAE7DF; color: var(--muted); }
.savebar.dirty { background: var(--amber-bg); color: var(--amber-ink); border: 1px solid var(--amber-line); }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line-strong); }
.subtab { border: 0; background: transparent; padding: 10px 14px; min-height: 44px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; font-size: 15px; }
.subtab:hover { color: var(--ink); }
.subtab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--green); }
.edit-block { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.edit-block > summary { display: flex; align-items: center; gap: 12px; padding: 12px 18px; min-height: 52px; }
.edit-block > summary:hover { background: var(--paper-2); border-radius: 12px; }
.eb-title { flex: 1; font-weight: 700; min-width: 0; }
.eb-meta { font-size: 13px; color: var(--muted); text-align: right; }
.eb-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); }
.edit-block .edit-block { background: var(--paper-2); }
.edit-block .edit-block .edit-block, .part-edit { background: var(--paper); }
.frm { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.frm input, .frm textarea, .frm select { color: var(--ink); font-weight: 500; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 12px; align-items: end; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions .spacer { flex: 1; }
.list-row { display: flex; gap: 8px; align-items: center; }
.list-row input, .list-row textarea { flex: 1; min-width: 0; }
.list-row textarea { min-height: 52px; }
.part-edit { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.set-h { margin: 8px 0 0; font-size: 16px; font-family: var(--display); font-weight: 700; }
.set-panel { display: flex; flex-direction: column; gap: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #FFFFFF; padding: 12px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; max-width: calc(100vw - 32px); z-index: 10; box-shadow: 0 6px 24px rgba(27, 26, 23, 0.25); }

@media (max-width: 860px) {
  .builder, .two-col, .types, .select-row, .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .builder-side { display: contents; }
  .builder > .panel { order: 1; }
  .builder-side > * { order: 2; }
  .builder-side > .label-card { order: 0; position: sticky; top: 0; z-index: 5; box-shadow: 0 6px 18px rgba(27, 26, 23, 0.12); }
  .label-name { margin-bottom: 10px; }
  .top-inner, .tabs, .page { padding-left: 18px; padding-right: 18px; }
  .dept > summary { padding: 16px 18px; }
  .cat > summary, .cat-static { padding-left: 18px; padding-right: 18px; }
  .cat-body { padding-left: 50px; padding-right: 18px; }
  .count { display: none; }
  .pg-rows li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .cat > summary, .cat-static { flex-wrap: wrap; }
  .cat-text { flex-basis: calc(100% - 32px); }
  .cat .chip { margin-left: 32px; margin-top: 0; }
  .list-row.pg { flex-wrap: wrap; }
  .list-row.pg input, .list-row.pg textarea { flex-basis: 100%; }
}
@media print {
  .tabs, .no-print, .actions, .toast, .badge-dirty, .form-foot { display: none !important; }
  body, .page { background: #FFFFFF; }
  .top { background: #FFFFFF; color: #000000; border-bottom: 2px solid #000000; }
  .brand p, .top-meta { color: #333333; }
  .page { padding: 16px 0; max-width: none; }
  .dept, .panel { border-color: #999999; }
  .type-card, .cat, .tag-item, .pg-rows li { break-inside: avoid; }
  .types { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Server version additions ---------- */
.loading { padding: 40px 32px; color: var(--muted); }
.top-user { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-user .who { font-size: 14px; color: #D6D2C6; margin-right: 4px; }
.top-user .who strong { color: #FFFFFF; font-weight: 600; }
.btn.dark { background: transparent; color: #F4F2EC; border-color: #6E6A60; }
.btn.dark:hover { border-color: #F4F2EC; }
.btn.dark[aria-current="page"] { background: #F4F2EC; color: var(--ink); border-color: #F4F2EC; }
.btn.link { border-color: transparent; background: transparent; color: var(--green); padding: 0 8px; text-decoration: underline; text-underline-offset: 3px; }
.btn.link:hover { color: var(--green-dark); border-color: transparent; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 13px; }

.refresh-banner { position: sticky; top: 0; z-index: 20; background: var(--amber-bg); border-bottom: 1px solid var(--amber-line); color: var(--amber-ink); }
.refresh-banner > div { max-width: 1120px; margin: 0 auto; padding: 10px 32px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-weight: 600; font-size: 14px; }

/* Inactive items */
.chip.off { background: #E6E3DB; color: #4A473F; }
.is-inactive .dept-name, .is-inactive .cat-name, .is-inactive > strong { color: #77736A; }
.dept.is-inactive { background: #F7F6F2; border-style: dashed; }
.cat.is-inactive, .pg-rows li.is-inactive { background: #F3F1EB; }
.inactive-note { font-size: 13px; color: #6E4F12; font-weight: 600; }
.status-box { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; background: #F7F6F2; }
.status-box.form { border-style: solid; border-color: var(--amber-line); background: var(--amber-bg); }
.status-box p { margin: 0; font-size: 14px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pg-edit { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--paper); }
.pg-edit.is-inactive { background: #F7F6F2; border-style: dashed; }
.read-value { font-size: 15px; color: var(--ink); font-weight: 500; padding: 2px 0; white-space: pre-wrap; }
.save-status { font-size: 14px; font-weight: 600; color: var(--muted); }
.save-status.saving { color: var(--amber-ink); }
.save-status.error { color: var(--red); }
.save-status.saved { color: var(--green); }

/* Permission grid */
.perm-grid { display: flex; flex-direction: column; gap: 4px; }
.perm-group { margin: 12px 0 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.perm-group:first-child { margin-top: 0; }
.perm-row { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; align-items: start; padding: 8px 0; border-top: 1px solid #ECE9E0; }
.perm-area { font-weight: 700; font-size: 14px; padding-top: 8px; }
.perm-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-size: 13px; font-weight: 600; cursor: pointer; }
.perm-check input { width: 18px; height: 18px; accent-color: var(--green); margin: 0; }
.perm-check.on { border-color: var(--green-line); background: var(--green-soft); }
.perm-check.custom { border-color: #C99A2E; background: var(--amber-bg); }
.perm-check.locked { cursor: not-allowed; opacity: 0.6; }
.perm-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.perm-legend span::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--green-line); background: var(--green-soft); }
.perm-legend span.custom::before { border-color: #C99A2E; background: var(--amber-bg); }

/* Users, roles, links */
.chip.ink { background: var(--ink); color: #FFFFFF; }
.link-box { border: 1px solid var(--green-line); background: var(--green-soft); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.link-box p { margin: 0; font-size: 14px; }
.link-box input { font-size: 14px; }
.table-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.table-list > li { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid #ECE9E0; }
.table-list > li:first-child { border-top: 0; }
.table-list .main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.table-list .sub { font-size: 13px; color: var(--muted); }

/* Change log */
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.log-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.log-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; padding: 12px 16px; border-top: 1px solid #ECE9E0; font-size: 14px; }
.log-row:first-child { border-top: 0; }
.log-when { color: var(--muted); font-weight: 600; font-size: 13px; padding-top: 1px; }
.log-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.log-type { color: var(--muted); }
.log-row.warn { background: #FDF6F4; }
.log-details { font-size: 13px; }
.log-details summary { color: var(--green); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.log-details dl { margin: 6px 0 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; }
.log-details dt { color: var(--muted); font-weight: 600; }
.log-details dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Account */
.perm-summary { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.perm-summary li { font-size: 14px; }
.perm-summary strong { display: inline-block; min-width: 170px; }

/* Sign-in pages */
.auth-body { min-height: 100vh; background: var(--ink); }
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 48px 20px; }
.auth-site { color: #F4F2EC; font-family: var(--display); font-weight: 800; font-size: 32px; margin: 0 0 18px; line-height: 1.05; }
.auth-card { background: var(--ground); border-radius: 16px; padding: 28px; }
.auth-card.wide { max-width: 640px; }
.auth-wrap:has(.wide) { max-width: 680px; }
.auth-card h1 { margin: 0 0 6px; font-family: var(--display); font-size: 28px; line-height: 1.1; }
.auth-lead { margin: 0 0 16px; color: var(--muted); }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; }
.auth-form input[type="email"], .auth-form input[type="url"], .auth-form input[type="file"] { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); min-height: 44px; font-size: 16px; }
.auth-form input[readonly] { background: #EFEDE6; color: var(--muted); }
.auth-form .btn { margin-top: 4px; min-height: 48px; font-size: 15px; }
.auth-form fieldset { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-check { flex-direction: row !important; align-items: center; font-weight: 600 !important; }
.auth-check input { width: 20px; height: 20px; accent-color: var(--green); }
.auth-hint { font-weight: 500; color: var(--muted); font-size: 13px; }
.auth-error { background: #FBE9E5; color: #7A2314; border: 1px solid var(--red-line); border-radius: 10px; padding: 10px 14px; margin: 12px 0 0; font-size: 14px; }
.auth-error ul { margin: 0; padding-left: 18px; }
.auth-notice { background: var(--green-soft); color: var(--green); border-radius: 10px; padding: 10px 14px; margin: 12px 0 0; font-size: 14px; font-weight: 600; }
.auth-foot { margin: 18px 0 0; font-size: 13px; color: var(--muted); }

@media (max-width: 860px) {
  .refresh-banner > div { padding-left: 18px; padding-right: 18px; }
  .perm-row, .log-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .perm-area { padding-top: 0; }
  .filters { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .top-user, .refresh-banner { display: none !important; }
}
