:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #dcdcd8;
  --accent: #8b1e1e;
  --accent-text: #ffffff;
  --green: #2e7d32;
  --yellow: #c79100;
  --red: #c62828;
  --ok-bg: #e8f5e9;
  --err-bg: #fdecea;
  --info-bg: #eef3fb;
  --radius: 6px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .8rem; }
h2 { font-size: 1.2rem; margin: 1.8rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
small, .muted { color: var(--muted); }

header.top {
  background: var(--accent);
  color: var(--accent-text);
}
header.top .inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
}
header.top .brand { font-weight: 700; font-size: 1.15rem; padding: .7rem 0; color: inherit; text-decoration: none; }
header.top nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
header.top nav a {
  color: var(--accent-text); text-decoration: none; padding: .7rem .7rem; opacity: .85;
  border-bottom: 3px solid transparent;
}
header.top nav a:hover { opacity: 1; }
header.top nav a.active { opacity: 1; border-bottom-color: #fff; font-weight: 600; }
header.top .who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
header.top .who form { margin: 0; }
header.top .who button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6); padding: .25rem .6rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1.4rem 16px 3rem; }

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid var(--line); }
.flash.ok { background: var(--ok-bg); border-color: #b7dfb9; }
.flash.error { background: var(--err-bg); border-color: #f5c2bf; }
.flash.info { background: var(--info-bg); border-color: #c8d6ef; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.row > .grow { flex: 1 1 320px; min-width: 0; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.toolbar form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin: 0; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #efefec; font-weight: 600; font-size: .9rem; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; margin: 0; }
.table-wrap { overflow-x: auto; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
  font: inherit; padding: .4rem .55rem; border: 1px solid #c4c4bf; border-radius: var(--radius); background: #fff; color: var(--text);
  max-width: 100%;
}
textarea { width: 100%; min-height: 4rem; }
input[type=color] { width: 3rem; height: 2.1rem; padding: 0; border: 1px solid #c4c4bf; border-radius: var(--radius); }
.field { margin-bottom: .7rem; }
.field input[type=text], .field input[type=password], .field select { width: 100%; }
.inline-fields { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.inline-fields .field { margin-bottom: 0; }

button, .button {
  font: inherit; cursor: pointer; display: inline-block; text-decoration: none;
  padding: .42rem .9rem; border-radius: var(--radius); border: 1px solid #b9b9b4; background: #fff; color: var(--text);
}
button:hover, .button:hover { background: #f0f0ed; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: #701616; }
button.danger { color: var(--red); border-color: #e3a5a5; }
button.danger:hover { background: var(--err-bg); }
button.small, .button.small { padding: .2rem .55rem; font-size: .85rem; }
button.link { border: none; background: none; color: var(--accent); padding: 0; text-decoration: underline; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.draft { background: #ececec; color: #555; }
.badge.released { background: var(--ok-bg); color: var(--green); }
.badge.archived { background: #f1ece2; color: #7a6a4f; }
.badge.own { background: var(--ok-bg); color: var(--green); }
.badge.fallback { background: #fff6dd; color: #8a6400; }
.badge.missing { background: var(--err-bg); color: var(--red); }

.light { display: inline-block; width: .85rem; height: .85rem; border-radius: 50%; vertical-align: -1px; margin-right: .35rem; }
.light.green { background: var(--green); }
.light.yellow { background: var(--yellow); }
.light.red { background: var(--red); }

.swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 3px; vertical-align: -2px; margin-right: .4rem; border: 1px solid rgba(0,0,0,.15); }

.stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; min-width: 150px; }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; }

.progress { background: #e6e6e2; border-radius: 999px; height: .5rem; width: 120px; display: inline-block; vertical-align: middle; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); }

.dropzone {
  border: 2px dashed #b9b9b4; border-radius: var(--radius); padding: 1.4rem; text-align: center; background: #fbfbfa;
  transition: background .15s, border-color .15s;
}
.dropzone.over { background: var(--info-bg); border-color: var(--accent); }
.dropzone input[type=file] { margin-top: .6rem; }

.drag-handle { cursor: grab; color: var(--muted); user-select: none; padding-right: .3rem; }
tr.dragging { opacity: .4; }

.code-big { font-size: 3rem; font-weight: 700; letter-spacing: .4rem; font-variant-numeric: tabular-nums; }
.qr svg { width: 260px; height: 260px; }

.login-box { max-width: 380px; margin: 4rem auto; }
.login-box h1 { text-align: center; }

details summary { cursor: pointer; color: var(--accent); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt0 { margin-top: 0; }
.warn { color: var(--red); }

/* read-only role: no editing controls */
.readonly form[method=post]:not(.keep),
.readonly [data-toggle],
.readonly .edit-only { display: none !important; }
.readonly tbody[data-sortable] .drag-handle { visibility: hidden; }
