:root {
  --red: #e1251b;
  --red-dark: #b81c14;
  --red-soft: #fdecea;
  --ink: #1f2430;
  --ink-2: #4b5363;
  --muted: #7a8394;
  --line: #e4e7ec;
  --bg: #f4f5f7;
  --card: #ffffff;
  --green: #1a7f4b; --green-soft: #e3f5ec;
  --amber: #a15c00; --amber-soft: #fff3dc;
  --blue: #1d5fbf; --blue-soft: #e5efff;
  --gray-soft: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; background: linear-gradient(to right, #fff 249px, var(--line) 249px 250px, var(--bg) 250px); }
.sidebar { background: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; background: #fff; }
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--gray-soft); text-decoration: none; }
.nav a.active { background: var(--red-soft); color: var(--red-dark); }
.nav a.locked { color: var(--muted); }
.nav a.locked .lock { margin-left: auto; width: 14px; height: 14px; }
.sidebar-foot { margin-top: auto; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 24px; gap: 12px; position: sticky; top: 0; z-index: 5; }
.topbar .crumbs { color: var(--muted); }
.topbar .crumbs b { color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; background: #fff; font: inherit; color: inherit; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.menu { position: absolute; right: 24px; top: 52px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 180px; padding: 6px; z-index: 20; }
.menu button { display: flex; width: 100%; gap: 8px; align-items: center; padding: 8px 10px; border: 0; background: none; font: inherit; border-radius: 6px; cursor: pointer; color: var(--ink); }
.menu button:hover { background: var(--gray-soft); }
.content { padding: 24px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn.menu-toggle { display: none; }

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head .actions { margin-left: auto; }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--gray-soft); text-decoration: none; }
.btn svg.i { width: 16px; height: 16px; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { filter: brightness(.92); }
.btn.danger { color: var(--red-dark); border-color: #f3c3bf; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.stat { padding: 16px; display: flex; gap: 14px; align-items: center; }
.stat .ic { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.stat .ic.green { background: var(--green-soft); color: var(--green); }
.stat .ic.blue { background: var(--blue-soft); color: var(--blue); }
.stat .ic.amber { background: var(--amber-soft); color: var(--amber); }
.stat .num { font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: 12.5px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-soft); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red-dark); }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover { background: #fafbfc; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.route { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.route .arrow { color: var(--muted); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.toolbar .search input { padding-left: 32px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 8px; align-items: center; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--red-dark); border-bottom-color: var(--red); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; font-size: 13px; color: var(--ink-2); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { opacity: .65; margin-left: 4px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field label .req { color: var(--red); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .warn { font-size: 12px; color: var(--amber); margin-top: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd4dc; border-radius: 8px; font: inherit; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(225,37,27,.2); border-color: var(--red); }
textarea { resize: vertical; min-height: 70px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: auto; }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 4px; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.error-box { background: var(--red-soft); color: var(--red-dark); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }

/* ---------- details ---------- */
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .t-title { font-weight: 600; }
.timeline .t-meta { color: var(--muted); font-size: 12px; }

/* ---------- modules ---------- */
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.module { position: relative; padding: 18px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: transform .12s, box-shadow .12s; color: inherit; }
.module:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.1); text-decoration: none; }
.module .m-ic { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: var(--red); color: #fff; }
.module .m-ic svg { width: 22px; height: 22px; }
.module .m-name { font-weight: 650; font-size: 15px; color: var(--ink); }
.module .m-sum { color: var(--muted); font-size: 13px; line-height: 1.4; }
.module .m-tag { position: absolute; top: 14px; right: 14px; }
.module.locked { background: #fbfbfc; }
.module.locked .m-ic { background: #e7e9ee; color: #8b93a3; }
.module.locked .m-name { color: var(--ink-2); }
.lock-hero { text-align: center; padding: 40px 20px 28px; }
.lock-hero .big { width: 72px; height: 72px; border-radius: 18px; background: #eceef2; color: #8b93a3; display: grid; place-items: center; margin: 0 auto 16px; position: relative; }
.lock-hero .big svg { width: 34px; height: 34px; }
.lock-hero .big .lk { position: absolute; right: -8px; bottom: -8px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; border: 3px solid #fff; }
.lock-hero .big .lk svg { width: 14px; height: 14px; }
.feature-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.feature-list li { display: flex; gap: 10px; align-items: flex-start; }
.feature-list li svg { color: var(--muted); margin-top: 1px; width: 16px; height: 16px; }

.alert-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .what { flex: 1; min-width: 0; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.sm { max-width: 440px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: tin .2s ease-out; }
.toast.err { background: var(--red-dark); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: linear-gradient(150deg, var(--red) 0%, var(--red-dark) 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h1 { font-size: 34px; line-height: 1.15; max-width: 440px; }
.login-side p { opacity: .85; max-width: 420px; line-height: 1.5; }
.login-form { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.login-form form { width: 100%; max-width: 360px; display: grid; gap: 14px; }

/* ---------- print (mission order) ---------- */
.print-sheet { background: #fff; max-width: 800px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--line); }
.print-sheet .ph { display: flex; align-items: center; gap: 14px; border-bottom: 3px solid var(--red); padding-bottom: 14px; margin-bottom: 20px; }
.print-sheet table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.print-sheet td { border: 1px solid #c9ced6; padding: 7px 10px; vertical-align: top; }
.print-sheet td.l { width: 28%; background: #f6f7f9; font-weight: 600; }
.print-sheet .sig { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 40px; }
.print-sheet .sig div { border-top: 1px solid #555; padding-top: 6px; text-align: center; font-size: 12px; }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .print-sheet { border: 0; padding: 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .shell { background: var(--bg); }
  .sidebar { border-right: 1px solid var(--line); }
  .btn.menu-toggle { display: inline-flex; }
  .user-chip span:not(.avatar) { display: none; }
  .table-wrap .t { min-width: 680px; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .cols-2, .form-grid { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { padding: 32px 24px; }
  dl.kv { grid-template-columns: 120px 1fr; }
}
