:root {
  --matcha-light: #76B729;
  --matcha-dark: #387931;
  --matcha-night: #1C3318;
  --matcha-bg: #F7FAF4;
  --matcha-cream: #FDFBF5;
  --text: #1A2B16;
  --text-soft: #5C6B58;
  --text-mute: #8A9585;
  --border: #E6EDE0;
  --border-soft: #F0F4EB;
  --white: #FFFFFF;
  --violet: #B8338B;
  --pink: #F087B6;
  --gold: #E8B923;
  --red: #D84545;
  --blue: #4A7BC4;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--matcha-bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 260px 380px 1fr;
  height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: linear-gradient(180deg, #FDFBF5 0%, #F5F9EE 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--matcha-light), var(--matcha-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(56, 121, 49, 0.25);
}
.brand-name {
  font-weight: 800;
  font-size: 16px;
  color: var(--matcha-night);
  letter-spacing: -0.2px;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 500;
}
.greeting {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}
.greeting strong { color: var(--matcha-dark); font-weight: 700; }

.compose-btn {
  margin: 14px 16px 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--matcha-light), var(--matcha-dark));
  color: white;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(56, 121, 49, 0.22);
  transition: transform 0.15s;
}
.compose-btn:hover { transform: translateY(-1px); }
.compose-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.nav-section {
  margin-top: 8px;
  padding: 0 12px;
}
.nav-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mute);
  padding: 10px 10px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.nav-title .chev { font-size: 11px; color: var(--text-mute); transition: transform 0.2s; }
.nav-section.collapsed .chev { transform: rotate(-90deg); }
.nav-section.collapsed .nav-items { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 1px;
}
.nav-item:hover { background: rgba(118, 183, 41, 0.08); color: var(--matcha-dark); }
.nav-item.active {
  background: rgba(118, 183, 41, 0.15);
  color: var(--matcha-dark);
  font-weight: 600;
}
.nav-item .icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.nav-item .dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--matcha-dark);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.nav-item .badge.soft {
  background: rgba(118, 183, 41, 0.15);
  color: var(--matcha-dark);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border-soft);
}
.sync-status {
  font-size: 11px;
  color: var(--text-mute);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--matcha-light);
}
.sync-dot.syncing { animation: pulse 1.2s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== MAIL LIST ===== */
.maillist {
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.maillist-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: white;
}
.maillist-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.maillist-title h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--matcha-night);
  letter-spacing: -0.3px;
}
.maillist-title .count {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 500;
}
.search-box {
  display: flex;
  align-items: center;
  background: var(--matcha-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  gap: 8px;
}
.search-box input {
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  flex: 1;
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-mute); }

