:root {
  --bg: #f3f5fa; --card: #ffffff; --line: #e3e7f0; --text: #24304a; --strong: #14223e;
  --muted: #778299; --accent: #615bd1; --accent-hover: #5049bd; --accent-soft: #efedfc;
  --side: #111c34; --side-text: #aebbd4; --side-active: #2b3653; --ok: #22836c; --warn: #ad6831;
  --bad: #b3413b; --radius: 12px; --sidebar: 248px;
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---- top bar + hamburger ---- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  height: 58px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.hamburger { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 9px; background: var(--card);
  display: grid; place-content: center; gap: 5px; cursor: pointer; padding: 0; }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--strong); border-radius: 2px;
  transition: transform .2s, opacity .2s; }
body.menu-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.menu-open .hamburger span:nth-child(2) { opacity: 0; }
body.menu-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.topbar .title { font-weight: 700; color: var(--strong); font-size: 1.05rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { background: #e5f3ef; color: #217c67; border-radius: 12px; padding: 5px 12px; font-size: .75rem;
  font-weight: 700; white-space: nowrap; }

/* ---- sidebar ---- */
.sidebar { position: fixed; top: 58px; bottom: 0; left: 0; width: var(--sidebar); z-index: 25;
  background: var(--side); color: var(--side-text); padding: 22px 14px; display: flex; flex-direction: column;
  gap: 6px; transform: translateX(-100%); transition: transform .22s ease; overflow-y: auto; }
body.menu-open .sidebar { transform: none; }
.brand { color: #fff; font-size: 1.45rem; font-weight: 700; padding: 0 10px; }
.brand-sub { color: #97a7c9; font-size: .78rem; padding: 0 10px 18px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0;
  background: transparent; color: #f4f0ff; padding: 12px 12px; border-radius: 9px; cursor: pointer;
  font-weight: 600; }
.nav-item:hover { background: #1d2944; }
.nav-item.active { background: var(--side-active); }
.nav-item .icon { width: 22px; text-align: center; opacity: .9; }
.nav-sep { height: 1px; background: #26314d; margin: 12px 6px; }
.nav-danger { color: #ffb4ae; }
.side-note { margin-top: auto; font-size: .78rem; line-height: 1.5; padding: 0 10px; }
.backdrop { position: fixed; inset: 58px 0 0 0; background: rgba(8, 14, 30, .45); z-index: 20; display: none; }

main { padding: 26px 30px 60px; transition: margin-left .22s ease; max-width: 1400px; }
@media (min-width: 1000px) {
  body.menu-open main { margin-left: var(--sidebar); }
}
@media (max-width: 999px) {
  body.menu-open .backdrop { display: block; }
  main { padding: 18px 16px 50px; }
}

/* ---- content ---- */
.eyebrow { color: #747e97; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
h1 { color: var(--strong); font-size: 1.9rem; margin: 4px 0 4px; }
h2 { color: var(--strong); font-size: 1.1rem; margin: 0 0 12px; }
h3 { color: var(--strong); font-size: .98rem; margin: 16px 0 8px; }
.muted { color: var(--muted); font-size: .88rem; line-height: 1.5; }
.hero { border-radius: 13px; color: #fff; padding: 18px 22px; margin: 18px 0;
  background: linear-gradient(135deg, #5255bc, #7973d7); }
.hero strong { display: block; font-size: 1.15rem; margin-bottom: 4px; }
.grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1100px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: .74rem; font-weight: 700;
  color: #747e97; letter-spacing: .04em; text-transform: uppercase; }
label.check, label.radio { display: flex; gap: 9px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: #fafbfe; border: 1px solid #dce1ed; border-radius: 7px; padding: 9px 10px;
  text-transform: none; letter-spacing: normal; font-weight: 400; font-size: .92rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8b3ef; border-color: #827cdb; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); margin-top: 3px; }
.btn { background: #fff; color: #46516e; border: 1px solid #dce1ed; border-radius: 8px; padding: 9px 15px;
  font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #f0eefc; border-color: #b2abe3; }
.btn:disabled { color: #a3abbd; background: #edf0f6; border-color: #e5e8ee; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; border: 0; padding: 11px 18px; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { background: #b3b0df; }
.btn.quiet { border: 0; background: transparent; color: #81799c; }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.drop { border: 2px dashed #c9cde0; border-radius: 12px; padding: 22px; text-align: center; cursor: pointer;
  background: #fafbfe; transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { color: var(--strong); }
.file-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.file-list li { display: flex; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid #edf0f6; font-size: .9rem; }
.file-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 6px; border-radius: 3px; background: #e4e7f0; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: #7770da; transition: width .3s; }
.status { font-size: .88rem; color: var(--muted); }
.status.error { color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.stat b { display: block; font-size: 1.6rem; color: #28365b; }
.stat span { color: #7a849b; font-size: .82rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { background: #f7f8fc; color: #8891a5; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  text-align: left; padding: 9px 8px; }
td { padding: 8px; border-bottom: 1px solid #edf0f6; vertical-align: top; overflow-wrap: anywhere; }
.tag { border-radius: 10px; padding: 2px 9px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.tag.ok { background: #e5f3ef; color: var(--ok); }
.tag.warn { background: #fbefe4; color: var(--warn); }
.tag.bad { background: #fbe7e6; color: var(--bad); }
.log { background: #fafbfe; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  font: .8rem/1.55 ui-monospace, Consolas, monospace; color: #55607a; max-height: 300px; overflow: auto;
  white-space: pre-wrap; margin: 0; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 18px; }
.step { padding: 6px 12px; border-radius: 20px; background: #e9ecf4; color: #7a849b; font-size: .82rem; font-weight: 600; }
.step.active { background: var(--accent); color: #fff; }
.step.done { background: #e5f3ef; color: var(--ok); }

/* ---- PDF viewer + crop ---- */
.viewer { position: relative; display: inline-block; max-width: 100%; user-select: none; touch-action: none;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.viewer img { display: block; max-width: 100%; height: auto; pointer-events: none; }
.viewer.cropping { cursor: crosshair; }
.selection { position: absolute; border: 2px solid var(--accent); background: rgba(97, 91, 209, .14);
  box-shadow: 0 0 0 9999px rgba(15, 20, 40, .35); }
.viewer-wrap { max-height: 78vh; overflow: auto; text-align: center; background: #e9ecf4; border-radius: 9px; padding: 10px; }

/* ---- dialog ---- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(980px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(10, 20, 50, .3); }
dialog::backdrop { background: rgba(8, 14, 30, .5); }
.dialog-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.dialog-head h2 { margin: 0; flex: 1; }
.dialog-body { padding: 16px 20px; overflow-y: auto; max-height: calc(100vh - 170px); }
.dialog-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 6px 16px; }
.choice-value { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumbs img { max-height: 110px; max-width: min(200px, 100%); border: 1px solid var(--line); border-radius: 6px; }
.preview-text { max-height: 160px; }
.mini-table td, .mini-table th { padding: 4px 6px; font-size: .8rem; }
.review-page { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }
.notice { background: #fff7ec; border: 1px solid #f2dcc0; color: #7a4b1c; border-radius: 9px; padding: 10px 12px; font-size: .88rem; }
.login { max-width: 380px; margin: 10vh auto; }
.mt { margin-top: 18px; }
.field.wide { min-width: 240px; }
.review-grid td { padding: 4px; min-width: 150px; }
.review-grid td:first-child { min-width: 140px; font-weight: 600; }
.review-grid td:nth-child(2) { min-width: 0; }
.cell-input { min-width: 140px; padding: 6px 8px !important; }
.text-review { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; }
.text-review summary { cursor: pointer; font-weight: 600; }
.text-review textarea { margin-top: 8px; font: .85rem/1.5 ui-monospace, Consolas, monospace; }
.side-link { color: #ffb3d6; text-decoration: none; font-weight: 600; }
.side-link:hover { text-decoration: underline; }
select { max-width: 100%; }
.dialog-body { overflow-x: hidden; }
label.check > span, label.radio > span { min-width: 0; overflow-wrap: anywhere; }
