:root {
  --ink: #1d2733; --muted: #66727f; --line: #e3e7ec; --bg: #f5f7f9; --card: #fff;
  --navy: #1f3a5a; --accent: #2f6db5;
  --ok: #1e7a4f; --ok-bg: #e7f5ee; --warn: #9a6400; --warn-bg: #fdf3df;
  --gap: #b3261e; --gap-bg: #fbe9e7; --info: #3c5a7a; --info-bg: #e9f0f7;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; color: var(--ink); background: var(--bg); }
h2 { font-size: 17px; margin: 0 0 6px; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 8px; }
button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line); background: #fff; padding: 8px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:disabled { opacity: .5; }
button.small { padding: 5px 10px; font-size: 13px; }
button.ghost { background: #fff; }
button.link { border: 0; background: none; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 10px 16px; }
.muted { color: var(--muted); } .hidden { display: none !important; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--navy); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; opacity: .75; font-size: 12px; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--navy); font-weight: 800; }
.demo { font-size: 11px; padding: 3px 8px; border: 1px solid rgba(255,255,255,.4); border-radius: 99px; margin-left: 6px; }
nav { display: flex; gap: 4px; margin-left: 12px; }
.tab { background: transparent; border: 0; color: rgba(255,255,255,.7); }
.tab.active { color: #fff; background: rgba(255,255,255,.14); }
.stats { margin-left: auto; display: flex; gap: 22px; }
.stats div { text-align: right; } .stats b { font-size: 22px; display: block; line-height: 1.1; }
.stats span { font-size: 11px; opacity: .75; }

body { display: flex; flex-direction: column; height: 100vh; } .view { flex: 1; min-height: 0; overflow: auto; }
#desk { display: grid; grid-template-columns: 330px 1fr; }
.cta { display: block; padding: 8px 20px; background: var(--warn-bg); color: var(--ink); font-size: 13px; text-decoration: none; border-bottom: 1px solid var(--line); } .cta b { color: var(--accent); text-decoration: underline; }
.inbox { border-right: 1px solid var(--line); background: var(--card); overflow-y: auto; }
.inbox-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.inbox-head h2 { margin: 0; }
#inbox-list { list-style: none; margin: 0; padding: 0; }
#inbox-list li { padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
#inbox-list li:hover { background: #f8fafc; } #inbox-list li.sel { background: #edf3fa; box-shadow: inset 3px 0 var(--accent); }
.li-top { display: flex; justify-content: space-between; } .from { font-weight: 600; } .time { color: var(--muted); font-size: 12px; }
.subj { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0 6px; }
.chips { display: flex; gap: 6px; }
.chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eef1f4; color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.gap { background: var(--gap-bg); color: var(--gap); } .chip.info { background: var(--info-bg); color: var(--info); }
.chip.done { background: var(--navy); color: #fff; }

.detail { overflow-y: auto; padding: 22px 28px 60px; display: grid; grid-template-columns: minmax(300px, 1fr) minmax(420px, 1.35fr); gap: 26px; align-items: start; }
.empty { grid-column: 1 / -1; max-width: 520px; margin: 80px auto; text-align: center; color: var(--muted); }
.empty h2 { color: var(--ink); }
.email, .prep, .reply { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.email { position: sticky; top: 0; }
.email-meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.email pre { white-space: pre-wrap; font: inherit; margin: 12px 0 0; }
.agent h3:first-child { margin-top: 0; }
.secs { float: right; text-transform: none; letter-spacing: 0; font-weight: 400; }
.working { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 10px 0; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { position: relative; padding: 4px 0 10px 32px; animation: in .3s ease both; counter-increment: s; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 11px; display: grid; place-items: center; }
.steps li b { display: block; } .steps li span { color: var(--muted); font-size: 13px; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } }
.fade { animation: in .4s ease both; }
.verdict { margin-top: 14px; border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.verdict span { font-weight: 700; font-size: 16px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); } .verdict.warn { background: var(--warn-bg); color: var(--warn); }
.verdict.gap { background: var(--gap-bg); color: var(--gap); } .verdict.info { background: var(--info-bg); color: var(--info); }
.checks { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.checks li { display: flex; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks i { font-style: normal; flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.checks .ok i { background: var(--ok-bg); color: var(--ok); } .checks .warn i { background: var(--warn-bg); color: var(--warn); }
.checks .gap i { background: var(--gap-bg); color: var(--gap); } .checks .info i { background: var(--info-bg); color: var(--info); }
.checks b { display: block; font-size: 13px; } .checks span { color: var(--muted); font-size: 13px; }
.prep small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.prep b { display: block; } .prep .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.prep table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 14px; }
.prep th { text-align: left; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line); padding: 4px 6px; }
.prep td { border-bottom: 1px solid var(--line); padding: 6px; vertical-align: top; }
.prep td small { text-transform: none; letter-spacing: 0; }
.prep p { margin: 4px 0 0; } .prep .fine { font-size: 11px; color: var(--muted); margin-top: 12px; }
.prep em { color: var(--gap); font-style: normal; }
.reply textarea { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 10px; resize: vertical; }
.reply.internal { background: #fffaf0; border-color: #f0dfb8; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.ams { padding: 22px 28px; max-width: 1200px; }
.ams-head { display: flex; justify-content: space-between; align-items: center; }
.ams-head input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; width: 260px; font: inherit; }
#ams-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
#ams-table th { text-align: left; padding: 10px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
#ams-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
#ams-table small { display: block; color: var(--muted); }
.pol { display: inline-block; font-size: 12px; background: #eef2f6; border-radius: 4px; padding: 2px 6px; margin: 0 4px 4px 0; }
.pol.expired { background: var(--gap-bg); color: var(--gap); }

dialog { border: 0; border-radius: 12px; padding: 22px; width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 0; }
dialog input, dialog textarea { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; color: var(--ink); }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.prep td:not(:first-child) { white-space: nowrap; }
.prep td:first-child { min-width: 120px; }
.prep { overflow-x: auto; }

@media (max-width: 800px) {
  body { height: auto; } .top { flex-wrap: wrap; gap: 10px; } .stats, .demo { display: none; } nav { margin-left: 0; }
  #desk { display: block; } .inbox { max-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .detail { grid-template-columns: minmax(0, 1fr); padding: 14px 12px 40px; } .actions { flex-wrap: wrap; } .email { position: static; }
  .prep { overflow-x: auto; } .ams { padding: 12px; overflow-x: auto; }
}