.mail-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border-soft);
  background: white;
}
.mail-tab {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.mail-tab.active {
  color: var(--matcha-dark);
  border-bottom-color: var(--matcha-light);
}

.mail-items {
  flex: 1;
  overflow-y: auto;
}
.section-label {
  padding: 10px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gold);
  background: linear-gradient(90deg, rgba(232, 185, 35, 0.08), transparent);
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-label.normal {
  color: var(--text-mute);
  background: none;
}
.section-label.todo-section {
  color: var(--red);
  background: linear-gradient(90deg, rgba(216, 69, 69, 0.1), transparent);
}

.todo-flag {
  color: var(--red);
  font-size: 12px;
  margin-right: 2px;
}
.mail-item.is-todo {
  border-left: 4px solid var(--red);
  padding-left: 20px;
}
.mail-item.is-todo.unread {
  border-left: 6px solid var(--red);
  background: linear-gradient(90deg, #FCE5E5 0%, #FAEFE5 50%, #FAFEF5 100%);
}

.mail-item {
  padding: 14px 20px 14px 24px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.mail-item:hover { background: var(--matcha-bg); }
.mail-item.active {
  background: linear-gradient(90deg, rgba(118, 183, 41, 0.1), transparent);
  border-left: 3px solid var(--matcha-light);
  padding-left: 21px;
}
/* Unread — strong visual distinction with vibrant green left ribbon and tinted background */
.mail-item.unread {
  background: linear-gradient(90deg, #E8F5D7 0%, #F4FBE9 50%, #FAFEF5 100%);
  border-left: 6px solid var(--matcha-light);
  padding-left: 18px;
  position: relative;
}
.mail-item.unread::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(180deg, var(--matcha-light), var(--matcha-dark));
}
.mail-item.unread .mail-from {
  font-weight: 800;
  color: var(--matcha-night);
  font-size: 13.5px;
}
.mail-item.unread .mail-subject {
  font-weight: 800;
  color: var(--matcha-night);
  font-size: 13.5px;
}
.mail-item.unread .mail-preview {
  color: var(--text);
  font-weight: 500;
}
.mail-item.unread .mail-time {
  color: var(--matcha-dark);
  font-weight: 800;
  background: white;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--matcha-light);
}
.mail-item.unread::before {
  content: '';
  position: absolute;
  left: 28px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--matcha-light);
  transform: translateY(-50%);
  box-shadow: 0 0 0 4px rgba(118, 183, 41, 0.3), 0 0 12px rgba(118, 183, 41, 0.4);
  z-index: 1;
}
.mail-item.unread .mail-row1 {
  padding-left: 18px;
}
.mail-item.unread .mail-subject,
.mail-item.unread .mail-preview {
  padding-left: 18px;
}
.mail-item.unread .mail-badges {
  padding-left: 18px;
}
/* Active unread — extra deep border */
.mail-item.unread.active {
  border-left: 6px solid var(--matcha-dark);
  background: linear-gradient(90deg, #DAEFB8 0%, #E8F5D7 60%, #F0F9E0 100%);
}

.mail-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 8px;
}
.mail-from {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.mail-account-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.mail-time {
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 500;
  flex-shrink: 0;
}
.mail-subject {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mail-preview {
  font-size: 12px;
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}
.mail-badges {
  display: flex;
  gap: 5px;
  margin-top: 7px;
  flex-wrap: wrap;
  align-items: center;
}
.badge-ai {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-ai.faktura { background: rgba(184, 51, 139, 0.1); color: var(--violet); }
.badge-ai.priorita { background: rgba(216, 69, 69, 0.1); color: var(--red); }
.badge-ai.info { background: rgba(74, 123, 196, 0.1); color: var(--blue); }
.badge-ai.newsletter { background: rgba(138, 149, 133, 0.12); color: var(--text-mute); }
.badge-ai.obchod { background: rgba(118, 183, 41, 0.12); color: var(--matcha-dark); }
.star-btn {
  background: none;
  border: none;
  font-size: 15px;
  color: #D8DED2;
  cursor: pointer;
  padding: 2px;
  margin-left: 6px;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.star-btn:hover { transform: scale(1.2); }
.star-btn.starred { color: var(--gold); }

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
}
.empty-state .emoji { font-size: 36px; margin-bottom: 12px; display: block; }

/* ===== PREVIEW PANE ===== */
.preview {
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-toolbar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
}
.tool-btn {
  padding: 8px 12px;
  background: var(--matcha-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.tool-btn:hover { background: white; border-color: var(--matcha-light); color: var(--matcha-dark); }
.tool-btn.primary {
  background: var(--matcha-dark);
  color: white;
  border-color: var(--matcha-dark);
}
.tool-btn.primary:hover { background: var(--matcha-night); }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tool-spacer { flex: 1; }

.preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}
.preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  flex-direction: column;
  color: var(--text-mute);
  text-align: center;
}
.preview-empty .emoji { font-size: 64px; margin-bottom: 16px; }
.preview-empty h3 { color: var(--matcha-night); margin-bottom: 8px; font-size: 18px; }

.preview-subject {
  font-size: 22px;
  font-weight: 800;
  color: var(--matcha-night);
  letter-spacing: -0.4px;
  margin-bottom: 16px;
  line-height: 1.3;
}
.ai-card {
  background: linear-gradient(135deg, rgba(118, 183, 41, 0.08), rgba(184, 51, 139, 0.06));
  border: 1px solid rgba(118, 183, 41, 0.25);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.ai-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--matcha-light), var(--violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.ai-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--matcha-dark);
  margin-bottom: 3px;
}
.ai-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.ai-text strong { color: var(--violet); }

.preview-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 24px;
}
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #B8338B, #F087B6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.meta-info { flex: 1; min-width: 0; }
.meta-from {
  font-size: 14px;
  font-weight: 700;
  color: var(--matcha-night);
}
.meta-email {
  font-size: 12px;
  color: var(--text-mute);
}
.meta-to {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 3px;
}
.meta-date {
  font-size: 12px;
  color: var(--text-mute);
  text-align: right;
  flex-shrink: 0;
}

.email-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  max-width: 740px;
  word-wrap: break-word;
}
.email-body p { margin-bottom: 14px; }
.email-body a { color: var(--matcha-dark); }
.email-body img { max-width: 100%; height: auto; }
.email-body pre { white-space: pre-wrap; font-family: inherit; }

.reply-box {
  margin-top: 24px;
  background: var(--matcha-bg);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: text;
}
.reply-box .placeholder {
  flex: 1;
  font-size: 13px;
  color: var(--text-mute);
}
.reply-box .ai-suggest {
  font-size: 11px;
  font-weight: 700;
  color: var(--violet);
  background: white;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(184, 51, 139, 0.2);
  cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 51, 24, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: white;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #FDFBF5, #F5F9EE);
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--matcha-night);
  letter-spacing: -0.3px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-mute);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}

