/* Shared look of the staff pages: Control Board (/kp), Developer Reference (/developer), Tools (/tools), Events calendar (/calendar).
   Layout: top bar + left sidebar (sections) + content. Light and dark through [data-theme]. Under 900px the sidebar becomes a scrolling strip. */
:root {
  --bg: #ffffff; --bg-subtle: #f6f7f9; --bg-hover: #eef0f3; --surface: #ffffff; --border: #e3e6eb; --border-strong: #cdd2da;
  --text: #1a1f27; --text-2: #46505e; --text-3: #5b6472; --accent: #4338ca; --accent-soft: #eef0ff; --on-accent: #ffffff;
  --bad: #b91c1c; --bad-soft: #fef2f2; --warn: #92560a; --warn-soft: #fff4dc; --ok: #0f6b3f; --ok-soft: #e6f5ec; --info: #0b5cad; --info-soft: #e8f2fc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: "Inter", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif; --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
:root[data-theme="dark"] {
  --bg: #0f1115; --bg-subtle: #14171c; --bg-hover: #1e222a; --surface: #181b21; --border: #272c35; --border-strong: #38404c;
  --text: #e7e9ed; --text-2: #b4bbc7; --text-3: #98a1af; --accent: #9ea2f7; --accent-soft: #1f2243; --on-accent: #0f1115;
  --bad: #fca5a5; --bad-soft: #2a1618; --warn: #fcd34d; --warn-soft: #2b2310; --ok: #6ee7b7; --ok-soft: #11261c; --info: #7cc0ff; --info-soft: #11233a;
  --shadow: none;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg-subtle); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* top bar */
header.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); }
.bar { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.brand h1 { font-size: 17px; line-height: 1.25; margin: 0; font-weight: 650; }
.brand small { display: block; font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); font-weight: 550; font-size: 14px; text-decoration: none; color: var(--text); transition: background .15s, border-color .15s; }
.btn:hover { background: var(--bg-hover); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 38px; padding: 0 10px; font-size: 13px; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 650; }
.btn.ghost { border-color: transparent; background: transparent; }

/* shell: sidebar + content */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: 0; max-width: 1480px; margin: 0 auto; }
.side { position: sticky; top: 61px; align-self: start; height: calc(100vh - 61px); overflow-y: auto; padding: 18px 12px 28px 20px; }
.side h2 { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); margin: 18px 10px 6px; font-weight: 650; }
.side h2:first-child { margin-top: 0; }
.side button.nav, .side a.nav { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 10px; background: none; color: var(--text-2); font-weight: 500; text-align: left; text-decoration: none; line-height: 1.3; }
.side .nav:hover { background: var(--bg-hover); color: var(--text); }
.side .nav[aria-selected="true"], .side .nav[aria-current="page"], .side .nav[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 650; }
.side .nav .t { flex: 1; min-width: 0; }
.side .nav .t small { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
.content { padding: 22px 24px 70px 12px; min-width: 0; }
.content.full { padding-left: 24px; }
@media (max-width: 900px) {
  .shell { display: block; }
  .side { position: static; height: auto; display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--border); }
  .side h2 { display: none; }
  .side .nav { width: auto; white-space: nowrap; }
  .side .nav .t small { display: none; }
  .content, .content.full { padding: 16px 14px 60px; }
  .bar { padding: 8px 14px; }
}

