:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #6b7489;
  --line: #e3e7f0;
  --primary: #2f5bea;
  --primary-dark: #2148c9;
  --primary-soft: #eaf0ff;
  --ok: #138a4b;
  --ok-soft: #e6f6ed;
  --bad: #c62f2f;
  --bad-soft: #fdeceb;
  --warn: #9a6400;
  --warn-soft: #fff5e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
[hidden] { display: none !important; }
code { background: #eef1f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--bad); margin: 10px 0 0; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #f5f7fc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.big { padding: 11px 24px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 2px 6px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: 16px;
  padding: 32px 28px; box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { margin: 12px 0 4px; font-size: 22px; }
.login-card input { width: 100%; margin: 18px 0 12px; }
.logo {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 26px;
}
.logo.sm { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; margin: 0; display: inline-grid; }

input[type=text], input[type=password], input[type=search], textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  font: inherit; color: var(--text); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 180px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { background: #f1f3f8; border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.pill b { color: var(--text); }
.pill.full { background: var(--bad-soft); }
.banner { margin: 16px 24px 0; padding: 12px 16px; border-radius: 10px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { margin: 0 0 14px; background: var(--ok-soft); color: #0f5e35; font-size: 13px; }
.badge.skip { background: #eceef2; color: #555d6e; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px;
  padding: 20px 24px 120px; max-width: 1500px; margin: 0 auto; align-items: start;
}
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; padding: 16px 12px 120px; } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.compose { position: sticky; top: 76px; }
@media (max-width: 1000px) { .compose { position: static; } }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.step {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: inline-grid; place-items: center; font-size: 13px;
}

/* ---------- dropzone ---------- */
.dropzone {
  display: block; border: 2px dashed #cfd6e6; border-radius: 12px; padding: 28px 16px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s; background: #fafbfe;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dz-icon { font-size: 30px; margin-bottom: 6px; }
.small-dz { padding: 12px; font-weight: 600; }

/* ---------- table ---------- */
.file-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.file-name { font-weight: 600; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input { flex: 1 1 200px; width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 11px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sel-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px; }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 60vh; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
th { position: sticky; top: 0; background: #f7f9fc; font-weight: 600; color: var(--muted); z-index: 1; }
tbody tr:hover { background: #fafbff; }
tbody tr.is-selected { background: #f5f8ff; }
td.c-chk, th.c-chk { width: 36px; }
td.c-num { color: var(--muted); width: 40px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.wait { background: #eef1f7; color: var(--muted); }
.badge.run { background: var(--primary-soft); color: var(--primary); }

/* ---------- compose ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.chips-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -4px 0 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid #cdd8fb; background: var(--primary-soft); color: var(--primary); border-radius: 999px;
  padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.chip:hover { background: #dce6ff; }
.hint { margin: 4px 0 14px; }
.att-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.att-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #f5f7fb; border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
.att-list li .x { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 16px; }
.preview { border: 1px solid var(--line); border-radius: 10px; margin: 6px 0 16px; }
.preview summary { cursor: pointer; padding: 10px 12px; font-weight: 600; }
.preview-inner { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.pv-row { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.pv-body { padding: 12px 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.6; word-break: break-word; }
.pv-att { font-size: 13px; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
#sendNote { text-align: right; margin: 8px 0 0; }

/* ---------- progress ---------- */
.progress-panel {
  position: fixed; right: 20px; bottom: 20px; width: min(380px, calc(100vw - 40px)); background: #fff;
  border-radius: 14px; box-shadow: 0 10px 40px rgba(20, 30, 60, .2); padding: 16px 18px; z-index: 20;
}
.pp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.bar { height: 8px; background: #eef1f7; border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.pp-stats { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; }
#ppMsg { margin: 10px 0 0; }
#ppMsg.bad { color: var(--bad); }
#ppMsg.ok { color: var(--ok); }
#ppClose { margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2433; color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 30; max-width: 90vw; box-shadow: var(--shadow);
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