.rules-intro {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--matcha-bg);
  border-radius: 10px;
  border-left: 3px solid var(--matcha-light);
}
.rules-intro strong { color: var(--matcha-dark); }
.rules-intro code {
  background: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--violet);
}

.rule-form {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.rule-form input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  background: var(--matcha-bg);
}
.rule-form input:focus { border-color: var(--matcha-light); background: white; }
.rule-form button {
  padding: 12px 18px;
  background: var(--matcha-dark);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.rule-form button:hover { background: var(--matcha-night); }

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rule-item {
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.15s;
}
.rule-item:hover { border-color: var(--matcha-light); }
.rule-item.disabled { opacity: 0.5; }
.rule-item .rule-id {
  font-size: 11px;
  font-weight: 800;
  color: var(--matcha-dark);
  background: var(--matcha-bg);
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.rule-item .rule-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.rule-item .rule-meta {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 4px;
}
.rule-item .rule-meta .auto-badge {
  background: rgba(118, 183, 41, 0.12);
  color: var(--matcha-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  margin-right: 6px;
}
.rule-item .rule-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.rule-item .rule-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.15s;
}
.rule-item .rule-actions button:hover {
  border-color: var(--matcha-light);
  color: var(--matcha-dark);
}
.rule-item .rule-actions button.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.classify-trigger {
  margin-top: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(118, 183, 41, 0.08), rgba(184, 51, 139, 0.06));
  border: 1px dashed rgba(118, 183, 41, 0.3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.classify-trigger .text {
  flex: 1;
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.5;
}
.classify-trigger button {
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--matcha-light), var(--violet));
  color: white;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.classify-trigger button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Agent log */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-entry {
  padding: 12px 14px;
  background: var(--matcha-bg);
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 12px;
}
.log-entry .log-action {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.log-entry.action-star .log-action { background: rgba(232, 185, 35, 0.15); color: var(--gold); }
.log-entry.action-delete .log-action { background: rgba(216, 69, 69, 0.12); color: var(--red); }
.log-entry.action-archive .log-action { background: rgba(74, 123, 196, 0.12); color: var(--blue); }
.log-entry.action-label .log-action { background: rgba(184, 51, 139, 0.12); color: var(--violet); }
.log-entry.action-inbox .log-action { background: rgba(138, 149, 133, 0.15); color: var(--text-mute); }
.log-entry .log-body { flex: 1; }
.log-entry .log-reason { color: var(--text-soft); margin-top: 3px; }
.log-entry .log-time { color: var(--text-mute); font-size: 10px; margin-top: 3px; }
.log-entry .log-pending { color: var(--red); font-weight: 700; font-size: 10px; }

/* AI badge color variants (additional to existing) */
.badge-ai.delete {
  background: rgba(216, 69, 69, 0.12);
  color: var(--red);
}
.badge-ai.pending-delete {
  background: rgba(232, 140, 35, 0.15);
  color: #D87520;
  border: 1px dashed rgba(216, 120, 32, 0.5);
}
.badge-ai.archive {
  background: rgba(74, 123, 196, 0.12);
  color: var(--blue);
}
.badge-ai.star {
  background: rgba(232, 185, 35, 0.15);
  color: var(--gold);
}
.badge-ai.generic {
  background: rgba(184, 51, 139, 0.1);
  color: var(--violet);
}

/* Signatures list */
.sig-item {
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
}
.sig-item .sig-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.sig-item .sig-dot { width: 8px; height: 8px; border-radius: 50%; }
.sig-item .sig-email {
  font-size: 12px;
  font-weight: 700;
  color: var(--matcha-night);
}
.sig-item textarea {
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  resize: vertical;
  outline: none;
  background: var(--matcha-bg);
}
.sig-item textarea:focus { border-color: var(--matcha-light); background: white; }

/* Rich text signature editor */
.sig-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  padding: 6px 8px;
  background: var(--matcha-bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.sig-toolbar button {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-soft);
  font-family: inherit;
  margin: 0;
}
.sig-toolbar button:hover {
  background: white;
  border-color: var(--border);
  color: var(--matcha-dark);
}
.sig-editor {
  min-height: 90px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  background: white;
  color: var(--text);
}
.sig-editor:focus { border-color: var(--matcha-light); }
.sig-editor:empty:before {
  content: 'Např.: S pozdravem, Petr Patočka — Kyosun s.r.o. · www.kyosun.com';
  color: var(--text-mute);
  font-style: italic;
}
.sig-editor a { color: var(--matcha-dark); }
.sig-item button {
  margin-top: 8px;
  padding: 8px 14px;
  background: var(--matcha-dark);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
}
.sig-item button.saved {
  background: var(--matcha-light);
  animation: savedPulse 0.4s;
}
@keyframes savedPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ===== COMPOSE MODAL ===== */
.modal.compose {
  max-width: 1100px;
  max-height: 95vh;
  width: 92vw;
}
.modal.compose .modal-body { padding: 18px 24px 22px; }
.compose-form { display: flex; flex-direction: column; gap: 8px; }
.compose-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 12px;
}
.compose-row label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.compose-row input,
.compose-row select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  background: var(--matcha-bg);
  color: var(--text);
}
.compose-row input:focus, .compose-row select:focus {
  border-color: var(--matcha-light);
  background: white;
}
.compose-row select {
  background: var(--matcha-bg);
  cursor: pointer;
}
.compose-cc-toggle {
  font-size: 11px;
  color: var(--matcha-dark);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 4px 0;
  text-align: left;
  font-family: inherit;
}
.compose-body-wrap { margin-top: 4px; }
.compose-body-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--matcha-bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
}
.compose-body-toolbar button {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-soft);
  font-family: inherit;
}
.compose-body-toolbar button:hover {
  background: white;
  border-color: var(--border);
  color: var(--matcha-dark);
}
.comp-body-editor {
  width: 100%;
  min-height: 420px;
  max-height: 65vh;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  outline: none;
  background: white;
  color: var(--text);
  overflow-y: auto;
}
.comp-body-editor:focus { border-color: var(--matcha-light); }
.comp-body-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--text-mute);
  font-style: italic;
}
.comp-body-editor a { color: var(--matcha-dark); }
.comp-body-editor img { max-width: 100%; height: auto; }
.comp-body-editor blockquote.reply-quote {
  margin: 8px 0 0 0;
  border-left: 3px solid var(--matcha-light);
  padding-left: 12px;
  color: var(--text-soft);
}
.comp-body-editor .reply-quote-header {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-mute);
}
.comp-body-editor .kyosun-sig {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 8px;
}

