@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #f1f5f9;
  --surface: #fff;
  --ink: #0f172a;
  --muted: #475569;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --teal: #0f766e;
  --teal-hover: #0d9488;
  --teal-soft: #ccfbf1;
  --danger: #dc2626;
  --header-h: 56px;
  --side-w: 268px;
  --detail-w: 440px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, system-ui, sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--teal); }
.hidden { display: none !important; }

html.guest #app, html.guest #acct { display: none; }
html.authed #login { display: none; }

#login {
  display: none;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  padding: 24px;
}
html.guest #login { display: flex; }
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px 28px;
}
.login-mark {
  width: 48px; height: 48px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--teal);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: .4px;
}
.login-card h1 { margin: 0; text-align: center; font-size: 22px; font-weight: 600; }
.login-card .sub { text-align: center; color: var(--muted); margin: 6px 0 24px; }
.field { margin: 0 0 14px; }
.field input, .pop-card input, .detail input, .detail textarea, .detail select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}
.field input { height: 48px; padding: 0 14px; }
.field input:focus, .pop-card input:focus, .detail input:focus,
.detail textarea:focus, .detail select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15,118,110,.15);
}
.login-err, .pop-err { color: var(--danger); min-height: 18px; font-size: 13px; }
.login-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.login-link {
  background: none; border: 0; color: var(--teal); padding: 0;
  font-weight: 600; font-size: 13px;
}
.login-link:hover { text-decoration: underline; }
.client-switch {
  max-width: 220px; height: 32px; border: 0; border-radius: 8px;
  background: #1e293b; color: #fff; padding: 0 10px;
}
.btn-primary {
  background: var(--teal); color: #fff; border: 0;
  height: 40px; padding: 0 18px; border-radius: 8px; font-weight: 600;
}
.btn-primary:hover { background: var(--teal-hover); }
.ghost {
  background: transparent; border: 1px solid var(--line);
  height: 40px; padding: 0 14px; border-radius: 8px;
}

