:root {
  --bg: #0f1419; --panel: #1a2129; --panel2: #222b35; --line: #2c3742;
  --text: #e6edf3; --muted: #8b98a5; --accent: #4f9cf9;
  --p3: #e5534b; --p2: #d9a441; --p1: #5a6b7a; --p0: #3a444e;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.msg { font-size: 13px; min-height: 18px; color: var(--accent); }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 14px; font-size: 14px; cursor: pointer;
}
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button:hover { filter: brightness(1.08); }
input {
  width: 100%; padding: 10px 12px; margin: 6px 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  font-size: 14px;
}

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); padding: 28px; border-radius: 14px; width: 320px; border: 1px solid var(--line); }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }

/* App */
header {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
header .spacer { flex: 1; }
.stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.stats b { color: var(--text); }
.tabs { display: flex; gap: 4px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab { background: transparent; color: var(--muted); border: 1px solid transparent; }
.tab.active { background: var(--panel2); color: var(--text); border-color: var(--line); }
main { padding: 14px 18px; max-width: 900px; margin: 0 auto; }

.msg-item {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--p2);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
}
.msg-item.p3 { border-left-color: var(--p3); }
.msg-item.p2 { border-left-color: var(--p2); }
.msg-item.p1 { border-left-color: var(--p1); }
.msg-item.p0 { border-left-color: var(--p0); opacity: .8; }
.msg-item .top { display: flex; gap: 8px; align-items: baseline; }
.msg-item .from { font-weight: 600; }
.msg-item .date { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.msg-item .subject { margin: 3px 0; }
.msg-item .summary { color: var(--muted); font-size: 13px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.badge.reply { background: #3a2326; color: #ffb4ad; border-color: #5a2f33; }
.badge.unread { background: #1f3247; color: #9ccbff; border-color: #2d4258; }
.badge.action { background: #233a2a; color: #a6e6b8; border-color: #2f5a3b; }
.action-line { margin-top: 6px; font-size: 13px; color: #a6e6b8; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-top: 14px; }
.card h3 { margin-top: 0; }
.acc-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.acc-row .err { color: var(--p3); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 40px; }
.detail { white-space: pre-wrap; background: var(--panel2); padding: 14px; border-radius: 8px; margin-top: 10px; font-size: 14px; max-height: 50vh; overflow: auto; }
.row2 { margin: 8px 0; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.msg-item a { color: var(--accent); text-decoration: none; }
.tiny { font-size: 11px; }

/* Publik anonym översikt */
.public-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 340px; }
.public-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 100%; }
.public-head { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.public-head #public-count { color: var(--p3); }
.public-stats { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.public-item { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.public-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--p2); flex: 0 0 auto; }
.public-item .pl { font-weight: 600; }
.public-item .pt { color: var(--muted); font-size: 12px; }
.public-item .pw { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Kalender-agenda */
.cal-day { margin: 16px 0 6px; font-weight: 700; text-transform: capitalize; color: var(--accent); }
.cal-item { display: flex; gap: 12px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.cal-item .cal-time { color: var(--muted); min-width: 48px; font-variant-numeric: tabular-nums; }
