:root {
  --bg: #f3f5f9;
  --card: #fff;
  --text: #1b2333;
  --muted: #6b7280;
  --line: #e2e6ee;
  --primary: #1f5fa8;
  --primary-dk: #17487f;
  --navy: #1f2a44;
  --error: #b42318;
  --error-bg: #fdecea;
  --warning: #9a5b00;
  --warning-bg: #fff4e0;
  --info: #4b5563;
  --info-bg: #eef0f3;
  --ok: #1a7f37;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* top bar + tabs */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 62px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 800; }
.brand-t { font-weight: 700; font-size: 16px; }
.brand-s { font-size: 12px; opacity: .7; }
.tabs { display: flex; gap: 4px; background: rgba(255,255,255,.08); padding: 4px; border-radius: 10px; }
.tab { font: inherit; font-size: 14px; color: #dfe6f3; background: none; border: 0; padding: 7px 14px; border-radius: 7px; cursor: pointer; }
.tab:hover { color: #fff; background: rgba(255,255,255,.08); }
.tab.active { background: #fff; color: var(--navy); font-weight: 600; }

main.wrap { padding-top: 22px; padding-bottom: 60px; }
.page-head { margin-bottom: 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 23px; }
.page-head p { margin: 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 16px; border: 2px dashed #c3c9d3; border-radius: 10px; cursor: pointer; text-align: center; transition: background .15s, border-color .15s; }
.drop:hover, .drop.over { background: #f0f5ff; border-color: var(--primary); }
.status { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--info-bg); }
.status.err { background: var(--error-bg); color: var(--error); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.counts { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.chip.error { color: var(--error); }
.chip.warning { color: var(--warning); }
.chip.info { color: var(--info); }
.chip.active { outline: 2px solid var(--primary); outline-offset: 1px; }
.ok { padding: 10px 12px; border-radius: 8px; background: #e7f6ec; color: var(--ok); margin-bottom: 10px; }
.table-wrap { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; background: #f9fafb; font-weight: 600; z-index: 1; }
td.cell { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; white-space: nowrap; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: uppercase; }
.badge.error { background: var(--error-bg); color: var(--error); }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.info { background: var(--info-bg); color: var(--info); }
.sheets { list-style: none; padding: 0; margin: 0; columns: 3 220px; }
.sheets li { padding: 3px 0; break-inside: avoid; }
.sheets .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.options { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.options input[type=text] { margin-left: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; width: 300px; font: inherit; }
.actions { display: flex; gap: 10px; }
button.primary, button.secondary { font: inherit; padding: 9px 18px; border-radius: 8px; cursor: pointer; border: 1px solid var(--primary); font-weight: 500; }
button.primary { background: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dk); }
button.secondary { background: #fff; color: var(--primary); }
button.secondary:hover { background: #f0f5ff; }
button.sm { padding: 6px 12px; font-size: 13.5px; }
button:disabled { opacity: .6; cursor: progress; }
button.link { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

/* MoU form */
.saved { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.saved select { font: inherit; font-size: 13.5px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 220px; max-width: 320px; }
.sec-h { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.sec-h p { margin: 2px 0 0; }
.num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #e8f0fb; color: var(--primary); font-weight: 700; display: grid; place-items: center; font-size: 14px; }
details summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details summary::-webkit-details-marker { display: none; }
details[open] summary .muted.small:first-of-type { display: none; }
h3.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 20px 0 10px; padding-top: 14px; border-top: 1px dashed var(--line); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.span2 { grid-column: span 2; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #374151; }
.f i { color: var(--error); font-style: normal; }
.f input, .f select { font: inherit; font-size: 14px; font-weight: 400; padding: 8px 10px; border: 1px solid #d3d9e3; border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
.f input:focus, .f select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,95,168,.15); }
.f.bad input { border-color: var(--error); background: #fff8f7; }
.combo { display: flex; }
.combo select { width: 78px; flex: none; border-radius: 8px 0 0 8px; border-right: 0; }
.combo input { border-radius: 0 8px 8px 0; }
.actionbar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; background: rgba(243,245,249,.95); backdrop-filter: blur(4px); padding: 12px 0; border-top: 1px solid var(--line); margin-top: 4px; }
.msg { margin-right: auto; font-size: 13.5px; }
.msg.err { color: var(--error); }
.msg.ok { color: var(--ok); background: none; padding: 0; margin-bottom: 0; }

@media (max-width: 820px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
