:root { --red: #d80d06; --red-dark: #a90a04; --orange: #ffa93c; --ink: #23211f; --soft: #5c5853; --line: #dedbd6; --bg: #f3f2f0; --green: #2f6b3f; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Barlow", "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; }
h1, h2, h3 { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 2rem; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #e9e6e1; padding: 18px 0; display: flex; flex-direction: column; }
.side .brand { padding: 0 18px 16px; font: 700 1.3rem "Barlow Condensed", sans-serif; color: #fff; text-decoration: none; display: block; }
.side .brand small { display: block; font: 400 .8rem "Barlow", sans-serif; color: #b6b1aa; }
.side nav a { display: block; padding: 9px 18px; text-decoration: none; color: #e9e6e1; }
.side nav a:hover { background: #34312d; }
.side nav a[aria-current="page"] { background: var(--red); color: #fff; }
.side .who { margin-top: auto; padding: 14px 18px; font-size: .85rem; color: #b6b1aa; border-top: 1px solid #3d3a36; }
.side .who button { background: none; border: 0; color: #fff; text-decoration: underline; padding: 0; cursor: pointer; font: inherit; }
.content { padding: 24px 32px 60px; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 18px; margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; text-decoration: none; }
.stat b { display: block; font: 700 2rem "Barlow Condensed", sans-serif; }
.stat span { color: var(--soft); }
.btn { display: inline-block; background: var(--red); color: #fff; border: 1px solid var(--red); border-radius: 4px; padding: 8px 16px; font: 600 .95rem "Barlow", sans-serif; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--red-dark); }
.btn-ghost { background: #fff; color: var(--ink); border-color: #b9b4ad; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--soft); font-weight: 600; background: #faf9f7; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 18px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #b9b4ad; border-radius: 4px; background: #fff; color: var(--ink); max-width: 100%; }
textarea { width: 100%; }
label.f { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
label.f input[type=text], label.f input[type=email], label.f input[type=password], label.f select { width: 100%; }
.check { display: inline-flex; gap: 6px; align-items: center; margin-right: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.muted { color: var(--soft); font-size: .9rem; }
.flash { padding: 10px 14px; border-radius: 4px; margin-bottom: 14px; background: #e9f4ec; border: 1px solid #a9d2b4; color: #1f4a2b; }
.flash.err { background: #fdecea; border-color: #f3b6b2; color: #7d0a05; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .8rem; font-weight: 600; background: var(--bg); }
.pill.new { background: #fff1dc; color: #7a4a00; }
.pill.in { background: #e9f4ec; color: var(--green); }
.pill.out { background: #fdecea; color: var(--red); }
.pill.rollback { background: #e7eefb; color: #1f3f7a; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photo { width: 140px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.photo img { width: 140px; height: 140px; object-fit: cover; display: block; }
.photo .acts { display: flex; justify-content: space-between; padding: 4px; }
.photo .acts button { background: none; border: 0; cursor: pointer; padding: 4px 6px; font: inherit; font-size: .85rem; }
.dropzone { border: 2px dashed #b9b4ad; border-radius: 6px; padding: 18px; text-align: center; background: #faf9f7; }
.dropzone.over { border-color: var(--red); background: #fff6f5; }
.vt input[type=text] { width: 100%; min-width: 160px; }
.vt input[type=number] { width: 90px; }
.login { max-width: 380px; margin: 10vh auto; }
.diff { font: .85rem/1.4 ui-monospace, Menlo, monospace; color: var(--soft); }

/* Chat */
.chat { display: grid; grid-template-rows: 1fr auto; height: calc(100vh - 140px); min-height: 420px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.chat-log { overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78ch; padding: 10px 14px; border-radius: 8px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--bg); }
.msg.tool { align-self: flex-start; font-size: .85rem; color: var(--soft); background: none; padding: 0 14px; }
.msg.error { align-self: flex-start; background: #fdecea; color: #7d0a05; }
.chat form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.chat textarea { flex: 1; resize: vertical; min-height: 48px; }
.chat-empty { color: var(--soft); margin: auto; text-align: center; max-width: 48ch; }
.chat-empty button { margin: 4px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; padding: 8px; align-items: center; }
  .side nav { display: flex; flex-wrap: wrap; }
  .side nav a { padding: 6px 10px; }
  .side .who { margin: 0; border: 0; padding: 6px 10px; }
  .content { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
}