#app { height: 100%; display: flex; flex-direction: column; }
.top {
  height: var(--header-h);
  background: #0f172a;
  color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  flex: 0 0 auto;
}
.brand {
  color: #fff; text-decoration: none; font-weight: 700;
  font-size: 18px; letter-spacing: .3px;
  background: var(--teal); padding: 6px 12px; border-radius: 8px;
}
.search-wrap { flex: 1; }
.search-wrap input {
  width: 100%; max-width: 520px; height: 36px;
  border: 0; border-radius: 8px; padding: 0 12px;
  background: #1e293b; color: #fff;
}
.search-wrap input::placeholder { color: #94a3b8; }
.app-switch {
  display: inline-flex;
  align-items: center;
  background: #1e293b;
  border-radius: 22px;
  padding: 3px;
  flex: 0 0 auto;
}
.app-switch a {
  height: 32px;
  padding: 0 16px;
  border-radius: 19px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
}
.app-switch a:hover { color: #fff; background: #334155; }
.app-switch a.on {
  background: var(--teal);
  color: #fff;
}
.app-switch a.on:hover { background: var(--teal-hover); color: #fff; }
.avatar {
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: var(--teal); color: #fff; font-weight: 700;
}

.shell { flex: 1; min-height: 0; display: flex; }
.side {
  width: var(--side-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 12px;
  overflow: auto;
  flex: 0 0 auto;
}
.jump-mail {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  background: #fff;
}
.jump-mail:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.add-btn {
  width: 100%; height: 40px; margin-bottom: 14px;
  border: 0; border-radius: 10px;
  background: var(--teal); color: #fff; font-weight: 600;
}
.add-btn:hover { background: var(--teal-hover); }
.filt, .st-row {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  border: 0; background: transparent;
  text-align: start;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}
.filt span, .st-count { margin-inline-start: auto; color: var(--faint); font-size: 12px; }
.filt.active, .st-row.active { background: var(--teal-soft); font-weight: 600; }
.filt:hover, .st-row:hover { background: #f8fafc; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.st-name {
  flex: 1; min-width: 0; border: 0; background: transparent;
  padding: 0; font-weight: 500; white-space: normal; line-height: 1.25;
  text-align: start; color: inherit; pointer-events: none;
}
.st-row input.st-name { pointer-events: auto; cursor: text; }
.st-del {
  border: 0; background: transparent; color: var(--faint);
  width: 22px; height: 22px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.st-row:hover .st-del, .st-del { display: inline-flex; }
.st-del:hover { color: var(--danger); background: #fee2e2; }
.add-status-form {
  display: flex; gap: 6px; margin-top: 10px;
}
.add-status-form input {
  flex: 1; min-width: 0; height: 36px;
  border: 1px solid var(--line); border-radius: 8px; padding: 0 10px;
}
.add-status-form button {
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: var(--teal); color: #fff; font-size: 20px; font-weight: 600;
}
.add-status-form button:hover { background: var(--teal-hover); }

.list-pane { flex: 1; min-width: 0; overflow: auto; }
.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
.grid th {
  text-align: start; font-size: 12px; font-weight: 600;
  color: var(--muted); letter-spacing: .04em; text-transform: uppercase;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface);
}
.grid td { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: #f8fafc; }
.grid tbody tr.sel { background: var(--teal-soft); }
.pill {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: #fff;
}
.muted { color: var(--faint); }
.empty { padding: 64px 24px; text-align: center; color: var(--muted); }

.detail {
  width: var(--detail-w);
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 16px;
  overflow: auto;
  flex: 0 0 auto;
}
.detail h2 { margin: 0 0 4px; font-size: 20px; }
.detail .sub { color: var(--muted); margin-bottom: 16px; font-size: 13px; }
.detail label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin: 0 0 12px;
}
.detail textarea { min-height: 160px; resize: vertical; }
.save-msg { font-size: 12px; color: var(--muted); min-height: 18px; margin-top: 4px; }
.detail-acts { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.detail-acts a, .detail-acts button.ghost {
  display: inline-flex; align-items: center;
  text-decoration: none; color: var(--ink);
}
.danger {
  border: 0; background: transparent; color: var(--danger);
  padding: 8px 0; margin-top: 8px;
}
.row-act { width: 44px; text-align: end; }
.row-mail {
  width: 32px; height: 32px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font-size: 15px;
  color: var(--teal);
}
.row-mail:hover { background: var(--teal-soft); border-color: var(--teal); }
.mail-go {
  width: 100%; height: 42px; margin: 0 0 16px;
  border: 0; border-radius: 10px;
  background: var(--teal); color: #fff; font-weight: 700;
}
.mail-go:hover { background: var(--teal-hover); }
.mail-log {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.mail-log h3 {
  margin: 0 0 10px; font-size: 13px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.mail-empty { color: var(--faint); font-size: 13px; padding: 8px 0 12px; }
.mail-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f8fafc;
}
.mail-when {
  font-size: 12px; color: var(--muted); font-weight: 600;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.mail-st {
  display: inline-flex; align-items: center;
  height: 18px; padding: 0 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; background: #e2e8f0; color: #334155;
}
.mail-st.queued, .mail-st.sending { background: #dbeafe; color: #1d4ed8; }
.mail-st.failed { background: #fee2e2; color: #b91c1c; }
.mail-subj { font-weight: 600; margin-top: 4px; }
.mail-from { font-size: 12px; color: var(--faint); margin: 2px 0 6px; }
.mail-body {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font: 13px/1.45 Inter, system-ui, sans-serif;
  color: var(--ink); max-height: 160px; overflow: auto;
}
.mail-full { margin-top: 6px; }
.mail-full summary { cursor: pointer; color: var(--teal); font-size: 12px; font-weight: 600; }
.mail-err { color: var(--danger); font-size: 12px; margin-top: 6px; }

.pop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 20; padding: 20px;
}
.pop-card {
  width: min(420px, 92vw);
  background: #fff; border-radius: 14px; padding: 20px;
}
.pop-card h3 { margin: 0 0 14px; }
.pop-card label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin: 0 0 12px;
}
.pop-acts { display: flex; justify-content: flex-end; gap: 8px; }

.acct {
  position: fixed; top: 56px; inset-inline-end: 12px;
  width: 260px; background: #fff; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15,23,42,.18);
  padding: 16px; text-align: center; z-index: 15;
}
.acct .big {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; margin: 0 auto 8px;
}
.signout {
  margin-top: 12px; width: 100%; height: 36px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}

@media (max-width: 980px) {
  .detail { position: fixed; inset: var(--header-h) 0 0 auto; z-index: 8;
    box-shadow: -8px 0 24px rgba(15,23,42,.12); }
  .side { width: 180px; }
}
@media (max-width: 720px) {
  .side { display: none; }
  .grid th:nth-child(4), .grid td:nth-child(4) { display: none; }
}