/* page header and plain-language intro */
.page-h { margin: 0 0 14px; }
.page-h h2 { font-size: 22px; line-height: 1.3; margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
.page-h p { margin: 0; color: var(--text-2); max-width: 78ch; }
.help { display: flex; gap: 10px; background: var(--info-soft); border: 1px solid transparent; color: var(--text); border-radius: 12px; padding: 11px 14px; margin: 0 0 16px; font-size: 14px; max-width: 100ch; }
.help .ic { color: var(--info); margin-top: 2px; }
.help b { font-weight: 650; }
h3.sec { font-size: 15px; margin: 24px 0 4px; font-weight: 650; }
p.sec-d { margin: 0 0 10px; color: var(--text-3); font-size: 13.5px; max-width: 90ch; }

/* cards and grids */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.card b { display: block; font-size: 24px; line-height: 1.25; font-variant-numeric: tabular-nums; font-weight: 650; }
.card > span { font-size: 13px; color: var(--text-3); }
.card.link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, background .15s; min-height: 44px; }
.card.link:hover { border-color: var(--accent); background: var(--accent-soft); }
.card.link b { font-size: 15px; } .card.link span { display: block; margin-top: 2px; }
.dbcard { padding: 0; overflow: hidden; }
.dbcard header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dbcard header .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.dbcard header h4 { margin: 0; font-size: 16px; line-height: 1.3; }
.dbcard header small { color: var(--text-3); display: block; font-size: 12.5px; }
.dbcard .dbmeta { padding: 8px 16px; font-size: 12.5px; color: var(--text-3); border-bottom: 1px solid var(--border); display: flex; gap: 14px; flex-wrap: wrap; }
.dbcard table { font-size: 13.5px; } .dbcard .tablewrap { border: 0; border-radius: 0; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.off { background: var(--bg-hover); color: var(--text-2); } .pill.info { background: var(--info-soft); color: var(--info); }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 650; white-space: nowrap; background: var(--bg-subtle); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; } th.num { text-align: right; }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
td small, .sub { display: block; color: var(--text-3); font-size: 12.5px; font-weight: 400; }
.bar2 { height: 8px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; min-width: 80px; } .bar2 > i { display: block; height: 100%; background: var(--accent); }
.pbar { position: relative; height: 12px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; min-width: 120px; } .pbar > i { display: block; height: 100%; background: var(--accent); transition: width .6s; } .pbar.done > i { background: var(--ok); }

/* forms */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
input[type=text], input[type=number], input[type=search], input[type=date], select, textarea { min-height: 44px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 12px; background: var(--bg); }
textarea { padding: 8px 12px; }
input.wide, input[type=search] { flex: 1; min-width: 220px; }
label.chk { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
pre { margin: 0; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: auto; max-height: 460px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note { color: var(--text-3); font-size: 13px; max-width: 86ch; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
.toast.on { opacity: 1; }
.status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.status .big { font-size: 18px; font-weight: 650; }
.dotl { width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); flex: none; } .dotl.on { background: var(--ok); animation: pulse 1.6s infinite; } .dotl.pause { background: var(--warn); } .dotl.bad { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }
.feed { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.feed li { padding: 7px 14px; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; } .feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--text-3); font-family: var(--mono); font-size: 12px; flex: none; } .feed .error { color: var(--bad); }
details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
details > summary { cursor: pointer; padding: 12px 14px; min-height: 44px; font-weight: 600; }
details[open] > summary { border-bottom: 1px solid var(--border); }
details .tablewrap { border: 0; border-radius: 0 0 12px 12px; box-shadow: none; }
details.ed { margin-top: 6px; border: 0; background: none; } details.ed summary { color: var(--accent); min-height: 32px; padding: 4px 0; } .ed .row input, .ed .row select, .ed .row textarea { min-height: 40px; }

/* calendars */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; } .cal .h { font-size: 12px; text-transform: uppercase; color: var(--text-3); text-align: center; padding: 4px 0; }
.cal .d { min-height: 92px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px 6px; font-size: 12.5px; overflow: hidden; } .cal .d.out { opacity: .4; } .cal .d.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal .d > b { font-size: 12px; color: var(--text-3); }
.ev { display: block; margin-top: 2px; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--text); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; border: 0; text-align: left; width: 100%; }
.ev.p { background: transparent; border: 1px dashed var(--border-strong); color: var(--text-2); }
.ev.High { background: var(--bad-soft); color: var(--bad); font-weight: 600; } .ev.Medium { background: var(--warn-soft); color: var(--warn); font-weight: 600; } .ev.Low { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
button.ev { cursor: pointer; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-bottom: 10px; } .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }
@media (max-width: 640px) { .cal .d { min-height: 60px; padding: 2px 3px; } .ev { font-size: 11px; padding: 0 3px; } }

/* developer page extras */
.dsplit { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.dlist { display: grid; gap: 8px; }
.dcard { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-height: 44px; transition: border-color .15s, background .15s; }
.dcard:hover { background: var(--bg-hover); } .dcard[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.dcard b { display: block; font-size: 14px; line-height: 1.35; } .dcard span { font-size: 12.5px; color: var(--text-2); display: block; margin-top: 2px; }
iframe.diagram { width: 100%; height: calc(100vh - 150px); min-height: 560px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
@media (max-width: 1100px) { .dsplit { grid-template-columns: 1fr; } .dlist { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }
.pill.admin { background: var(--bad-soft); color: var(--bad); } .pill.api { background: var(--warn-soft); color: var(--warn); } .pill.open { background: var(--ok-soft); color: var(--ok); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
