:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #646b73;
  --line: #dcdad4;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --danger: #b4372f;
  --ok-bg: #e6f2ec;
  --err-bg: #f8e5e3;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --surface: #1f2226;
    --text: #e6e6e3;
    --muted: #9aa0a6;
    --line: #34383d;
    --accent: #6fbfa6;
    --accent-ink: #10221c;
    --danger: #e0786f;
    --ok-bg: #1f3329;
    --err-bg: #3a2221;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
.muted { color: var(--muted); }
code { font-size: .9em; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.modules { display: flex; gap: 1rem; flex-wrap: wrap; }
.modules a { text-decoration: none; color: var(--text); padding: .2rem 0; border-bottom: 2px solid transparent; }
.modules a.active { border-color: var(--accent); }
.modules .soon { color: var(--muted); cursor: default; }
.right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.lang { display: flex; gap: .25rem; }
.lang .current { font-weight: 700; color: var(--text); text-decoration: none; }
form.inline { display: inline; }

/* Layout */
.page { max-width: 1000px; margin: 1.5rem auto; padding: 0 1rem; }
.narrow { max-width: 420px; margin: 3rem auto; padding: 0 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.card + .card { margin-top: 1rem; }
.grid .card + .card { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.subnav { display: flex; gap: 1rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.subnav a { text-decoration: none; color: var(--muted); padding: .4rem 0; border-bottom: 2px solid transparent; }
.subnav a.active { color: var(--text); border-color: var(--accent); }
.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .spacer { flex: 1; }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; }
.field .help { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.field.check label { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: .5rem .6rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
}
.toolbar input, .toolbar select { width: auto; }
.field div label { font-weight: 400; display: flex; gap: .4rem; align-items: center; margin: .15rem 0; }
ul.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
ul.checks label { font-weight: 400; display: flex; gap: .4rem; align-items: center; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: .25rem 0; font-size: .9rem; }

button, .button {
  display: inline-block; padding: .5rem 1rem; font: inherit; cursor: pointer; text-decoration: none;
  border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
table.matrix td, table.matrix th { text-align: center; }
table.matrix td:first-child, table.matrix th:first-child { text-align: left; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.tag { display: inline-block; padding: 0 .45rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--line); margin: 0 .2rem .2rem 0; }
a.tag { text-decoration: none; color: var(--text); }
.tag.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tag.warn { border-color: var(--danger); color: var(--danger); }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .5rem; background: var(--ok-bg); }
.msg.error { background: var(--err-bg); }

.qr { background: #fff; padding: 12px; display: block; width: fit-content; margin: .5rem 0; border-radius: 6px; }
.qr svg { display: block; width: 200px; height: 200px; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; align-items: center; }
pre.changes { margin: 0; font-size: .8rem; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 640px) {
  .right { margin-left: 0; width: 100%; justify-content: space-between; }
}

/* News */
.news-item h2 { margin: .25rem 0 .5rem; }
.news-item h2 a, .news-item h3 a { color: var(--text); text-decoration: none; }
.news-meta { font-size: .85rem; }
.prose { overflow-wrap: anywhere; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; }
.prose pre { background: var(--bg); padding: .75rem; border-radius: 6px; overflow-x: auto; }
.prose blockquote { margin: 0; padding-left: 1rem; border-left: 3px solid var(--line); color: var(--muted); }
.clamp { color: var(--muted); }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
ul.images { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
ul.images li { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
ul.images img { width: 96px; height: 64px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.field ul, .field div[id] { padding: 0; }

/* Maintenance */
.work-item h2 { margin: .25rem 0 .5rem; font-size: 1.1rem; }
.work-item h2 a, .work-item h3 a { color: var(--text); text-decoration: none; }
.struck { text-decoration: line-through; color: var(--muted) !important; }
.tag.status-in_progress { border-color: var(--danger); color: var(--danger); }
.tag.status-done, .tag.status-cancelled { color: var(--muted); }
.tag.impact-outage { background: var(--err-bg); }
.tag.impact-partial { background: #f5e9c8; color: #6b4e00; }
.tag.impact-none { background: var(--ok-bg); }
@media (prefers-color-scheme: dark) { .tag.impact-partial { background: #3a3220; color: #e8cf8a; } }
table.facts { width: auto; background: none; margin: .5rem 0 1rem; }
table.facts th, table.facts td { border: none; padding: .2rem 1rem .2rem 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.banner { display: block; padding: .6rem .9rem; border-radius: 6px; margin-bottom: .75rem; text-decoration: none; color: var(--text); border: 1px solid var(--line); }
.banner.impact-outage { background: var(--err-bg); border-color: var(--danger); }
.banner.impact-partial { background: #f5e9c8; color: #4a3600; }
.banner.impact-none { background: var(--ok-bg); }
@media (prefers-color-scheme: dark) { .banner.impact-partial { background: #3a3220; color: #e8cf8a; } }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal-head { padding: .4rem; font-size: .8rem; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }
.cal-day { min-height: 92px; padding: .3rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; }
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.other { background: var(--bg); color: var(--muted); }
.cal-day.today .cal-num { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 .4rem; display: inline-block; }
.cal-num { font-size: .8rem; margin-bottom: .2rem; }
.cal-work { display: block; font-size: .75rem; line-height: 1.3; padding: .1rem .3rem; margin-bottom: .15rem; border-radius: 4px; text-decoration: none; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--ok-bg); }
.cal-work.impact-outage { background: var(--err-bg); }
.cal-work.impact-partial { background: #f5e9c8; color: #4a3600; }
.cal-work.status-cancelled { text-decoration: line-through; opacity: .6; }
@media (max-width: 640px) { .row2 { grid-template-columns: 1fr; } .cal-day { min-height: 60px; } .cal-work { font-size: .65rem; } }

/* Requests */
.badge { display: inline-block; min-width: 1.2em; padding: 0 .35em; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; line-height: 1.4; text-align: center; vertical-align: 1px; }
.dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--danger); margin-right: .4rem; vertical-align: 2px; }
.small { font-size: .8rem; }
table.tickets tr.unread td:first-child a { font-weight: 600; }
.tag.tstatus-new { border-color: var(--accent); color: var(--accent); }
.tag.tstatus-in_progress { background: var(--ok-bg); }
.tag.tstatus-waiting { background: #f5e9c8; color: #6b4e00; }
.tag.tstatus-done, .tag.tstatus-rejected { color: var(--muted); }
.tag.urgency-high { border-color: var(--danger); color: var(--danger); }
.tag.urgency-low { color: var(--muted); }
@media (prefers-color-scheme: dark) { .tag.tstatus-waiting { background: #3a3220; color: #e8cf8a; } }
.ticket-text { margin-top: .5rem; }
ul.files { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
ol.timeline { list-style: none; padding: 0; margin: 0 0 1rem; border-left: 2px solid var(--line); }
ol.timeline .entry { position: relative; margin: 0 0 .75rem 1rem; padding: .6rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
ol.timeline .entry::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: .9rem; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
ol.timeline .entry.by-author::before { background: var(--accent); }
ol.timeline .entry.status, ol.timeline .entry.assign { background: transparent; border-style: dashed; font-size: .9rem; }
ol.timeline .meta { font-size: .8rem; margin-bottom: .25rem; }
ol.timeline .body p { margin: .25rem 0; }

/* Projects */
.page.wide { max-width: 1280px; }
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.board-col { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; min-height: 120px; }
.board-col h2 { font-size: .95rem; margin: 0 0 .6rem; }
.board-col.pstatus-in_progress { border-top: 3px solid var(--accent); }
.board-col.pstatus-done, .board-col.pstatus-postponed { opacity: .85; }
.board-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .6rem; margin-bottom: .5rem; }
.board-card-top { display: flex; gap: .5rem; align-items: flex-start; justify-content: space-between; }
.board-card-top a { color: var(--text); text-decoration: none; font-weight: 600; }
.vote-form { display: inline; }
.vote { padding: .1rem .5rem; font-size: .85rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); white-space: nowrap; }
.vote.voted { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.vote.static { display: inline-block; color: var(--muted); }
.goal { font-size: 1.05rem; margin: 0 0 .5rem; }
.tag.pstatus-idea { color: var(--muted); }
.tag.pstatus-planned { border-color: var(--accent); color: var(--accent); }
.tag.pstatus-in_progress { background: var(--ok-bg); }
.tag.pstatus-done { color: var(--muted); }
.tag.pstatus-postponed { background: #f5e9c8; color: #6b4e00; }
@media (prefers-color-scheme: dark) { .tag.pstatus-postponed { background: #3a3220; color: #e8cf8a; } }
@media (max-width: 900px) { .board { grid-template-columns: repeat(5, 240px); } }
