:root {
  --navy: #2e3a70; --navy-dark: #1f274c; --blue: #0053a3; --orange: #ffa800; --orange-deep: #ef5e34;
  --bg: #f4f6fa; --card: #ffffff; --ink: #1f274c; --muted: #5d6478; --line: #dde2ec; --ok: #1f8a4c; --warn: #b7791f; --bad: #b42318;
  --radius: 10px; --shadow: 0 1px 2px rgba(31,39,76,.06), 0 4px 16px rgba(31,39,76,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue); }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--navy-dark), var(--navy) 55%, var(--blue)); }
.login-card { background: var(--card); border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--navy); }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card .brandbar { height: 6px; width: 64px; background: var(--orange); border-radius: 3px; margin-bottom: 20px; }
.login-card input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.login-card button { width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 8px; background: var(--navy); color: #fff; font-weight: 600; font-size: 16px; }
.login-card button:hover { background: var(--navy-dark); }
.login-card .err { color: var(--bad); margin-top: 10px; min-height: 22px; }
.login-card .foot { margin-top: 18px; font-size: 12px; color: var(--muted); }

/* ---------- app shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; display: flex; align-items: center; gap: 16px; padding: 10px 20px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topbar .title { font-weight: 700; font-size: 16px; white-space: nowrap; }
.topbar .title small { display: block; font-weight: 400; font-size: 11px; opacity: .8; }
.topbar .spacer { flex: 1; }
.topbar .overall { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar .bar { width: 160px; height: 8px; background: rgba(255,255,255,.2); border-radius: 4px; overflow: hidden; }
.topbar .bar i { display: block; height: 100%; background: var(--orange); transition: width .3s; }
.topbar .save { font-size: 12px; opacity: .85; min-width: 110px; text-align: right; }
.topbar .save.saving { color: var(--orange); }
.topbar .save.error { color: #ffb4a8; }
.topbar .badge { font-size: 11px; padding: 3px 8px; border-radius: 10px; background: rgba(255,255,255,.15); text-transform: uppercase; letter-spacing: .04em; }
.topbar .badge.admin { background: var(--orange); color: var(--navy-dark); font-weight: 700; }
.topbar button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 5px 10px; font-size: 13px; }
.topbar button:hover { background: rgba(255,255,255,.12); }
.topbar .menu-btn { display: none; }

.layout { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 52px); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto; }
.sidebar .nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: transparent; border-radius: 8px; color: var(--ink); }
.sidebar .nav-item:hover { background: var(--bg); }
.sidebar .nav-item.active { background: #e9eef8; color: var(--navy); font-weight: 600; }
.sidebar .nav-item .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--bg); color: var(--muted); flex: none; }
.sidebar .nav-item.complete .num { background: var(--ok); color: #fff; }
.sidebar .nav-item.partial .num { background: var(--orange); color: var(--navy-dark); }
.sidebar .nav-item .lbl { flex: 1; font-size: 14px; }
.sidebar .nav-item .cnt { font-size: 11px; color: var(--muted); }
.sidebar .sep { height: 1px; background: var(--line); margin: 10px 4px; }
.sidebar .nav-item.admin-link { color: var(--orange-deep); }

.main { padding: 28px 36px 80px; max-width: 900px; width: 100%; }

/* ---------- overview ---------- */
.hero { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 30px; margin-bottom: 20px; border-top: 5px solid var(--orange); }
.hero h1 { margin: 0 0 6px; color: var(--navy); font-size: 26px; }
.hero p { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.hero ul { margin: 8px 0 0 18px; padding: 0; color: var(--ink); }
.hero li { margin: 4px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.scard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border: 1px solid transparent; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.scard:hover { border-color: var(--blue); }
.scard .h { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--navy); }
.scard .owner { font-size: 12px; color: var(--muted); }
.scard .pbar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.scard .pbar i { display: block; height: 100%; background: var(--blue); }
.scard.complete .pbar i { background: var(--ok); }
.scard .pct { font-size: 12px; color: var(--muted); }

/* ---------- section ---------- */
.sec-head { margin-bottom: 18px; }
.sec-head .crumb { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sec-head h1 { margin: 2px 0 6px; color: var(--navy); font-size: 26px; }
.sec-head .intro { color: var(--muted); margin: 0 0 8px; }
.sec-head .owner { font-size: 13px; color: var(--ink); background: #fff6e0; display: inline-block; padding: 3px 10px; border-radius: 12px; border: 1px solid #ffe2a3; }
.sec-status { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #e3f5ea; color: var(--ok); }
.pill.warn { background: #fff6e0; color: var(--warn); }
.pill.muted { background: var(--bg); color: var(--muted); }

.field { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 12px; }
.field.info { background: #eef3fb; box-shadow: none; border-left: 4px solid var(--blue); }
.field.info .lbl { color: var(--blue); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.field.info p { margin: 0; color: var(--ink); font-size: 14px; }
.field .lbl { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; flex-wrap: wrap; }
.field .lbl .req { color: var(--orange-deep); font-weight: 700; }
.field .lbl .lock { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 10px; }
.field .help { font-size: 13px; color: var(--muted); margin: -2px 0 8px; }
.field input[type=text], .field input[type=email], .field input[type=tel], .field input[type=url], .field input[type=date], .field input[type=number], .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.field .money { display: flex; align-items: center; gap: 6px; }
.field .money span { color: var(--muted); }
.field .opts { display: flex; flex-direction: column; gap: 6px; }
.field .opt { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.field .opt:hover { border-color: var(--blue); background: #f8faff; }
.field .opt input { margin-top: 3px; }
.field .opt.checked { border-color: var(--blue); background: #eef3fb; }
.clear-link { display: inline-block; margin-top: 6px; border: 0; background: none; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 2px 0; }
.clear-link:hover { color: var(--bad); }
.field .suggest { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.field .suggest .chip { background: #fff6e0; color: var(--warn); border: 1px solid #ffe2a3; padding: 2px 8px; border-radius: 10px; font-weight: 600; font-size: 12px; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-dark); color: #fff; }
.btn.orange { background: var(--orange); color: var(--navy-dark); border-color: var(--orange); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.field .meta { font-size: 11px; color: var(--muted); margin-top: 8px; }
.field .masked { display: flex; align-items: center; gap: 10px; }
.field .masked code { font-size: 15px; background: var(--bg); padding: 6px 10px; border-radius: 6px; letter-spacing: .1em; }
.field .revealed { background: #fff6e0; border: 1px solid #ffe2a3; padding: 8px 10px; border-radius: 8px; margin-top: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 14px; word-break: break-all; }

/* repeater */
.rep-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: #fbfcfe; }
.rep-item .rep-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.rep-item .sub { margin-bottom: 10px; }
.rep-item .sub label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.rep-item .sub .lock { font-size: 10px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.rep-item .sub .opts { gap: 4px; }
.rep-item .sub .opt { padding: 5px 8px; font-size: 13px; }

/* files */
.files-list { list-style: none; padding: 0; margin: 8px 0 0; }
.files-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.files-list li:last-child { border-bottom: 0; }
.files-list .sz { color: var(--muted); }
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-row input[type=file] { font-size: 13px; }
.upload-status { font-size: 12px; color: var(--muted); }

.sec-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; padding: 18px 20px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); flex-wrap: wrap; }
.sec-foot .left { font-size: 13px; color: var(--muted); }
.sec-foot .right { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- admin ---------- */
.admin-grid { display: grid; gap: 12px; }
.admin-row { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.admin-row .t { font-weight: 600; color: var(--navy); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin-row .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.admin-row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.admin-row textarea { width: 100%; margin-top: 8px; min-height: 48px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; }
.admin-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 20px; }
.activity { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.activity li { padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 13px; display: grid; grid-template-columns: 150px 60px 80px 1fr; gap: 10px; }
.activity li:last-child { border-bottom: 0; }
.activity .ts { color: var(--muted); font-variant-numeric: tabular-nums; }
.activity .who { font-weight: 600; text-transform: uppercase; font-size: 11px; color: var(--blue); }
.activity .who.admin { color: var(--orange-deep); }
.activity .act { color: var(--muted); }
.activity .det { word-break: break-word; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; color: var(--navy); }
.stat span { font-size: 12px; color: var(--muted); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy-dark); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 52px; width: 280px; transform: translateX(-100%); transition: transform .2s; z-index: 15; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .topbar { gap: 8px; padding: 10px 12px; }
  .topbar .menu-btn { display: inline-block; }
  .topbar .title { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar .title small { display: none; }
  .topbar .overall span:first-child { display: none; }
  .topbar .overall .bar { width: 60px; }
  .topbar .save, .topbar .badge { display: none; }
  .topbar button { padding: 5px 8px; font-size: 12px; white-space: nowrap; }
  .hero, .field { padding: 16px; }
  .sec-foot .right { width: 100%; }
  .sec-foot .right .btn { flex: 1; }
  .main { padding: 18px 16px 80px; }
  .activity li { grid-template-columns: 1fr; gap: 2px; }
  .admin-row { grid-template-columns: 1fr; }
}
@media print { .topbar, .sidebar, .sec-foot { display: none; } .layout { display: block; } }
