:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1c2530; --muted: #6b7785; --line: #dfe4ea;
  --accent: #2557d6; --accent-ink: #fff; --ok: #1d8a4c; --warn: #b7791f; --bad: #c0392b; --work: #2557d6;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none; }
.brand span { font-weight: 400; font-size: 14px; color: var(--muted); margin-left: 8px; }
.who { font-size: 14px; color: var(--muted); display: flex; gap: 12px; align-items: center; }
main { max-width: 980px; margin: 24px auto; padding: 0 16px 60px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 14px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 16px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], textarea { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { resize: vertical; min-height: 44px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
.narrow { max-width: 400px; margin: 60px auto; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 20px; }

.cases { display: grid; gap: 10px; }
.case { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: inherit; }
.case:hover { border-color: var(--accent); }
.case .name { font-weight: 600; }
.badge { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: #e8ebf0; color: #3d4756; white-space: nowrap; }
.badge.work { background: #e3ebff; color: var(--work); }
.badge.ok, .badge.done { background: #def3e6; color: var(--ok); }
.badge.warn { background: #fbefd5; color: var(--warn); }
.badge.bad { background: #fadfdb; color: var(--bad); }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); transition: .15s; }
.drop.over { border-color: var(--accent); background: #eef3ff; color: var(--accent); }
.drop .row { justify-content: center; margin-top: 10px; }
.uploads { margin-top: 12px; display: grid; gap: 8px; }
.up { font-size: 14px; }
.up .bar { height: 6px; background: #e8ebf0; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.up .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.up.fail { color: var(--bad); }

.chat { display: grid; gap: 12px; }
.msg { padding: 12px 16px; border-radius: 12px; max-width: 100%; overflow-wrap: anywhere; }
.msg.assistant { background: #fff; border: 1px solid var(--line); }
.msg.user { background: #e8efff; align-self: end; justify-self: end; border: 1px solid #cddcff; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 22px; }
.msg h3, .msg h4 { margin: 10px 0 6px; font-size: 16px; }
.msg table { border-collapse: collapse; margin: 8px 0; font-size: 14px; display: block; overflow-x: auto; }
.msg th, .msg td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.msg th { background: #f0f3f7; }
.msg code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 14px; }
.progress { display: flex; gap: 10px; align-items: center; padding: 12px 16px; background: #eef3ff; border-radius: 12px; color: var(--work); }
.spin { width: 16px; height: 16px; border: 2px solid #b9cbf5; border-top-color: var(--work); border-radius: 50%; animation: s 0.9s linear infinite; flex: none; }
@keyframes s { to { transform: rotate(360deg); } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { border-radius: 99px; padding: 6px 14px; font-size: 15px; text-align: left; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.files { display: grid; gap: 6px; }
.file { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.file:last-child { border-bottom: 0; }
.errbox { background: #fdecea; border: 1px solid #f5c2bc; color: var(--bad); padding: 12px 16px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2530; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 20; max-width: 90vw; }
@media (max-width: 600px) { .top { padding: 10px 14px; } .brand span { display: none; } }
