/* Draft UI: functional only, will be replaced by the design mockup. */
:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2f6fde; --danger: #c83737; --warn: #b7791f; --ok: #2f855a;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; background: #fff; }
textarea { width: 100%; resize: vertical; }
label { display: block; margin: 6px 0; }
label > span { display: block; font-size: 12px; color: var(--muted); }

header.top { display: flex; gap: 16px; align-items: center; padding: 8px 16px; background: #1d2330; color: #fff; }
header.top a { color: #cfd8ea; text-decoration: none; }
header.top a.active { color: #fff; font-weight: 600; }
header.top .spacer { flex: 1; }

.inbox { display: grid; grid-template-columns: 220px 380px 1fr; height: calc(100vh - 41px); }
.filters, .list, .card { overflow: auto; }
.filters { padding: 12px; border-right: 1px solid var(--line); background: var(--panel); }
.list { border-right: 1px solid var(--line); background: var(--panel); }
.list .item { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .item:hover { background: #f0f4fb; }
.list .item.active { background: #e3ecfb; }
.list .item .row { display: flex; gap: 6px; align-items: baseline; }
.list .item .subject { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .item .meta, .muted { color: var(--muted); font-size: 12px; }
.list .item .preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card { padding: 16px 20px; }

.badge { display: inline-block; padding: 0 6px; border-radius: 10px; font-size: 11px; background: #eef0f4; color: #374151; white-space: nowrap; }
.badge.new { background: #dbeafe; color: #1e40af; }
.badge.in_progress { background: #fef3c7; color: #92400e; }
.badge.waiting_user, .badge.waiting_internal { background: #ede9fe; color: #5b21b6; }
.badge.resolved, .badge.sent { background: #dcfce7; color: #166534; }
.badge.failed, .badge.unknown { background: #fee2e2; color: #991b1b; }
.badge.queued, .badge.sending { background: #e0e7ff; color: #3730a3; }

.box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.box h3 { margin: 0 0 8px; font-size: 14px; }
.msg { border-left: 3px solid var(--line); padding: 6px 10px; margin: 10px 0; }
.msg.outbound { border-left-color: var(--accent); background: #f6f9ff; }
.msg pre, .pre { white-space: pre-wrap; word-wrap: break-word; font: inherit; margin: 6px 0 0; }
.msg iframe { width: 100%; height: 360px; border: 1px solid var(--line); background: #fff; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.fields input, .fields select, .fields textarea { width: 100%; }
.warn { color: var(--warn); }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.notice { padding: 8px 10px; border-radius: 6px; background: #fff7e6; border: 1px solid #f3d19e; margin-bottom: 10px; }
.notice.error { background: #fdecec; border-color: #f5b5b5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.stars { color: #e0a100; letter-spacing: 1px; }

.login { max-width: 320px; margin: 12vh auto; background: var(--panel); padding: 24px; border-radius: 10px; border: 1px solid var(--line); }
.login h1 { margin-top: 0; font-size: 20px; }

.admin { padding: 16px 20px; max-width: 1200px; }
.admin nav { display: flex; gap: 8px; margin-bottom: 12px; }
.admin nav button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 18px; max-width: 520px; }
dialog::backdrop { background: rgba(0,0,0,.3); }
.toast { position: fixed; bottom: 16px; right: 16px; background: #1d2330; color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 420px; }
.toast.error { background: var(--danger); }
