:root {
  --navy: #0f3d5c; --navy-2: #15527a; --bg: #f3f5f8; --card: #fff; --ink: #1c2733; --muted: #66727f;
  --line: #e1e6ec; --ok: #1f8a4c; --warn: #b7791f; --err: #c0392b; --p1: #c0392b; --p2: #d9731a; --p3: #2f6fb0; --p4: #6b7785;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--navy-2); }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
em { font-style: normal; color: var(--muted); font-weight: 400; }

.top { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-size: 1.15rem; margin-right: auto; }
.brand b { color: #7fd1ff; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 800; }
.who { display: flex; flex-direction: column; text-align: right; line-height: 1.2; font-size: .9rem; }
.who small { opacity: .75; }
.top .link { color: #fff; opacity: .85; }
@media (max-width: 520px) { .who { display: none; } }

nav.tabs { background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; }
nav.tabs a, nav.subtabs a { padding: 12px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
nav.tabs a.on, nav.subtabs a.on { color: var(--navy); border-color: var(--navy); }
nav.subtabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 0 16px; }

main { max-width: 980px; margin: 0 auto; padding: 16px; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px 32px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.card.narrow { max-width: 420px; margin: 24px auto; }
.card.inline { display: flex; gap: 12px; align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > * { min-width: 0; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1; }
.field > span { font-weight: 600; font-size: .92rem; }
.field small { color: var(--muted); font-size: .8rem; }
input[type=text], input[type=password], input[type=number], input[type=time], select, textarea {
  font: inherit; padding: 11px 12px; border: 1px solid #c9d1da; border-radius: 10px; background: #fff; width: 100%; min-height: 46px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #7fb6e0; border-color: var(--navy-2); }
.check { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.check input { width: 20px; height: 20px; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px; border-radius: 10px; border: 1px solid #c9d1da; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.danger { color: var(--err); border-color: #e7b7b1; }
.btn.wide { width: 100%; }
.btn.choice { flex-direction: column; align-items: flex-start; text-align: left; }
.btn.choice small { color: var(--muted); font-weight: 400; }
.link { background: none; border: 0; padding: 6px 4px; font: inherit; color: var(--navy-2); cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--err); }

.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; background: #e7f5ec; border: 1px solid #b9e0c8; }
.flash.err { background: #fbeaea; border-color: #f0c2bd; }
.flash.warn { background: #fdf4e3; border-color: #efd9a8; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 16px; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stats b { display: block; font-size: 1.6rem; color: var(--navy); }
.stats span { color: var(--muted); font-size: .85rem; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: inherit; text-decoration: none; margin-bottom: 8px; }
.list .row { margin: 0; }
a.row:hover { border-color: #b8c6d4; }
.row > div:first-child { min-width: 0; }
.row b { display: block; }
.row small { color: var(--muted); display: block; overflow-wrap: anywhere; }
.row .right { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.row.faded { opacity: .55; }
@media (max-width: 560px) { a.row { flex-direction: column; align-items: flex-start; } .row .right { justify-content: flex-start; } }
.pill { font-size: .78rem; padding: 3px 9px; border-radius: 999px; background: #eef2f6; color: #44505c; white-space: nowrap; }
.pill.ok { background: #e3f4ea; color: var(--ok); } .pill.off { background: #fbeaea; color: var(--err); } .pill.warn { background: #fdf0d8; color: var(--warn); }
.empty { background: #fff; border: 1px dashed #c9d1da; border-radius: var(--radius); padding: 20px; text-align: center; color: var(--muted); margin-bottom: 8px; }
.empty.small { padding: 12px; font-size: .9rem; }

.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.tpl { position: relative; cursor: pointer; }
.tpl input { position: absolute; opacity: 0; }
.tpl span { display: flex; flex-direction: column; gap: 2px; height: 100%; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tpl small { color: var(--muted); }
.tpl em { font-size: .8rem; margin-top: 6px; }
.tpl input:checked + span { border-color: var(--navy); background: #eef5fb; }
.tpl input:focus-visible + span { outline: 2px solid #7fb6e0; }

.rules { display: flex; flex-direction: column; gap: 10px; }
.rule { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.rule.off { background: #f8f9fb; }
.rule.off .rule-head b { color: var(--muted); }
.rule-head { display: flex; gap: 12px; align-items: flex-start; }
.rule-head > div { flex: 1; min-width: 0; }
.rule-head b { display: block; }
.rule-head small { color: var(--muted); display: block; }
.rule details { margin-top: 8px; }
.rule summary { cursor: pointer; color: var(--muted); font-size: .88rem; list-style: none; }
.rule summary::-webkit-details-marker { display: none; }
.rule-body { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 10px; }
.pri { font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; color: #fff; }
.pri.P1 { background: var(--p1); } .pri.P2 { background: var(--p2); } .pri.P3 { background: var(--p3); } .pri.P4 { background: var(--p4); }
.switch { position: relative; width: 44px; height: 26px; flex: none; margin-top: 2px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c9d1da; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }

.status { display: flex; gap: 10px; align-items: flex-start; }
.status small { display: block; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex: none; }
.dot.wait { background: #e0a73a; }
.sop { white-space: pre-wrap; background: #f8f9fb; border-radius: 10px; padding: 12px; }

.pinbox { background: #f3f8fc; border: 1px solid #cfe1ef; border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.pinbox code { overflow-wrap: anywhere; background: #fff; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); }
.pinbox code.big { font-size: 1.4rem; letter-spacing: 3px; font-weight: 700; }
.pinbox small { color: var(--muted); }

.table { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8f9fb; }
