:root { --brand: #1a56db; --brand-dark: #0b2a5b; --bg: #f4f6fa; --line: #e3e7ee; --muted: #6b7280; --ok: #047857; --bad: #b91c1c; }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: #1f2937; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; color: var(--brand-dark); }
h2 { font-size: 16px; margin: 0 0 10px; color: var(--brand-dark); }
.sub { color: var(--muted); margin: 0 0 18px; }

.side { position: fixed; inset: 0 auto 0 0; width: 220px; background: var(--brand-dark); color: #cbd5e1; display: flex; flex-direction: column; z-index: 5; }
.side .logo { color: #fff; font-weight: 800; letter-spacing: .5px; padding: 20px 18px 16px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side .logo small { display: block; font-weight: 400; color: #93a4c3; letter-spacing: 0; font-size: 12px; margin-top: 2px; }
.side nav { padding: 10px 8px; flex: 1; }
.side nav a { display: flex; gap: 10px; align-items: center; color: #cbd5e1; padding: 9px 12px; border-radius: 6px; margin-bottom: 2px; }
.side nav a span { width: 18px; text-align: center; opacity: .8; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a.on { background: var(--brand); color: #fff; }
.side .me { padding: 14px 18px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side .me a { color: #93c5fd; }
main.with-side { margin-left: 220px; padding: 26px 32px 60px; max-width: 1280px; }
main.plain { max-width: 420px; margin: 8vh auto; padding: 0 16px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--brand); border-radius: 8px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; color: var(--brand-dark); }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }

label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd6e1; border-radius: 6px; font: inherit; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid #cfd6e1; background: #fff; color: #1f2937; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { filter: brightness(.95); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }

table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); font-weight: 600; }
table.list td { padding: 9px 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
table.list tr:hover td { background: #fafbfd; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.st-draft { background: #fef3c7; color: #92400e; }
.st-final { background: #dbeafe; color: #1e40af; }
.st-sent { background: #d1fae5; color: #065f46; }
.st-none { background: #f3f4f6; color: #6b7280; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.warn ul { margin: 4px 0 0; padding-left: 18px; }

/* editor */
.sec-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.sec-card.hidden-sec { opacity: .6; border-style: dashed; }
.sec-head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; border-radius: 10px 10px 0 0; }
.sec-head .type { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); background: #eef2f7; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.sec-head input.title { font-weight: 700; color: var(--brand-dark); border-color: transparent; background: transparent; }
.sec-head input.title:hover, .sec-head input.title:focus { border-color: #cfd6e1; background: #fff; }
.sec-body { padding: 14px; }
.sec-body.collapsed { display: none; }
.ed-table { width: 100%; border-collapse: collapse; }
.ed-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); text-align: left; padding: 4px 4px; font-weight: 600; }
.ed-table td { padding: 3px 4px; }
.ed-table input { padding: 5px 7px; }
.ed-table .n { width: 80px; }
.ed-table .x { width: 34px; text-align: center; }
.mv { font-size: 11px; font-weight: 700; white-space: nowrap; }
.mv.up { color: var(--ok); } .mv.down, .mv.lost { color: var(--bad); } .mv.new { color: var(--brand); } .mv.hold { color: var(--muted); }
.kwscroll { max-height: 520px; overflow: auto; border: 1px solid #f0f2f6; border-radius: 6px; }
.kwscroll thead th { position: sticky; top: 0; background: #fff; z-index: 1; }
.imgs { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.imgs figure { margin: 0; width: 180px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #fafbfd; }
.imgs img { width: 100%; height: 110px; object-fit: cover; border-radius: 4px; display: block; }
.imgs input[type=text] { margin-top: 5px; font-size: 12px; padding: 4px 6px; }
.imgs .check { font-size: 11px; color: var(--bad); }
.sticky-bar { position: sticky; bottom: 0; background: rgba(244,246,250,.96); padding: 12px 0; display: flex; gap: 8px; border-top: 1px solid var(--line); z-index: 4; backdrop-filter: blur(4px); }
.paste { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px; margin-top: 10px; }
.paste textarea { min-height: 80px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.minibar { display: inline-block; vertical-align: middle; }
details summary { cursor: pointer; font-weight: 600; color: var(--brand); }

/* report preview */
.preview-wrap { background: #e5e7eb; padding: 26px; border-radius: 10px; }
.preview-page { background: #fff; max-width: 820px; margin: 0 auto; padding: 44px 48px; box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.preview-page .rpt img { max-width: 100%; }
.share-top { background: var(--brand-dark); color: #fff; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; }
.share-top a { color: #fff; }

@media (max-width: 900px) {
  .side { position: static; width: auto; }
  .side nav { display: flex; flex-wrap: wrap; }
  main.with-side { margin-left: 0; padding: 16px; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .preview-page { padding: 20px; }
  .preview-wrap { padding: 8px; }
}
@media print {
  .side, .toolbar, .no-print, .warn, .flash { display: none !important; }
  main.with-side { margin: 0; padding: 0; }
  .preview-wrap { background: none; padding: 0; }
  .preview-page { box-shadow: none; padding: 0; max-width: none; }
}
.no-city .city-col { display: none; }
