:root {
  --bg: #f6f5f2; --panel: #fff; --line: #e3e0da; --ink: #1d1c1a; --muted: #6b6864; --accent: #b3541e; --accent-ink: #fff;
  --action: #b3541e; --fyi: #2f6f8f; --ignore: #8a8783; --high: #c0392b; --chip: #efece6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 12px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: var(--panel); width: 100%; }
textarea { resize: vertical; min-height: 120px; }
a { color: var(--accent); }
.hidden { display: none !important; }

#app { height: 100%; display: grid; grid-template-columns: 200px 380px 1fr; }
nav { border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
nav h1 { font-size: 17px; margin: 4px 8px 14px; letter-spacing: .02em; }
nav .item { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
nav .item:hover { background: var(--chip); }
nav .item.active { background: var(--ink); color: #fff; }
nav .count { font-size: 12px; opacity: .8; }
nav .spacer { flex: 1; }
nav .sub { font-size: 12px; color: var(--muted); margin: 14px 10px 4px; text-transform: uppercase; letter-spacing: .06em; }

.list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list .toolbar { padding: 10px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.list .rows { overflow: auto; flex: 1; }
.row { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 3px; }
.row:hover { background: #fbfaf8; }
.row.active { background: #f1eee8; }
.row.unread .subject { font-weight: 600; }
.row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.row .subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .summary { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--chip); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.badge.action { background: var(--action); color: #fff; }
.badge.fyi { background: var(--fyi); color: #fff; }
.badge.ignore { background: var(--ignore); color: #fff; }
.badge.high { background: var(--high); color: #fff; }
.badge.sit { background: #e8e2d4; color: #5a4a2a; text-transform: none; }

.detail { overflow: auto; padding: 18px 24px; min-width: 0; }
.detail .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.detail h2 { margin: 0 0 6px; font-size: 20px; }
.triage-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.triage-box .action { font-weight: 600; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin: 12px 0; }
.msg .meta { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.msg .meta b { color: var(--ink); }
.msg.out { border-left: 4px solid var(--accent); }
.msg .body { padding: 14px; white-space: pre-wrap; word-break: break-word; }
.msg .body.collapsed { max-height: 90px; overflow: hidden; position: relative; }
.msg .attachments { padding: 0 14px 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg .attachments a { font-size: 13px; background: var(--chip); padding: 3px 9px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.msg iframe { width: 100%; border: 0; min-height: 400px; }

.compose { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 16px; display: grid; gap: 8px; }
.compose .grid { display: grid; grid-template-columns: 70px 1fr; gap: 6px 10px; align-items: center; }
.compose .ai { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.compose .actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.compose .status { color: var(--muted); font-size: 13px; margin-right: auto; }

.situations { padding: 18px 24px; overflow: auto; grid-column: 2 / 4; }
.situations .card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.situations .card h3 { margin: 0 0 4px; }
.situations .rules { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.situations .rules .badge button { border: 0; background: transparent; padding: 0 0 0 6px; color: inherit; }
.situations .addrule { display: grid; grid-template-columns: 110px 1fr auto; gap: 6px; }
.situations textarea { min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.login { grid-column: 1 / 4; display: grid; place-items: center; }
.login .box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px; width: 380px; text-align: center; }
.empty { color: var(--muted); padding: 40px; text-align: center; }
.notes { margin-top: 16px; }
.notes .note { font-size: 13px; background: #fff8e6; border: 1px solid #efe1b8; padding: 8px 10px; border-radius: 6px; margin-bottom: 6px; white-space: pre-wrap; }
.answer { background: #fff8e6; border: 1px solid #efe1b8; padding: 12px; border-radius: 8px; white-space: pre-wrap; margin-top: 8px; }
@media (max-width: 1000px) { #app { grid-template-columns: 160px 1fr; } .detail, .compose-page { grid-column: 1 / 3; } .list.hidden-mobile { display: none; } }
