* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2128;
  --bg4: #21262d;
  --border: #30363d;
  --text1: #e6edf3;
  --text2: #8b949e;
  --text3: #6e7681;
  --accent: #2ea043;
  --accent2: #3fb950;
  --blue: #58a6ff;
  --red: #f85149;
  --font: 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text1);
  height: 100vh;
  overflow: hidden;
}

/* LOGIN */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg);
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 360px;
}
.login-logo h1 {
  font-size: 32px;
  color: var(--accent2);
  margin-bottom: 6px;
}
.login-logo p {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 28px;
}
.login-form input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  color: var(--text1);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}
.login-form input:focus { border-color: var(--accent); }
.login-form button {
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.login-form button:hover { background: var(--accent2); }
.error-msg { color: var(--red); font-size: 12px; margin-top: 8px; }

/* APP LAYOUT */
.app { display: flex; height: 100vh; }

/* Company sidebar */
.panel-companies {
  width: 72px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
}
.company-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #1a3a2a;
  color: var(--accent2);
  border: 2px solid transparent;
  transition: all 0.15s;
}
.company-logo.active { border-color: var(--accent2); border-radius: 16px; }
.company-logo.add-btn { background: var(--bg4); color: var(--text2); font-size: 22px; }
.company-divider { width: 32px; height: 1px; background: var(--border); margin: 4px 0; }

/* Team panel */
.panel-team {
  width: 280px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.team-header { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.team-header h2 { font-size: 15px; font-weight: 600; }
.team-header p { font-size: 12px; color: var(--text2); margin-top: 2px; }
.team-search {
  margin: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text2);
}
.team-search input {
  background: none; border: none; outline: none;
  color: var(--text1); font-size: 13px; width: 100%;
}
.tab-bar { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 14px; font-size: 12px; font-weight: 500;
  cursor: pointer; color: var(--text3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all 0.15s;
}
.tab.active { color: var(--accent2); border-bottom-color: var(--accent2); }
.team-list { overflow-y: auto; flex: 1; padding: 4px 0; }
.loading-msg { font-size: 13px; color: var(--text3); padding: 16px; text-align: center; }

/* Contact row */
.contact-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer;
  border-radius: 8px; margin: 1px 6px;
  transition: background 0.1s;
}
.contact-row:hover { background: var(--bg3); }
.contact-row.active { background: var(--bg4); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
  background: #1a3a2a; color: var(--accent2);
  position: relative;
}
.presence {
  position: absolute; bottom: 1px; right: 1px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--bg2);
}
.presence.online { background: var(--accent2); }
.presence.offline { background: var(--text3); }
.contact-info { flex: 1; min-width: 0; }
.contact-name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-sub {
  font-size: 11px; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.contact-time { font-size: 10px; color: var(--text3); }
.unread-dot {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 999px; min-width: 18px;
  height: 18px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
}

/* Main panel */
.panel-main { flex: 1; display: flex; flex-direction: column; background: var(--bg3); min-width: 0; }
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text3); gap: 12px;
}
.empty-state i { font-size: 48px; }
.empty-state h3 { font-size: 18px; color: var(--text2); }
.empty-state p { font-size: 13px; }

/* Chat header */
.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  display: flex; align-items: center; gap: 12px;
}
.chat-header-info { flex: 1; }
.chat-header-info h3 { font-size: 14px; font-weight: 600; }
.chat-header-info p { font-size: 11px; color: var(--text2); }
.chat-header-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: none; border: none; color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 17px; transition: all 0.1s;
}
.icon-btn:hover { background: var(--bg4); color: var(--text1); }
.msg-type-toggle {
  display: flex; gap: 4px; padding: 2px;
  background: var(--bg4); border-radius: 8px;
  border: 1px solid var(--border);
}
.msg-type-btn {
  padding: 4px 12px; border-radius: 6px;
  border: none; font-size: 11px; font-weight: 500;
  cursor: pointer; color: var(--text2); background: none;
  transition: all 0.15s;
}
.msg-type-btn.active {
  background: var(--bg2); color: var(--text1);
  border: 1px solid var(--border);
}

/* Messages */
.messages-area {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 2px;
}
.msg-day-label {
  text-align: center; font-size: 11px; color: var(--text3);
  margin: 12px 0;
}
/* Toolbar fixes */
.editor-toolbar {
  background: var(--bg2);
  min-height: 44px;
}

.tb-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  transition: all 0.1s;
  vertical-align: middle;
}

.tb-btn:hover {
  background: var(--bg4);
  color: var(--text1);
}

.tb-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  border-radius: 6px;
  padding: 3px 6px;
  cursor: pointer;
  height: 28px;
  vertical-align: middle;
}

.tb-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  vertical-align: middle;
}

.editor-toolbar .ti {
  font-size: 16px;
  line-height: 1;
}

#emailSubject {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text1);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  height: 28px;
}

#emailSubject:focus {
  border-color: var(--accent);
}

.editor-body {
  padding: 12px 16px;
  min-height: 90px;
  max-height: 160px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text1);
  outline: none;
  background: var(--bg2);
}

.editor-body:empty::before {
  content: attr(data-placeholder);
  color: var(--text3);
  pointer-events: none;
}

.editor-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}

.attach-icons {
  display: flex;
  gap: 2px;
  flex: 1;
  align-items: center;
}

.mode-label {
  font-size: 11px;
  color: var(--text3);
  font-family: monospace;
  letter-spacing: 0.05em;
}

.send-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.send-btn:hover {
  background: var(--accent2);
}
