:root {
  color-scheme: light;
  --ink: #10211f;
  --muted: #667571;
  --canvas: #f1f3ee;
  --card: rgba(255, 255, 252, .92);
  --white: #ffffff;
  --brand: #0a3a36;
  --brand-2: #155a50;
  --brand-3: #2f7a69;
  --mint: #dcebe4;
  --mint-2: #edf5f1;
  --line: rgba(16, 33, 31, .11);
  --red: #9b3a35;
  --red-soft: #f8e5e1;
  --gold: #c9a45f;
  --yellow: #f2c94c;
  --yellow-soft: #fff7d2;
  --yellow-border: #e4c457;
  --shadow-sm: 0 8px 24px rgba(10, 42, 37, .07);
  --shadow-lg: 0 24px 70px rgba(10, 42, 37, .12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(circle at 10% 0%, rgba(111, 169, 145, .18), transparent 32rem), radial-gradient(circle at 90% 18%, rgba(201, 164, 95, .11), transparent 28rem); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(2.3rem, 6vw, 4.25rem); line-height: .98; letter-spacing: -.055em; font-weight: 760; }
h2 { margin: 0; font-size: 1.55rem; line-height: 1.15; letter-spacing: -.025em; }
h3 { margin: 0; font-size: 1rem; }
.muted { color: var(--muted); }
.compact { margin: 5px 0; font-size: .88rem; }
.eyebrow { margin: 20px 0 8px; color: var(--brand-2); font-size: .7rem; font-weight: 850; letter-spacing: .16em; }
.eyebrow.light { margin-top: 0; color: rgba(255,255,255,.66); }

label { display: block; margin: 20px 0 7px; font-size: .8rem; font-weight: 750; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; color: var(--ink); background: rgba(255,255,255,.94); outline: none; transition: border-color .2s, box-shadow .2s, background .2s; }
input:focus, textarea:focus { border-color: var(--brand-3); background: #fff; box-shadow: 0 0 0 4px rgba(47,122,105,.12); }
textarea { resize: vertical; line-height: 1.55; }
button { border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 780; transition: transform .15s, background .2s, box-shadow .2s; }
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { cursor: default; opacity: .6; transform: none; }
.primary { color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--brand)); box-shadow: 0 8px 20px rgba(10,58,54,.18); }
.primary:hover { box-shadow: 0 10px 24px rgba(10,58,54,.25); }
.secondary { color: var(--brand); background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.quiet { color: var(--ink); background: transparent; }
.danger { color: #fff; background: var(--red); }
.full { width: 100%; margin-top: 22px; padding: 14px 18px; }

.login-page { background: var(--canvas); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; }
.login-card { width: min(100%, 460px); padding: 36px 38px 26px; text-align: center; background: rgba(255,255,252,.88); border: 1px solid rgba(255,255,255,.76); border-radius: 32px; box-shadow: var(--shadow-lg); backdrop-filter: blur(22px); }
.login-logo { width: min(230px, 76%); height: auto; display: block; margin: -12px auto 10px; }
.login-card h1 { font-size: clamp(2rem, 8vw, 3rem); }
.login-intro { max-width: 350px; margin: 13px auto 24px; line-height: 1.6; }
.login-card form { text-align: left; }
.login-foot { margin: 22px 0 0; color: #7b8884; font-size: .72rem; letter-spacing: .06em; }

.setup-shell { min-height: 100vh; display: grid; place-items: start center; padding: 28px 18px 60px; }
.setup-card { width: min(100%, 650px); padding: 36px; background: var(--card); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow-lg); }
.setup-card h2 { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; color: #fff; background: var(--brand); font-size: 25px; font-weight: 850; box-shadow: var(--shadow-sm); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 17px; }

.topbar { position: sticky; z-index: 10; top: 0; display: flex; justify-content: space-between; align-items: center; min-height: 74px; padding: max(12px, env(safe-area-inset-top)) max(22px, calc((100vw - 1120px)/2)); background: rgba(241,243,238,.78); border-bottom: 1px solid rgba(16,33,31,.07); backdrop-filter: blur(22px) saturate(130%); }
.brand { display: inline-flex; gap: 11px; align-items: center; color: var(--ink); text-decoration: none; }
.brand-icon { width: 44px; height: 44px; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(10,58,54,.11); border-radius: 14px; background: #f0f1ec; box-shadow: var(--shadow-sm); }
.brand-icon img { width: 100%; height: 100%; object-fit: cover; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 1.02rem; letter-spacing: -.02em; }
.brand-copy small { color: var(--muted); font-size: .69rem; }
.logout-button { padding-inline: 12px; color: var(--muted); }
.logout-button:hover { color: var(--ink); background: rgba(255,255,255,.7); }
.topbar-actions { display: flex; align-items: center; gap: 5px; }
.nav-link { padding: 10px 12px; border-radius: 12px; color: var(--brand); text-decoration: none; font-size: .88rem; font-weight: 780; }
.nav-link:hover { background: rgba(255,255,255,.7); }

.app-shell { width: min(calc(100% - 36px), 1120px); margin: 0 auto; padding: 34px 0 calc(82px + env(safe-area-inset-bottom)); }
.hero { position: relative; isolation: isolate; display: flex; justify-content: space-between; gap: 36px; align-items: flex-end; min-height: 250px; margin-bottom: 24px; padding: clamp(28px, 5vw, 48px); overflow: hidden; color: #fff; border-radius: 32px; background: radial-gradient(circle at 85% -10%, rgba(142,201,176,.32), transparent 40%), linear-gradient(135deg, #123f3a, #082927 72%); box-shadow: var(--shadow-lg); }
.hero::after { content: ""; position: absolute; z-index: -1; right: -72px; bottom: -132px; width: 340px; height: 340px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; box-shadow: 0 0 0 44px rgba(255,255,255,.025), 0 0 0 88px rgba(255,255,255,.018); }
.hero-copy { max-width: 650px; }
.hero-meta { margin: 18px 0 0; color: rgba(255,255,255,.7); font-size: .93rem; }
.hero-actions { display: grid; justify-items: end; gap: 14px; flex: 0 0 auto; }
.status-dot { display: inline-flex; align-items: center; gap: 8px; color: rgba(255,255,255,.73); font-size: .76rem; font-weight: 700; }
.status-dot i { width: 8px; height: 8px; border-radius: 50%; background: #77d6a6; box-shadow: 0 0 0 5px rgba(119,214,166,.12); }

.install-tip, .alert { border-radius: 15px; padding: 13px 15px; }
.install-tip { margin: 0 0 20px; color: #5d4a21; background: #fff5d9; border: 1px solid #ead59f; }
.alert.error { color: #7d281f; background: var(--red-soft); border: 1px solid #ebc7c1; }
.alert.success { color: var(--brand); background: var(--mint); border: 1px solid #bfd7cc; }
.button-link { display: inline-block; margin-top: 14px; padding: 12px 16px; border-radius: 13px; text-decoration: none; font-weight: 780; }

.digest-card { margin-bottom: 18px; padding: clamp(22px, 4vw, 32px); background: var(--card); border: 1px solid rgba(255,255,255,.85); border-radius: 26px; box-shadow: var(--shadow-sm); backdrop-filter: blur(16px); }
.digest-card.older { box-shadow: none; background: rgba(255,255,252,.68); }
.digest-head, .mail-top { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.digest-head .eyebrow { margin-top: 0; }
.badge { flex: 0 0 auto; padding: 7px 11px; color: var(--brand); background: var(--mint); border-radius: 999px; font-size: .73rem; font-weight: 850; }
.badge.reply { color: #84352e; background: var(--red-soft); }
.badge.noise { color: #69500b; background: #ffe89a; }
.badge.important { color: #fff; background: #b24b3e; box-shadow: 0 5px 14px rgba(155,58,53,.18); }
.badge.answered { color: #155a50; background: #dcefe5; }
.digest-copy { margin: 20px 0; font-size: 1.04rem; line-height: 1.65; }
.account-status-list { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 22px; }
.account-status { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; font-size: .75rem; font-weight: 760; }
.account-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.account-status.ok { color: var(--brand-2); background: var(--mint-2); }
.account-status.error { color: var(--red); background: var(--red-soft); }
.account-status.skipped { color: #766027; background: #fff5d9; }
.section-title { margin: 28px 0 11px; color: var(--brand); }
.mail-list { display: grid; gap: 11px; }
.mail-item { padding: 18px; background: rgba(255,255,255,.86); border: 1px solid var(--line); border-radius: 18px; transition: border-color .2s, box-shadow .2s; }
.mail-item:hover { border-color: rgba(21,90,80,.24); box-shadow: 0 8px 20px rgba(10,42,37,.055); }
.mail-item.noise-item { background: linear-gradient(145deg, rgba(255,251,229,.96), rgba(255,255,255,.92)); border-color: rgba(201,164,95,.34); }
.mail-item.important-item { background: linear-gradient(145deg, rgba(255,246,241,.98), rgba(255,255,255,.94)); border-color: rgba(178,75,62,.34); box-shadow: inset 4px 0 0 #b24b3e; }
.mail-item.handled { opacity: .72; }
.mail-item > p { line-height: 1.55; }
.notification-summary { max-width: 720px; font-size: 1.04rem; line-height: 1.45; }
.notification-source { margin-bottom: 0; }
.mail-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.action-line { color: var(--brand-2); font-weight: 680; }
.noise-reason { margin-bottom: 0; color: #715b1f; font-size: .88rem; }
.noise-title { color: #735915; }
.mail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mail-action-button { min-width: 104px; padding: 10px 14px; font-size: .84rem; }
.delete-button { color: var(--red); background: var(--red-soft); }
.flag-button { color: #74580d; background: var(--yellow-soft); }
.flag-button.is-flagged { color: #594302; background: #ffe18a; opacity: 1; }
.reply-button { margin-left: auto; color: #fff; background: var(--brand-2); }
.spam-actions { display: grid; }
.spam-button { width: 100%; padding: 14px 18px; color: #4b3900; background: linear-gradient(135deg, #ffd964, var(--yellow)); border: 1px solid var(--yellow-border); box-shadow: 0 7px 18px rgba(169,126,0,.16); font-size: .94rem; }
.spam-button:hover { box-shadow: 0 9px 22px rgba(169,126,0,.24); }
.handled-note { display: inline-flex; align-items: center; padding: 9px 12px; color: var(--muted); background: rgba(102,117,113,.1); border-radius: 11px; font-size: .82rem; font-weight: 760; }
.batch-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; padding-top: 19px; border-top: 1px solid var(--line); }
.batch-log-link { color: var(--muted); text-decoration: none; font-size: .82rem; font-weight: 720; }
.batch-log-link:hover { color: var(--brand); }
.complete-button { min-width: 132px; padding: 13px 24px; color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--brand)); box-shadow: 0 8px 20px rgba(10,58,54,.18); letter-spacing: .06em; }
.complete-button:hover { box-shadow: 0 10px 24px rgba(10,58,54,.25); }
.small-button { padding: 8px 12px; font-size: .82rem; }
details { margin-top: 19px; padding-top: 16px; color: var(--muted); border-top: 1px solid var(--line); }
details summary { cursor: pointer; font-weight: 720; }
details li { margin: 8px 0; }
.empty-state, .loading { padding: 48px 24px; text-align: center; color: var(--muted); }
.loading { display: flex; justify-content: center; align-items: center; gap: 10px; }
.spinner { width: 17px; height: 17px; border: 2px solid rgba(10,58,54,.18); border-top-color: var(--brand-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { width: min(740px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; color: var(--ink); background: rgba(255,255,252,.98); border: 0; border-radius: 26px; box-shadow: 0 28px 90px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(5,25,23,.65); backdrop-filter: blur(6px); }
.dialog-card { padding: 26px; overflow: auto; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head .eyebrow { margin-top: 0; }
.icon-button { padding: 4px 10px; background: transparent; font-size: 1.8rem; font-weight: 400; }
.inline-action { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.preview { margin-top: 16px; padding: 15px; background: #fff7d8; border: 1px solid #dec879; border-radius: 15px; }
.preview p { margin: 7px 0; }
.warning-copy { color: #7d381f; font-weight: 760; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); padding: 12px 16px; color: #fff; background: var(--brand); border-radius: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 30px); transition: .2s; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error-toast { background: var(--red); }

.log-shell { width: min(calc(100% - 36px), 980px); margin: 0 auto; padding: 38px 0 calc(82px + env(safe-area-inset-bottom)); }
.log-hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; padding: 30px 34px; color: #fff; border-radius: 26px; background: linear-gradient(135deg, #123f3a, #082927); box-shadow: var(--shadow-lg); }
.log-hero h1 { font-size: clamp(2.1rem, 7vw, 3.5rem); }
.log-hero p { margin-bottom: 0; color: rgba(255,255,255,.7); }
.log-list { display: grid; gap: 16px; }
.log-batch { padding: 24px; background: var(--card); border: 1px solid rgba(255,255,255,.85); border-radius: 22px; box-shadow: var(--shadow-sm); }
.log-batch-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.log-batch-head .eyebrow { margin-top: 0; }
.log-digest { margin: 16px 0 18px; color: var(--muted); line-height: 1.55; }
.log-items { display: grid; gap: 9px; }
.log-item { padding: 15px 16px; background: rgba(255,255,255,.78); border: 1px solid var(--line); border-radius: 15px; }
.log-item.important-log-item { border-left: 4px solid #b24b3e; }
.log-item h3 { line-height: 1.4; }
.log-item-meta { margin: 6px 0 10px; color: var(--muted); font-size: .78rem; }
.log-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.log-action { padding: 6px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.log-action.done { color: var(--brand); background: var(--mint); }
.log-action.moved { color: #7d281f; background: var(--red-soft); }
.log-action.spam { color: #69500b; background: #ffe89a; }
.log-action.none { color: var(--muted); background: rgba(102,117,113,.1); }
.log-completed { margin: 8px 0 0; color: var(--muted); font-size: .78rem; }

@media (max-width: 720px) {
  .topbar { min-height: 66px; padding-inline: 14px; }
  .brand-icon { width: 40px; height: 40px; border-radius: 12px; }
  .brand-copy small { display: none; }
  .app-shell { width: min(calc(100% - 22px), 1120px); padding-top: 18px; }
  .hero { display: grid; align-items: start; min-height: 0; gap: 30px; padding: 28px 22px; border-radius: 24px; }
  .hero h1 { font-size: clamp(2.35rem, 13vw, 3.4rem); }
  .hero-actions { justify-items: stretch; }
  .status-dot { justify-self: start; }
  .hero-actions button { width: 100%; }
  .digest-card { border-radius: 21px; }
  .mail-top { display: grid; gap: 9px; }
  .badge.reply { justify-self: start; }
  .badge.noise { justify-self: start; }
  .mail-badges { justify-content: flex-start; }
  .mail-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .reply-button { grid-column: 1 / -1; width: 100%; margin-left: 0; }
  .spam-actions { grid-template-columns: 1fr; }
  .inline-action { grid-template-columns: 1fr; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .dialog-actions .danger { grid-column: 1 / -1; }
  .batch-actions { display: grid; }
  .complete-button { width: 100%; }
  .log-shell { width: min(calc(100% - 22px), 980px); padding-top: 18px; }
  .log-hero { display: grid; padding: 26px 22px; border-radius: 22px; }
  .log-batch { padding: 19px; }
  .log-batch-head { display: grid; gap: 10px; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 22px 24px; border-radius: 25px; }
  .login-logo { width: min(210px, 78%); }
  .logout-button { font-size: .82rem; }
  .digest-head { display: grid; gap: 12px; }
  .digest-head .badge { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
