:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1c2430; --muted: #4d5b6b; --border: #d5dae1;
  --brand: #8a1c1c; --focus: #0b57d0; --error: #b00020; --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14181f; --surface: #1d232d; --text: #e8ecf1; --muted: #a8b3c1; --border: #364152; --brand: #e26d6d; --focus: #8ab4f8; --error: #ff8a80; }
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; max-width: 72rem; margin: 0 auto; padding: .5rem 1rem; }
.brand { font-weight: 700; font-size: 1.25rem; text-decoration: none; color: var(--brand); margin-right: auto; }
.tenant-badge { font-size: .875rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .75rem; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-button { display: none; cursor: pointer; border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem .8rem; margin: 0; }
.nav-toggle:focus-visible + .nav-button { outline: 3px solid var(--focus); outline-offset: 2px; }
.main-nav { flex-basis: 100%; }
.main-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: 0; padding: 0; }
.main-nav a { display: inline-block; padding: .5rem .25rem; min-height: 44px; line-height: 28px; text-decoration: none; color: var(--text); }
.main-nav a[aria-current="page"] { border-bottom: 3px solid var(--brand); font-weight: 600; }
main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.site-footer { max-width: 72rem; margin: 0 auto; padding: 1rem; color: var(--muted); font-size: .875rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
.required::after { content: " *"; color: var(--brand); }
.field-error { color: var(--error); font-size: .875rem; margin-top: .25rem; }
input, select, textarea, button { font: inherit; min-height: 44px; }
@media (max-width: 40rem) {
  .nav-button { display: inline-block; }
  .main-nav { display: none; }
  .nav-toggle:checked ~ .main-nav { display: block; }
  .main-nav ul { flex-direction: column; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .25rem; }
.inline-form { display: inline-flex; gap: .5rem; align-items: center; margin: 0; }
.flash { background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--brand); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }
.field { margin-bottom: 1rem; }
.field input:not([type=checkbox]):not([type=hidden]), .field select, .field textarea { width: 100%; max-width: 32rem; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.field [aria-invalid=true] { border-color: var(--error); border-width: 2px; }
.field-check label { font-weight: 400; display: flex; gap: .5rem; align-items: center; min-height: 44px; }
.field-check input { width: 1.25rem; height: 1.25rem; min-height: 0; }
.hint { color: var(--muted); font-size: .875rem; margin: .25rem 0 0; }
.btn { display: inline-block; padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; font-weight: 600; }
@media (prefers-color-scheme: dark) { .btn { color: #14181f; } }
.btn-secondary { background: transparent; color: var(--brand); }
.btn-danger { background: var(--error); border-color: var(--error); }
.form-narrow { max-width: 32rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .875rem; color: var(--muted); }
.badge { display: inline-block; font-size: .8125rem; padding: .05rem .6rem; border-radius: 999px; border: 1px solid var(--border); }
.badge-warn { border-color: var(--error); color: var(--error); }
.stack > * + * { margin-top: 1.5rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row-actions select { min-width: 9rem; }
.muted { color: var(--muted); }
details.danger summary { cursor: pointer; color: var(--error); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
@media (max-width: 40rem) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; padding: .25rem 0; }
  .table-stack td { border: 0; padding: .25rem .75rem; }
  .table-stack td::before { content: attr(data-label); display: block; font-size: .8125rem; color: var(--muted); }
  .row-actions select { min-width: 0; flex: 1 1 8rem; }
}
.flash-info { border-left-color: var(--focus); }
.flash-info code { display: block; word-break: break-all; padding: .5rem; background: var(--bg); border-radius: 4px; margin-top: .25rem; }
.masterdata-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; }
.masterdata-card { text-decoration: none; color: inherit; transition: border-color .15s; }
.masterdata-card:hover, .masterdata-card:focus-visible { border-color: var(--brand); }
.masterdata-card h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
.search-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.search-form input[type=search] { min-width: 12rem; }
.masterdata-child-row { padding-left: 1.5rem; }
fieldset.card, fieldset.field { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
fieldset legend { padding: 0 .4rem; font-weight: 600; }
.picture-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.picture-card { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; background: var(--bg); position: relative; }
.picture-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: calc(var(--radius) - 2px); display: block; }
.picture-card .badge { position: absolute; top: .75rem; left: .75rem; background: var(--surface); }
.picture-meta { margin: .5rem 0; }
.picture-meta input { margin-bottom: .35rem; }
.picture-card figcaption { color: var(--muted); font-size: .875rem; margin-top: .35rem; }
