.brand-bar { padding-bottom: 26px; }
.top { display: flex; align-items: center; gap: 16px; max-width: 1600px; margin: 0 auto; }
.top .title { flex: 1; font-size: 22px; font-weight: 800; color: var(--yellow); }
.top .btn { min-height: 40px; }
main { max-width: 1600px; margin: -10px auto 0; padding: 0 16px 40px; }
.tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 4px solid var(--green); margin-bottom: 16px; }
.tabs button { border: 2px solid var(--ink); border-bottom: 0; background: var(--paper); padding: 10px 18px; font-weight: 700; cursor: pointer; margin-right: 4px; }
.tabs button[aria-selected="true"] { background: var(--green); color: var(--yellow); border-color: var(--green-dark); }
.card { background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow); padding: 16px; margin-bottom: 18px; }
.login { max-width: 380px; margin: 40px auto; }
.field { display: grid; gap: 4px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea, .tool input, .tool select { border: 2px solid var(--ink); padding: 8px 10px; background: #fff; min-height: 40px; font-weight: 400; width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tool { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.tool input[type=search] { width: 220px; }
.tool select { width: auto; }
.btn.sm { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.err { color: var(--red); font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }

/* Matrix */
.mwrap { overflow: auto; border: 2px solid var(--ink); background: var(--paper); max-height: 74vh; }
table.m { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.m th, .m td { border-bottom: 1px solid #c8d0cb; border-right: 1px solid #e0e5e2; padding: 4px 6px; vertical-align: middle; background: var(--paper); }
.m thead th { position: sticky; top: 0; z-index: 3; background: var(--green); color: #fff; text-align: center; font-size: 12px; padding: 6px 4px; border-right: 1px solid var(--green-dark); }
.m thead th.nm { text-align: left; }
.m td.stick, .m th.stick { position: sticky; left: 0; z-index: 2; }
.m thead th.stick { z-index: 4; }
.m td.stick { background: #fff; border-right: 2px solid var(--ink); min-width: 190px; max-width: 230px; }
.m .name { font-weight: 700; cursor: pointer; text-decoration: underline; text-decoration-color: var(--yellow-dark); text-underline-offset: 3px; background: none; border: 0; padding: 0; text-align: left; }
.m .sub { color: var(--muted); font-size: 12px; }
.m th.cl { min-width: 84px; cursor: help; }
.m th.cl .n { display: block; font-size: 16px; color: var(--yellow); font-weight: 900; }
.m th.cl .s { display: block; font-weight: 400; font-size: 10px; line-height: 1.1; max-width: 90px; margin: 0 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell { display: block; width: 100%; min-height: 44px; border: 2px solid transparent; background: transparent; cursor: pointer; padding: 2px; font-size: 11px; line-height: 1.25; text-align: center; }
.cell.empty { color: #b8c2bc; font-size: 18px; border: 1px dashed #c8d0cb; }
.cell.empty:hover { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.cell.s-ok { background: #d7ecdf; border-color: var(--green); }
.cell.s-due { background: #fdf3a6; border-color: var(--yellow-dark); }
.cell.s-new { background: #fff7c2; border-color: var(--yellow-dark); border-style: dashed; }
.cell.s-overdue { background: #f7c9c5; border-color: var(--red); }
.cell b { display: block; font-size: 11px; }
.cell .live { display: inline-block; width: 8px; height: 8px; background: var(--green); margin-left: 3px; transform: rotate(45deg); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; margin: 8px 0 12px; align-items: center; }
.legend i { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; border: 2px solid; }
.m td.c { text-align: center; }
.m td select { border: 1px solid var(--ink); padding: 3px; background: #fff; font-size: 13px; }
.sw { width: 20px; height: 20px; accent-color: var(--green); }
.due-red { color: var(--red); font-weight: 800; }

/* Cluster */
details.cluster { border: 2px solid var(--ink); background: var(--paper); margin-bottom: 10px; }
details.cluster > summary { cursor: pointer; padding: 10px 14px; font-weight: 800; display: flex; gap: 10px; align-items: center; list-style: none; }
details.cluster > summary::-webkit-details-marker { display: none; }
details.cluster > summary::before { content: "▸"; color: var(--green); }
details.cluster[open] > summary::before { content: "▾"; }
details.cluster[open] > summary { background: var(--green-soft); border-bottom: 2px solid var(--ink); }
.nrbox { background: var(--green); color: var(--yellow); min-width: 30px; text-align: center; font-weight: 900; padding: 1px 6px; }
.cbody { padding: 14px; }
.cbody h4 { margin: 14px 0 6px; color: var(--green-dark); }
.q { border-left: 6px solid var(--green); padding: 6px 12px; margin: 8px 0; background: #f7f9f7; }
.q ol { margin: 4px 0 4px 20px; padding: 0; list-style: upper-alpha; }
.q li.ok { font-weight: 800; color: var(--green-dark); }
.q li.ok::marker { color: var(--green); }
.q .ex { font-size: 13px; color: var(--muted); }
.cbody ul { margin: 4px 0 8px 18px; padding: 0; }
.langtabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0 10px; }
.langtabs button { border: 2px solid var(--ink); background: #fff; padding: 4px 10px; cursor: pointer; font-weight: 700; }
.langtabs button[aria-pressed="true"] { background: var(--yellow); box-shadow: 2px 2px 0 var(--green); }
.bar { height: 14px; border: 2px solid var(--ink); background: #fff; min-width: 120px; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--green); }
table.t { border-collapse: collapse; width: 100%; font-size: 14px; }
.t th { background: var(--green); color: #fff; text-align: left; padding: 6px 8px; }
.t td { border-bottom: 1px solid #c8d0cb; padding: 6px 8px; }

dialog { border: 3px solid var(--ink); box-shadow: 8px 8px 0 var(--green); padding: 0; width: min(640px, 96vw); max-height: 92vh; background: var(--paper); }
dialog::backdrop { background: rgba(0, 40, 28, .55); }
.dh { background: var(--green); color: #fff; padding: 12px 16px; font-weight: 800; font-size: 18px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dh button { background: var(--yellow); border: 2px solid var(--ink); width: 36px; height: 36px; font-weight: 900; cursor: pointer; }
.db { padding: 16px; overflow: auto; max-height: calc(92vh - 60px); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } .tool input[type=search] { width: 100%; } }
.linkbox { display: flex; gap: 6px; flex-wrap: wrap; }
.linkbox input { flex: 1; min-width: 200px; font-size: 13px; }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--ink); color: #fff; padding: 10px 16px; border-left: 8px solid var(--yellow); z-index: 100; }

/* Editor */
.editor h3 { margin: 18px 0 8px; color: var(--green-dark); }
.ecols { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 18px; margin-bottom: 14px; align-items: start; }
.ecard { max-width: 560px; }
.ehead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ehead .kicker { font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; color: var(--green); }
.ecard .panel { background: #fff; border: 2px solid var(--ink); box-shadow: var(--shadow); padding: 14px; }
.ed { outline: 0; min-height: 1.4em; padding: 3px 4px; border: 1px dashed transparent; overflow-wrap: anywhere; white-space: pre-wrap; }
.ed:hover { border-color: #9db3a8; }
.ed:focus { border-color: var(--green); background: #f4faf7; }
.ed:empty::before { content: attr(data-ph); color: #8a9a92; }
.ecard h2.ed { font-size: 21px; margin: 0 0 8px; font-weight: 700; }
.eblock { display: flex; gap: 6px; align-items: flex-start; margin: 4px 0; }
.eblock > .ed, .eblock > figure { flex: 1; min-width: 0; }
.ed.li { position: relative; padding-left: 26px; font-size: 16px; }
.ed.li::after { content: ""; position: absolute; left: 6px; top: .6em; width: 9px; height: 9px; background: var(--green); transform: rotate(45deg); }
.ed.note { background: var(--yellow); border: 2px solid var(--ink); border-left: 10px solid var(--green); padding: 8px 10px; font-weight: 700; }
.etools { display: inline-flex; gap: 2px; flex-wrap: wrap; align-items: center; opacity: .55; }
.eblock:hover .etools, .eopt:hover .etools, .ehead .etools, .etools:focus-within { opacity: 1; }
.etools button { border: 1px solid var(--ink); background: #fff; min-width: 26px; height: 26px; padding: 0 6px; cursor: pointer; font-size: 12px; font-weight: 700; }
.etools button.del:hover { background: var(--red); color: #fff; }
.eadd { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fig img { max-width: 100%; display: block; border: 2px solid var(--ink); }
.fig .cap { font-size: 13px; color: var(--muted); }
.fig.sm img { max-height: 90px; width: auto; border-width: 1px; }
.noimg { background: #eee; border: 2px dashed #999; padding: 20px; text-align: center; color: var(--muted); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.qthumb { max-height: 70px; vertical-align: middle; border: 1px solid var(--ink); margin: 2px 6px 2px 0; }
.eopt { display: grid; grid-template-columns: auto 28px 1fr auto; gap: 6px; align-items: center; border: 2px solid var(--ink); background: #fff; margin: 6px 0; padding: 4px 6px; }
.eopt.right { background: #d7ecdf; border-color: var(--green); }
.eopt .letter { background: var(--green-soft); border: 1px solid var(--ink); text-align: center; font-weight: 900; padding: 2px 0; }
.eopt .otext img { max-width: 160px; max-height: 100px; display: block; border: 1px solid var(--ink); }
.eopt .rad { display: flex; }
.ed.qtext { font-size: 18px; font-weight: 700; }
.explainbox { margin-top: 12px; border-top: 1px dashed var(--muted); padding-top: 8px; font-size: 14px; }
.imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.imgpick { border: 2px solid var(--ink); background: #fff; padding: 0; cursor: pointer; height: 100px; }
.imgpick:hover { border-color: var(--green); box-shadow: 3px 3px 0 var(--yellow-dark); }
.imgpick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.notei { color: var(--orange); font-weight: 700; }
.smsnote { background: var(--yellow); border: 2px solid var(--ink); padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.smsnote ul { margin: 6px 0 0 18px; padding: 0; }
.m .sub.err { color: var(--red); }
dialog#dlg2 { border: 3px solid var(--ink); box-shadow: 8px 8px 0 var(--green); padding: 0; width: min(760px, 96vw); max-height: 92vh; background: var(--paper); }
dialog#dlg2::backdrop { background: rgba(0, 40, 28, .55); }

.eblock figure img { width: 100%; }

label.row { flex-wrap: nowrap; align-items: flex-start; }
.eblock { position: relative; }
.eblock .etools { position: absolute; right: 0; top: -14px; z-index: 2; background: #fff; border: 1px solid var(--ink); padding: 1px; display: none; opacity: 1; }
.eblock:hover .etools, .eblock:focus-within .etools { display: inline-flex; }
