:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e9edf4;
  background: #101319;
  --panel: #181d25;
  --surface: #11161e;
  --muted: #a4afbe;
  --border: #343e4c;
  --accent: #9cce79;
  --mono: Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 3vw, 2.45rem); letter-spacing: -.04em; line-height: 1.15; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: #c1eaa6; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip { position: absolute; top: -4rem; left: 1rem; z-index: 3; }
.skip:focus { top: .8rem; background: var(--surface); padding: .5rem; }

.shell { width: min(100% - 3.5rem, 98rem); margin-inline: auto; }
.app-header { border-bottom: 1px solid var(--border); background: #141921; }
.header-layout { min-height: 4.65rem; display: flex; align-items: center; gap: clamp(1.1rem, 4vw, 3rem); }
.brand { display: flex; align-items: center; gap: .75rem; color: #edf2f7; text-decoration: none; font-size: 1.125rem; font-weight: 700; line-height: 1.12; white-space: nowrap; }
.brand small { display: block; color: var(--muted); font-size: .8125rem; font-weight: 400; margin-top: .18rem; }
.brand-mark { width: 2.4rem; height: 2.4rem; display: grid; grid-template-columns: repeat(2, 1fr); gap: .22rem; padding: .47rem; background: #22301f; border: 1px solid #42543a; border-radius: .62rem; }
.brand-mark i { background: var(--accent); border-radius: .12rem; }
.brand-mark i:last-child { background: #557947; }
.header-layout nav { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.header-layout nav a { padding: .55rem .72rem; color: var(--muted); border-radius: .4rem; text-decoration: none; font-size: .9375rem; white-space: nowrap; }
.header-layout nav a:hover, .header-layout nav a[aria-current] { color: var(--accent); background: #26332a; }
.logout { margin-left: auto; }

main { padding-block: 2.8rem; }
.editor-shell { max-width: 62rem; }
.narrow { max-width: 31rem; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-heading p, .login p { margin-top: .45rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.value { color: #c9e6b6; }
.lcsc { color: #a4c6e0; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: .75rem; min-width: 0; }
.panel-pad { padding: clamp(1rem, 3vw, 1.6rem); }
.stack { display: grid; gap: 1rem; }
.login form { margin-top: 1.4rem; }

input, button, select, textarea { font: inherit; }
label { display: block; color: #d3dae4; font-weight: 550; font-size: .875rem; min-width: 0; }
input:not([type=hidden]), select, textarea {
  display: block; width: 100%; min-width: 0; margin-top: .4rem; padding: .58rem .7rem;
  color: #edf2f8; background: var(--surface); border: 1px solid #455266; border-radius: .42rem;
  min-height: 2.55rem; font-size: 1rem; font-weight: 400;
}
input::placeholder { color: #9aa8b9; }
select { appearance: none; padding-right: 1.8rem; background-image: linear-gradient(45deg, transparent 50%, #a4afbe 50%), linear-gradient(135deg, #a4afbe 50%, transparent 50%); background-position: calc(100% - .87rem) 50%, calc(100% - .55rem) 50%; background-size: .32rem .32rem; background-repeat: no-repeat; }
textarea { min-height: 7rem; resize: vertical; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.55rem;
  padding: .5rem .85rem; border: 1px solid transparent; border-radius: .42rem;
  font-weight: 650; font-size: .875rem; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.primary { background: var(--accent); color: #172213; }
.primary:hover { background: #b7df9d; color: #172213; }
.secondary { background: #222832; color: #e2e7ef; border-color: #455266; }
.secondary:hover { background: #303846; color: #fff; }
.quiet { color: var(--muted); background: transparent; }
.danger { background: #322126; color: #ffb6b9; border-color: #7d5057; }
.danger:hover { background: #482930; color: #ffe4e4; }

.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; padding: 1rem 1.2rem; }
.filters .search { flex: 1 1 17rem; }
.filters label:not(.search) { min-width: 9.5rem; }
.table-wrap { overflow: auto; }
table { width: 100%; min-width: 66rem; border-collapse: collapse; text-align: left; }
.user-table { min-width: 0; }
.user-table th, .user-table td { min-width: 0; }
thead { background: #202631; }
thead th { border-block: 1px solid var(--border); font-size: .875rem; white-space: nowrap; }
thead th a { display: block; color: #cad3df; text-decoration: none; }
thead th[aria-sort] a, .sort-mark { color: var(--accent); }
td, th { padding: .82rem .8rem; vertical-align: middle; overflow-wrap: anywhere; }
td:first-child, th:first-child { padding-left: 1.2rem; }
td:last-child, th:last-child { padding-right: 1.2rem; }
tbody tr + tr > * { border-top: 1px solid #2b333f; }
tbody tr:hover { background: #202a34; }
tbody td { font-size: .875rem; }
tbody td:nth-child(2) { min-width: 8rem; }
td.lcsc { min-width: 7rem; }
tbody th { max-width: 18rem; min-width: 10rem; font-size: .9375rem; font-weight: 650; }
.part-name { color: #e9edf4; }
.row-status { display: block; color: var(--muted); margin-top: .26rem; font-weight: 400; }
.category-chip { display: inline-block; color: #c6d1de; background: #2b3543; border: 1px solid #485467; border-radius: .28rem; padding: .19rem .42rem; font-size: .8125rem; }
.pagination { border-top: 1px solid var(--border); padding: .85rem 1.2rem; display: flex; justify-content: space-between; align-items: center; gap: .6rem; color: var(--muted); font-size: .875rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.back { display: inline-block; margin-bottom: 1rem; }
.editor-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.editor-form fieldset + fieldset { margin-top: 1.45rem; padding-top: .35rem; }
legend { font-size: 1.05rem; font-weight: 680; padding: 0; margin-bottom: .7rem; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .95rem; }
.wide { grid-column: 1 / -1; }
.field-link, .field-grid small { display: block; margin-top: .4rem; font-size: .875rem; }
.required { color: var(--accent); }
.form-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-top: 1.35rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.archive-form { margin-top: 1rem; }
.library-field { min-width: 0; }
.library-field select[hidden] { display: none; }
.library-control:not([hidden]) { display: flex; gap: .45rem; margin-top: .4rem; }
.library-control input { margin-top: 0; }
.library-dialog {
  color: inherit; width: min(44rem, calc(100% - 1.6rem)); max-height: 85dvh;
  box-shadow: 0 1.2rem 4rem #0008;
}
.library-dialog[open] { display: flex; flex-direction: column; gap: 1rem; }
.library-dialog::backdrop { background: #080b11b8; }
.library-dialog input[type=search] { margin-top: 0; }
.library-results {
  overflow: auto; min-height: 0; margin: 0; padding: 0; list-style: none;
  border: 1px solid var(--border); border-radius: .42rem;
}
.library-results li + li { border-top: 1px solid var(--border); }
.library-result {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 32%); gap: .2rem .8rem;
  width: 100%; padding: .72rem .8rem; border: 0; text-align: left;
  color: inherit; background: var(--surface); overflow-wrap: anywhere; cursor: pointer;
}
.library-result:hover, .library-result[aria-current] { background: #26332a; color: var(--accent); }
.library-result-source { text-align: end; }
.library-result-source, .library-result-detail { font-size: .85rem; }
.library-result-detail { grid-column: 1 / -1; }
.library-result:focus-visible { outline-offset: -3px; }
.library-footer { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.password-hint { margin: .6rem 0 .85rem; }
.message { padding: .65rem .9rem; margin: 0 0 1rem; border-radius: .45rem; border: 1px solid; overflow-wrap: anywhere; }
.message li { margin-left: .95rem; }
.message.error { background: #3b252a; border-color: #98505a; color: #ffd1d4; }
.message.success { background: #273a2a; border-color: #54764a; color: #d7eace; }
.login .message { margin-top: 1rem; }
.inline-form { display: flex; align-items: end; gap: .7rem; margin-top: .8rem; }
.inline-form label { flex: 1; }
.management { margin-top: 1rem; }
.manage-row { padding: .9rem 1.2rem; display: grid; grid-template-columns: minmax(0, 1fr) 8rem minmax(14rem, auto); align-items: center; gap: .85rem; overflow-wrap: anywhere; }
.manage-row + .manage-row { border-top: 1px solid var(--border); }
.empty { padding: 2rem 1.2rem; color: var(--muted); }

@media (max-width: 46rem) {
  .shell { width: calc(100% - 1.6rem); }
  .header-layout { flex-wrap: wrap; gap: .7rem; padding-block: .7rem; }
  .header-layout nav { order: 3; width: 100%; margin-left: -.3rem; }
  main { padding-block: 1.5rem; }
  .filters label:not(.search) { flex: 1; min-width: 7rem; }
  .field-grid { grid-template-columns: 1fr; }
  .library-result { grid-template-columns: 1fr; }
  .library-result-source { text-align: start; }
  .manage-row { grid-template-columns: minmax(0, 1fr) auto; }
  .manage-row > :last-child { grid-column: 1 / -1; }
}