/* Attachments dropzone */
.attach-zone {
  margin-top: 10px;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  cursor: pointer;
  transition: all 0.15s;
}
.attach-zone:hover, .attach-zone.dragging {
  border-color: var(--matcha-light);
  background: rgba(118, 183, 41, 0.05);
  color: var(--matcha-dark);
}
.attach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--matcha-bg);
  border-radius: 8px;
  font-size: 12px;
}
.attach-item .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.attach-item .size {
  color: var(--text-mute);
  font-size: 11px;
}
.attach-item .remove {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}

.compose-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.compose-footer .send-btn {
  padding: 11px 22px;
  background: linear-gradient(135deg, var(--matcha-light), var(--matcha-dark));
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(56, 121, 49, 0.22);
}
.compose-footer .send-btn:hover { transform: translateY(-1px); }
.compose-footer .send-btn:disabled {
  background: var(--border);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.compose-footer .save-draft-btn {
  padding: 11px 16px;
  background: var(--matcha-bg);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.compose-footer .save-draft-btn:hover { border-color: var(--matcha-light); color: var(--matcha-dark); }
.compose-footer .draft-status {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-mute);
}
.compose-footer .draft-status.saved { color: var(--matcha-dark); }

/* Drafts list */
.draft-item {
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.draft-item:hover { border-color: var(--matcha-light); background: var(--matcha-bg); }
.draft-item .draft-from {
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.draft-item .draft-subject {
  font-size: 14px;
  font-weight: 700;
  color: var(--matcha-night);
  margin-bottom: 4px;
}
.draft-item .draft-preview {
  font-size: 12px;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-item .draft-meta {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-mute);
}
.draft-item .draft-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.draft-item .draft-actions button {
  background: none;
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-soft);
}
.draft-item .draft-actions button.danger:hover { color: var(--red); border-color: var(--red); }

/* AI prompt context box */
.ai-prompt-context {
  margin-top: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(118, 183, 41, 0.06), rgba(184, 51, 139, 0.04));
  border-left: 3px solid var(--matcha-light);
  border-radius: 10px;
}

/* Address autocomplete dropdown */
.autocomplete-dropdown {
  position: fixed;
  background: white;
  border: 1px solid var(--matcha-light);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(28, 51, 24, 0.18);
  max-height: 320px;
  overflow-y: auto;
  z-index: 10000;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
}
.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.selected {
  background: linear-gradient(90deg, rgba(118, 183, 41, 0.12), rgba(118, 183, 41, 0.04));
  color: var(--matcha-dark);
}
.autocomplete-item .ac-email {
  color: var(--text-mute);
  font-weight: 500;
  font-size: 12px;
}
.autocomplete-item.selected .ac-email {
  color: var(--matcha-dark);
}

/* Spam modal */
.spam-context {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(216, 69, 69, 0.06);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

/* Loading spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--matcha-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
