* { box-sizing: border-box; }
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8a93a6;
  --accent: #6aa9ff;
  --accent2: #5990e6;
  --danger: #ff6b6b;
  --ok: #38c172;
}
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  cursor: pointer; background: var(--accent); color: white;
  border: none; padding: 8px 14px; border-radius: 6px;
  font: inherit; font-weight: 500;
}
button:hover { background: var(--accent2); }
button.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line);
}
button.ghost:hover { background: var(--panel2); }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font: inherit; width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar .nav { display: flex; gap: 16px; align-items: center; }
.topbar .nav .user { color: var(--muted); }
.topbar .nav a.active { color: var(--text); border-bottom: 2px solid var(--accent); padding-bottom: 2px; }

.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-card {
  width: 360px; padding: 28px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px;
}
.login-card h1 { margin: 0 0 16px; font-size: 20px; }
.login-card .row { margin-bottom: 12px; }
.login-card label { display: block; color: var(--muted); margin-bottom: 4px; }
.login-card .err { color: var(--danger); font-size: 13px; margin-top: 8px; }

.section { margin-bottom: 28px; }
.section h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 16px; margin-bottom: 12px;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--line);
}
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: var(--panel2); cursor: pointer; }
td.unread { font-weight: 600; }
td .badge {
  background: var(--accent); color: white; border-radius: 10px;
  padding: 2px 8px; font-size: 11px; margin-left: 6px;
}

.row-flex { display: flex; gap: 12px; align-items: center; }
.row-flex .grow { flex: 1; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.email-view .meta {
  background: var(--panel); padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px;
}
.email-view .meta div { margin: 3px 0; }
.email-view .body {
  background: var(--panel); padding: 16px;
  border: 1px solid var(--line); border-radius: 8px;
  white-space: pre-wrap; word-break: break-word;
}
.email-view .body iframe { width: 100%; min-height: 400px; border: 0; background: white; border-radius: 4px; }

.actions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }

.toast {
  position: fixed; right: 20px; bottom: 20px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

.empty {
  text-align: center; color: var(--muted);
  padding: 40px 0;
}

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 22px; width: 360px;
}
.modal h3 { margin: 0 0 14px; }
.modal .row { margin-bottom: 10px; }
.modal .row label { display: block; color: var(--muted); margin-bottom: 4px; }
.modal .actions { justify-content: flex-end; margin-bottom: 0; }

.modal.email-modal {
  width: min(900px, 95vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  padding: 0;
}
.modal.email-modal .head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal.email-modal .head h3 {
  margin: 0; font-size: 16px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.modal.email-modal .head .close {
  background: transparent; color: var(--muted); border: 0;
  font-size: 22px; padding: 0 6px; cursor: pointer;
}
.modal.email-modal .head .close:hover { color: var(--text); }
.modal.email-modal .body-scroll { overflow: auto; padding: 16px 18px; }
.modal.email-modal .body iframe { width: 100%; min-height: 350px; border: 0; background: white; border-radius: 4px; }
.modal.email-modal .body {
  background: var(--bg); padding: 12px;
  border: 1px solid var(--line); border-radius: 6px;
  white-space: pre-wrap; word-break: break-word;
}

.mute-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 14px; font-size: 12px; cursor: pointer;
}
.mute-btn.muted { background: rgba(255,107,107,0.12); border-color: var(--danger); color: var(--danger); }
.mute-btn:hover { background: var(--panel2); color: var(--text); }
.mute-btn.muted:hover { background: var(--danger); color: white; }

/* Upload dropzone */
.upload {
  display: flex; align-items: center; gap: 12px;
  border: 1px dashed var(--line); border-radius: 8px;
  padding: 14px; background: var(--panel);
  margin-bottom: 14px;
}
.upload input[type=file] { flex: 1; }

/* Files list */
.files-table .url { color: var(--accent); }
.copy-btn { font-size: 12px; padding: 4px 8px; }

/* Lines split view: full-width, 50/50 */
.split-wrap { padding: 12px 16px; }
.split {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; align-items: start;
  height: calc(100vh - 80px);
}
.split .left, .split .right {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; overflow: auto; height: 100%;
}
.split .left .toolbar {
  position: sticky; top: 0; background: var(--panel);
  border-bottom: 1px solid var(--line); padding: 10px 12px;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  z-index: 1;
}
.split .left .filter-btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); padding: 4px 10px;
  border-radius: 14px; font-size: 12px; cursor: pointer;
}
.split .left .filter-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

.split .left select {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 4px 8px; font-size: 12px; font: inherit;
  cursor: pointer;
}
.split .left select.active { background: var(--accent); border-color: var(--accent); color: white; }

.line-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.line-item:hover { background: var(--panel2); }
.line-item.selected { background: rgba(106,169,255,0.12); }
.line-item .no { color: var(--muted); font-size: 11px; min-width: 26px; }
.line-item .content {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.split .left.wrap .line-item .content {
  white-space: pre-wrap; word-break: break-all; overflow: visible;
}
.line-item .icon-btn {
  width: 26px; height: 26px; display: inline-flex;
  align-items: center; justify-content: center;
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 6px;
  cursor: pointer; padding: 0; font-size: 15px; line-height: 1;
}
.line-item .icon-btn:hover { background: var(--panel2); color: var(--text); }
.line-item .icon-btn.del:hover { color: var(--danger); }
.line-item .icon-btn.plus { color: var(--muted); opacity: 0.5; }
.line-item .icon-btn.plus:hover { opacity: 1; color: var(--accent); }
.line-item .icon-btn.envelope {
  color: var(--accent); opacity: 1; font-size: 18px;
  text-shadow: 0 0 8px rgba(106,169,255,0.6);
}
.line-item .icon-btn.envelope:hover { color: white; background: var(--accent); }

.split .right .placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--muted); padding: 40px;
  text-align: center;
}
.split .right .inner { padding: 14px 16px; }
