/* Scoped Email presentation; no shared navigation or business-state rules. */
#email { --email-teal: #174b47; --email-muted: #697c76; --email-gold: #b58b4a; color: #24453f; padding-bottom: 24px; }
#email .email-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 28px 32px; background: linear-gradient(115deg, #faf9f3, #f0f5f0); border: 1px solid #dfe7de; border-radius: 18px; margin-bottom: 24px; }
#email .email-eyebrow { color: var(--email-gold); font-size: 13px; letter-spacing: .12em; font-weight: 700; }
#email h2 { margin: 10px 0 12px; color: var(--email-teal); font-size: clamp(24px, 2.5vw, 32px); font-weight: 650; }
#email p { line-height: 1.75; margin: 0; }
#email .email-hero p { color: var(--email-muted); max-width: 550px; }
#email .email-hero-art { flex: 0 0 144px; width: 144px; height: 116px; }
#email .email-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
#email .email-badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 24px; font-size: 13px; background: #fff; border: 1px solid #dde6dc; color: var(--email-teal); }
#email .email-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--email-gold); }
#email .email-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 24px; align-items: stretch; }
#email h3 { margin: 0; font-size: 17px; color: var(--email-teal); }
#email .email-section-head { margin-bottom: 16px; }
#email .email-section-head p { color: var(--email-muted); font-size: 15px; margin-top: 5px; }
#email .email-provider-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
#email .email-provider { padding: 24px 20px; border: 1px solid #e0e7e2; border-radius: 15px; background: #fff; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; min-width: 0; }
#email .email-provider:is([data-email-provider="gmail"],[data-email-provider="outlook"]) { min-height: 248px; box-sizing: border-box; }
#email .email-provider-icon { width: 44px; height: 44px; padding: 10px; border-radius: 12px; background: #f2f6f3; box-sizing: border-box; }
#email .email-provider h4 { font-size: 16px; margin: 0; line-height: 1.5; color: var(--email-teal); }
#email .email-provider p { font-size: 15px; color: var(--email-muted); }
#email .email-provider-kind { font-size: 13px; color: #87683b; background: #fbf5ea; padding: 4px 9px; border-radius: 6px; }
#email .email-provider button { margin-top: auto; width: 100%; padding: 11px 8px; background: #edf2ee; color: #667970; border: 1px solid #dce5de; border-radius: 9px; font-size: 15px; cursor: pointer; opacity: 1; white-space: normal; }
#email .email-provider button:disabled { cursor: not-allowed; }
#email .email-provider small { color: var(--email-muted); font-size: 13px; line-height: 1.6; }
#email .email-connection { padding: 24px; border: 1px solid #dce6dd; border-radius: 15px; background: #fafbf7; min-width: 0; }
#email .email-connection-head { display: flex; align-items: center; gap: 9px; margin-bottom: 28px; }
#email .email-status-icon { display: grid; place-items: center; width: 52px; height: 52px; color: var(--email-teal); background: #eaf1e8; border-radius: 16px; margin-bottom: 16px; }
#email .email-status-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#email #emailStatusTitle { font-size: 18px; margin: 0 0 10px; color: var(--email-teal); }
#email #emailStatusDescription { color: var(--email-muted); font-size: 15px; }
#email .email-account-details { margin: 20px 0 0; border-top: 1px solid #e0e7dd; padding-top: 10px; font-size: 13px; }
#email .email-account-details div { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 10px; padding: 7px 0; }
#email dt { color: var(--email-muted); } #email dd { margin: 0; overflow-wrap: anywhere; }
#email .email-gmail-note { margin-top: 20px; border-top: 1px solid #e0e7dd; padding-top: 16px; color: var(--email-muted); font-size: 13px; }
#email .email-boundary { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px; margin-top: 24px; border-radius: 12px; background: #f7f5ed; border: 1px solid #e9e2d5; }
#email .email-boundary svg { flex: 0 0 22px; width: 22px; height: 22px; fill: none; stroke: #91723f; stroke-width: 1.5; }
#email .email-boundary strong { font-size: 15px; color: #785e36; }
#email .email-boundary p { font-size: 13px; color: var(--email-muted); margin-top: 4px; }
#email[data-state="error"] .email-status-icon { background: #f7eee3; color: #936e38; }
#email[data-state="loading"] .email-status-icon { animation: email-soft-pulse 1.5s ease-in-out infinite; }
@keyframes email-soft-pulse { 50% { opacity: .5; } }
@media (max-width: 1160px) { #email .email-grid { grid-template-columns: minmax(0, 1fr); } #email .email-connection-head { margin-bottom: 18px; } }
@media (max-width: 640px) { #email .email-hero { padding: 24px 20px; } #email .email-hero-art { display: none; } #email .email-provider-cards { grid-template-columns: minmax(0, 1fr); } #email .email-grid { gap: 20px; } }
@media (prefers-reduced-motion: reduce) { #email[data-state="loading"] .email-status-icon { animation: none; } }

/* Email connection sheet uses the same light surface as confirmations. */
#emailImapDialog {
  width:min(440px,calc(100vw - 32px)); max-height:calc(100dvh - 40px); overflow:auto;
  box-sizing:border-box; border:1px solid rgb(255 255 255 / 85%); border-radius:18px;
  padding:26px; background:var(--kd-dialog-surface); color:var(--kd-dialog-ink);
  box-shadow:var(--kd-dialog-shadow); font-family:var(--kd-dialog-font);
  -webkit-backdrop-filter:blur(24px); backdrop-filter:blur(24px);
}
#emailImapDialog::backdrop { background:rgb(20 24 30 / 18%); -webkit-backdrop-filter:blur(4px); backdrop-filter:blur(4px); }
#emailImapDialog header { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom:22px; }
#emailImapDialog h3 { font-size:20px; line-height:1.4; letter-spacing:-.025em; font-weight:600; margin:0; color:var(--kd-dialog-ink); }
#emailImapDialog #emailImapClose {
  display:grid; place-items:center; background:rgb(118 118 128 / 10%); color:#757579;
  border:0; border-radius:50%; width:28px; height:28px; min-height:0; line-height:1;
  font:22px/1 var(--kd-dialog-font); padding:0; flex-shrink:0; box-shadow:none;
}
#emailImapDialog #emailImapClose:hover { background:rgb(118 118 128 / 17%); }
#emailImapDialog p { line-height:1.6; }
#emailImapDialog label { display:flex; flex-direction:column; gap:7px; font-size:13px; font-weight:500; color:#55555a; margin-top:15px; }
#emailImapDialog input:not([type=checkbox]),#emailImapDialog select {
  width:100%; box-sizing:border-box; padding:10px 12px; min-height:42px;
  border:1px solid rgb(60 60 67 / 15%); border-radius:10px; background:rgb(255 255 255 / 88%);
  color:var(--kd-dialog-ink); min-width:0; font:15px/1.4 var(--kd-dialog-font); box-shadow:none;
}
#emailImapDialog input:focus,#emailImapDialog select:focus { border-color:var(--kd-dialog-accent); outline:2px solid var(--kd-dialog-focus); outline-offset:0; }
#emailImapDialog .email-imap-help { font-size:12px; font-weight:400; color:var(--kd-dialog-secondary); margin:9px 0 16px; }
#emailImapDialog .email-imap-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 14px; }
#emailImapDialog .email-imap-wide { grid-column:1 / -1; }
#emailImapDialog details { border-top:1px solid rgb(60 60 67 / 10%); padding-top:14px; margin-top:18px; font-size:13px; }
#emailImapDialog summary { cursor:pointer; margin-bottom:10px; color:var(--kd-dialog-secondary); }
#emailImapDialog #emailImapResult { font-size:13px; line-height:1.6; color:#b43b31; overflow-wrap:anywhere; margin:12px 0; }
#emailImapDialog #emailImapResult:empty,#emailImapDialog #emailImapDiscovery:empty { display:none; }
#emailImapDialog .email-imap-support-link { display:inline-block; margin-inline-start:.5em; color:var(--kd-dialog-accent); font-weight:500; text-decoration:none; white-space:nowrap; }
#emailImapDialog .email-imap-support-link:hover { text-decoration:underline; }
#emailImapDialog .email-imap-support-link:focus-visible,#emailImapDialog button:focus-visible { outline:2px solid var(--kd-dialog-accent); outline-offset:3px; }
#emailImapDialog #emailImapSubmit {
  width:100%; min-height:38px; padding:9px 14px; border:0; background:var(--kd-dialog-accent); color:#fff;
  border-radius:10px; font:500 14px/1.4 var(--kd-dialog-font); box-shadow:none; margin-top:4px;
}
#emailImapDialog #emailImapSubmit:hover:not(:disabled) { background:var(--kd-dialog-accent-hover); }
#emailImapDialog button:disabled { opacity:.42; cursor:not-allowed; }
#emailImapActions { display:flex; flex-wrap:wrap; gap:8px; margin-top:16px; }
#emailImapActions[hidden] { display:none; }
#emailImapActions button { font-size:12px; padding:8px 10px; border:1px solid #cad9ce; border-radius:7px; background:#fff; color:#174b47; }
#emailImapActions button:disabled { opacity:.5; cursor:not-allowed; }
@media(max-width:600px) { #emailImapDialog { padding:20px; } #emailImapDialog .email-imap-grid { grid-template-columns:minmax(0,1fr); } }

/* Account management follows Kedola teal/ivory surfaces; safe at narrow widths. */
#email .email-connection { min-width:0; }
#email .email-connection-head { flex-wrap:wrap;gap:10px; }
#emailAccountCount { color:#56756a;font-size:.875rem;margin-left:auto; }
#emailAddAccount { padding:6px 10px;font-size:.875rem; }
#email .email-account-list { display:grid;gap:12px;margin-top:20px; }
#email .email-account-card { border:1px solid #d7e1d7;border-radius:14px;padding:16px;background:#fffdf7;min-width:0; }
#email .email-account-heading { display:flex;gap:10px;align-items:flex-start;justify-content:space-between; }
#email .email-account-heading h4 { margin:0;font-size:1rem;color:#174b47;overflow-wrap:anywhere; }
#email .email-account-badge { flex-shrink:0;padding:3px 8px;background:#e6eee6;color:#295f52;border-radius:20px;font-size:.8125rem; }
#email .email-account-provider { color:#537366;font-size:.875rem;margin:9px 0; }
#email .email-account-sync,#email .email-account-note { color:#6d776d;font-size:.875rem;line-height:1.65;overflow-wrap:anywhere;margin:6px 0; }
#email .email-account-actions { display:flex;gap:8px;flex-wrap:wrap;margin-top:13px; }
#email .email-account-actions button { padding:6px 9px;font-size:.875rem; }
#email .email-account-actions button:last-child { color:#74684b;background:#f3efdf;border-color:#dfd4b7; }
@media(max-width:600px) {
 #email .email-account-heading { flex-direction:column;gap:7px; }
 #email .email-account-card { padding:13px; }
}

#emailImapDialog fieldset { margin:14px 0 0; padding:0; border:0; min-width:0; }

#email .email-gmail-authorize { align-self:stretch; display:block; padding:12px 16px; border-radius:10px; background:#174b47; color:#fff; text-align:center; text-decoration:none; font-size:14px; font-weight:600; margin-top:12px; }
#email .email-gmail-authorize[hidden] { display:none; }
#email .email-gmail-authorize:focus-visible { outline:1px solid var(--kd-focus-ring, #577f73); outline-offset:2px; }
#email #emailGmailTestResult { font-size:14px; line-height:1.7; overflow-wrap:anywhere; }

#email :is(#emailGmailTestConnect,#emailGmailTestCheck):not(:disabled) { background:#174b47; color:#fff; border-color:#174b47; }
