From eba921ab7ac35e3abc6d8551a78f629317600ce2 Mon Sep 17 00:00:00 2001 From: Meghdad <61308304+MeghdadFadaee@users.noreply.github.com> Date: Wed, 12 Aug 2026 23:25:01 +0330 Subject: [PATCH] initial --- .dockerignore | 26 + .editorconfig | 18 + .env.example | 5 + .gitattributes | 12 + .github/ISSUE_TEMPLATE/bug_report.yml | 49 + .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/feature_request.yml | 23 + .github/dependabot.yml | 24 + .github/pull_request_template.md | 17 + .github/workflows/ci.yml | 52 + .github/workflows/dependency-review.yml | 16 + .gitignore | 47 + CHANGELOG.md | 22 + CONTRIBUTING.md | 42 + Dockerfile | 29 + LICENSE | 10 + LICENSES/AGPL-3.0-source-offer.txt | 11 + README.md | 170 + SECURITY.md | 31 + THIRD_PARTY_NOTICES.md | 21 + api/openapi.yaml | 228 + app/globals.css | 220 + app/page.tsx | 646 +++ cmd/mailctl/main.go | 653 +++ cmd/mailctl/main_test.go | 9 + cmd/meovv-mail/main.go | 83 + compose.yaml | 86 + deploy/caddy/Caddyfile | 26 + docs/architecture.md | 38 + docs/operations.md | 40 + docs/security.md | 29 + eslint.config.mjs | 41 + go.mod | 18 + go.sum | 49 + internal/app/session.go | 41 + internal/app/session_test.go | 25 + internal/config/config.go | 132 + internal/httpapi/server.go | 886 +++ internal/httpapi/server_test.go | 33 + internal/mailer/mime.go | 150 + internal/mailer/mime_test.go | 50 + internal/mailer/smtp.go | 92 + internal/stalwart/client.go | 154 + internal/store/store.go | 623 +++ internal/store/store_test.go | 90 + internal/webhook/dispatcher.go | 139 + internal/webhook/dispatcher_test.go | 67 + package-lock.json | 5615 ++++++++++++++++++++ package.json | 42 + release/compatibility.json | 14 + release/compatibility.pub | 3 + release/compatibility.sig | 1 + tests/rendered-html.test.mjs | 36 + tsconfig.json | 22 + vite.frontend.config.ts | 12 + web/index.html | 20 + web/main.tsx | 6 + web/public/favicon.svg | 1 + web/public/meovv-mail-social.png | Bin 0 -> 785739 bytes 59 files changed, 11046 insertions(+) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 .env.example create mode 100644 .gitattributes create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/dependency-review.yml create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 LICENSES/AGPL-3.0-source-offer.txt create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 THIRD_PARTY_NOTICES.md create mode 100644 api/openapi.yaml create mode 100644 app/globals.css create mode 100644 app/page.tsx create mode 100644 cmd/mailctl/main.go create mode 100644 cmd/mailctl/main_test.go create mode 100644 cmd/meovv-mail/main.go create mode 100644 compose.yaml create mode 100644 deploy/caddy/Caddyfile create mode 100644 docs/architecture.md create mode 100644 docs/operations.md create mode 100644 docs/security.md create mode 100644 eslint.config.mjs create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/app/session.go create mode 100644 internal/app/session_test.go create mode 100644 internal/config/config.go create mode 100644 internal/httpapi/server.go create mode 100644 internal/httpapi/server_test.go create mode 100644 internal/mailer/mime.go create mode 100644 internal/mailer/mime_test.go create mode 100644 internal/mailer/smtp.go create mode 100644 internal/stalwart/client.go create mode 100644 internal/store/store.go create mode 100644 internal/store/store_test.go create mode 100644 internal/webhook/dispatcher.go create mode 100644 internal/webhook/dispatcher_test.go create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 release/compatibility.json create mode 100644 release/compatibility.pub create mode 100644 release/compatibility.sig create mode 100644 tests/rendered-html.test.mjs create mode 100644 tsconfig.json create mode 100644 vite.frontend.config.ts create mode 100644 web/index.html create mode 100644 web/main.tsx create mode 100644 web/public/favicon.svg create mode 100644 web/public/meovv-mail-social.png diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..16baf86 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,26 @@ +.git +.github +.idea +.vscode +.next +.vinext +.wrangler +dist +web-dist +node_modules +data +backups +coverage +secrets +.env +.env.* +*.db +*.sqlite +*.pem +*.key +*.log +mailctl +meovv-mail +README.md +docs +tests diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..929199f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[*.go] +indent_style = tab + +[Makefile] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..94c8b78 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# Documentation only. Run `mailctl init`; do not deploy this file as `.env`. +MEOVV_VERSION=0.1.0 +MAIL_HOSTNAME=mail.example.com +STALWART_RECOVERY_ADMIN= +API_SUBMISSION_USER= diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c953812 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +* text=auto eol=lf + +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.woff binary +*.woff2 binary + +package-lock.json linguist-generated=true +go.sum linguist-generated=true diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..1df5210 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,49 @@ +name: Bug report +description: Report a reproducible problem in MEOVV Mail +title: "[Bug]: " +labels: [bug] +body: + - type: markdown + attributes: + value: Do not report vulnerabilities or include credentials, message content, or customer data here. Use the private process in SECURITY.md. + - type: input + id: version + attributes: + label: MEOVV Mail version or commit + placeholder: v0.1.0 or commit SHA + validations: + required: true + - type: dropdown + id: platform + attributes: + label: Platform + options: + - Ubuntu 24.04 amd64 + - Ubuntu 24.04 arm64 + - Debian 13 amd64 + - Debian 13 arm64 + - Development workstation + - Other + validations: + required: true + - type: textarea + id: description + attributes: + label: What happened? + description: Include expected behavior and sanitized reproduction steps. + validations: + required: true + - type: textarea + id: diagnostics + attributes: + label: Sanitized diagnostics + description: Include relevant `mailctl doctor` results or logs after removing sensitive data. + - type: checkboxes + id: checks + attributes: + label: Safety checks + options: + - label: I removed credentials, domains, IP addresses, mailbox content, and customer information. + required: true + - label: This is not a security vulnerability. + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..ba2dd1f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,23 @@ +name: Feature request +description: Suggest a product or operational improvement +title: "[Feature]: " +labels: [enhancement] +body: + - type: textarea + id: problem + attributes: + label: Problem + description: What user or operator problem should be solved? + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Proposed behavior + description: Describe the desired outcome and any compatibility constraints. + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Alternatives considered diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f017a4c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,24 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + - package-ecosystem: gomod + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + - package-ecosystem: docker + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 3 + ignore: + - dependency-name: stalwartlabs/stalwart + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly + open-pull-requests-limit: 3 diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..d3b9af7 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +## Summary + +Describe the problem and the outcome of this change. + +## Verification + +- [ ] `npm run check` +- [ ] `go test ./cmd/... ./internal/...` +- [ ] `go vet ./cmd/... ./internal/...` +- [ ] Relevant browser, contract, or Compose checks + +## Release impact + +- [ ] Documentation and OpenAPI are updated where required. +- [ ] No credentials, personal data, runtime state, or generated output is included. +- [ ] Stalwart version/digest and compatibility policy are unchanged, or the required contract and release review is included. +- [ ] Security, migration, backup, and rollback effects are described below. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f5c9d37 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + frontend: + name: Frontend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - run: npm ci --ignore-scripts + - run: npm run check + - run: npm audit --omit=dev --audit-level=high + + backend: + name: Go backend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + - run: go test ./cmd/... ./internal/... + - run: go vet ./cmd/... ./internal/... + - run: go build ./cmd/... + + appliance: + name: Appliance bundle + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Validate Compose configuration + env: + MAIL_HOSTNAME: mail.example.com + run: docker compose config --quiet + - name: Build the application image + run: docker build --tag meovv-mail:ci . diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..d65bbc7 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,16 @@ +name: Dependency review + +on: + pull_request: + +permissions: + contents: read + +jobs: + review: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/dependency-review-action@v4 + with: + fail-on-severity: high diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6b9e3a --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# Dependencies and generated frontend output +/node_modules/ +/web-dist/ +/dist/ +/coverage/ +*.tsbuildinfo + +# Runtime state and credentials +.env +.env.* +!.env.example +/secrets/ +/data/ +/backups/ +*.db +*.db-shm +*.db-wal +*.sqlite +*.sqlite-shm +*.sqlite-wal +*.pem +*.key + +# Local binaries and diagnostic output +/mailctl +/meovv-mail +/outputs/ +/work/ +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# Editors and operating systems +.DS_Store +.idea/ +.vscode/ +*.swp +*~ + +# Legacy/local preview tooling +/.next/ +/.vinext/ +/.wrangler/ +/.openai/ +/public/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..64227d4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,22 @@ +# Changelog + +All notable project changes will be recorded here. This project follows +[Semantic Versioning](https://semver.org/) after the first stable release. + +## [Unreleased] + +### Added + +- Initial three-container self-hosted appliance architecture. +- React/Vite mailbox, setup, authentication, and administration interfaces. +- Go control plane, REST send API, JMAP session proxy, delivery events, and + signed webhook delivery. +- SQLite state store, `mailctl` operations, signed compatibility manifest, + OpenAPI contract, and operator documentation. + +### Security + +- OAuth authorization code flow with PKCE and encrypted server-side tokens. +- Hashed, scoped, sender-bound API keys and encrypted webhook secrets. +- HTML sanitization, remote-content blocking, CSRF defenses, webhook SSRF + controls, and strict public protocol exposure. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b189d7b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,42 @@ +# Contributing + +Thank you for helping improve MEOVV Mail. + +## Before opening a change + +- Search existing issues and pull requests. +- Use a discussion or feature request for substantial product or protocol + changes before investing in an implementation. +- Use the private process in `SECURITY.md` for vulnerabilities. +- Never commit real domains, credentials, mailbox content, database files, + backups, or customer logs. + +The MEOVV product layer is currently published under an all-rights-reserved +license. Opening a pull request does not change ownership of your contribution +or grant the project additional rights. Maintainers may ask for a separate +contribution agreement before accepting code. Issue reports and documentation +corrections are welcome while that policy is finalized. + +## Development checks + +Install Node.js 22+, Go 1.24+, and Docker with Compose. Then run: + +```bash +npm ci +npm run check +go test ./cmd/... ./internal/... +go vet ./cmd/... ./internal/... +go build ./cmd/... +MAIL_HOSTNAME=mail.example.com docker compose config --quiet +docker build -t meovv-mail:local . +``` + +Changes to Stalwart integration must also pass contract tests against the exact +image and digest in `compose.yaml`. Do not update that image independently of +the signed compatibility manifest. + +## Pull requests + +Keep changes focused, add tests for changed behavior, update public contracts +and operational documentation, and explain security or compatibility effects. +Generated output, local environment files, and secrets must remain untracked. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d476df2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# syntax=docker/dockerfile:1.7 +FROM node:22.23.1-alpine AS web-builder +WORKDIR /src +COPY package.json package-lock.json ./ +RUN npm ci +COPY app ./app +COPY web ./web +COPY vite.frontend.config.ts tsconfig.json ./ +RUN npm run build:web + +FROM golang:1.26.5-alpine AS go-builder +WORKDIR /src +RUN apk add --no-cache ca-certificates +COPY go.mod go.sum ./ +RUN go mod download +COPY cmd ./cmd +COPY internal ./internal +RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/meovv-mail ./cmd/meovv-mail && \ + CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/mailctl ./cmd/mailctl + +FROM alpine:3.22 +RUN apk add --no-cache ca-certificates tzdata && addgroup -S -g 2001 meovv && adduser -S -D -H -u 2001 -G meovv meovv +COPY --from=go-builder /out/meovv-mail /usr/local/bin/meovv-mail +COPY --from=go-builder /out/mailctl /usr/local/bin/mailctl +COPY --from=web-builder /src/web-dist /app/web +RUN mkdir -p /var/lib/meovv-mail && chown -R meovv:meovv /var/lib/meovv-mail +USER meovv +EXPOSE 8080 +ENTRYPOINT ["/usr/local/bin/meovv-mail"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..77963a2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,10 @@ +Copyright (c) 2026 MEOVV Mail authors + +All rights reserved. + +No permission is granted to use, copy, modify, merge, publish, distribute, +sublicense, or sell any portion of this software except under a separate +written agreement with the copyright holder. + +Third-party components remain subject to their own license terms. See +THIRD_PARTY_NOTICES.md and the LICENSES directory. diff --git a/LICENSES/AGPL-3.0-source-offer.txt b/LICENSES/AGPL-3.0-source-offer.txt new file mode 100644 index 0000000..f6597f3 --- /dev/null +++ b/LICENSES/AGPL-3.0-source-offer.txt @@ -0,0 +1,11 @@ +Stalwart Mail Server v0.16.17 is distributed unmodified under the GNU Affero +General Public License, version 3. The complete corresponding source for the +exact distributed version is available at: + +https://github.com/stalwartlabs/stalwart/tree/v0.16.17 + +The image digest used by this release is: +sha256:a8108e19bd927e172d4d8c128907b8dfc93fd180ae8ee07dccdd42cb97eb9dfa + +This notice does not replace the license text or legal review required for a +customer distribution. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9bc35c5 --- /dev/null +++ b/README.md @@ -0,0 +1,170 @@ +# MEOVV Mail + +![MEOVV Mail — private email, beautifully run](web/public/meovv-mail-social.png) + +MEOVV Mail is a single-tenant, self-hosted email appliance for one organization. +It combines a polished web inbox and administration experience with a pinned Stalwart mail core, +a Go control plane, and automatic HTTPS through Caddy. + +> [!IMPORTANT] +> MEOVV Mail is pre-1.0 software under active development. The architecture, +> UI, API contract, and local test suite are implemented, but a release must not +> be used for production correspondence until the Stalwart contract suite, +> open-relay/security review, supported-Linux restore drills, and documented +> performance acceptance tests pass for that exact release. + +Version `0.1.0` targets one Linux host, multiple domains, and up to 500 local users. +It exposes SMTP on 25/465/587, IMAP over TLS on 993, JMAP and OAuth over HTTPS, +and a scoped REST send API. POP3 and plaintext IMAP are not published. + +## Architecture + +The production bundle runs exactly three containers: + +- `caddy` terminates public TLS, publishes discovery routes, and sends product traffic to MEOVV. +- `meovv` serves the web application, encrypted OAuth sessions, REST API, setup, delivery metadata, webhook jobs, audit events, and operational endpoints. +- `stalwart` stores accounts and all mailbox data and provides SMTP, IMAP, JMAP, filtering, queues, and delivery telemetry. + +Stalwart is pinned to `v0.16.17` and multi-architecture digest `sha256:a8108e19bd927e172d4d8c128907b8dfc93fd180ae8ee07dccdd42cb97eb9dfa`. +Mail bodies and attachments never enter the MEOVV SQLite database. + +## Host requirements + +- Ubuntu 24.04 or Debian 13 on amd64 or arm64 +- Docker Engine with the Compose plugin +- 4 vCPU, 8 GB RAM, and SSD storage for the reference 500-account deployment +- A public static IP and control of DNS for direct delivery +- Inbound TCP 25, 80, 443, 465, 587, and 993 +- Outbound TCP 25, or an authenticated TLS smart host + +Direct delivery also needs working reverse DNS and acceptable IP reputation. If the hosting provider blocks port 25 or cannot set PTR, use relay mode. + +## Install + +Build the local operator utility, initialize the bundle, and start it: + +```bash +go build -o mailctl ./cmd/mailctl +./mailctl init --hostname mail.example.com +docker compose up -d --build +``` + +`mailctl init` prints a one-time browser bootstrap token and temporary Stalwart recovery credential. Store both securely. Visit `https://mail.example.com`, complete the three-step wizard, and save the one-time result shown on the final screen. + +After setup: + +```bash +docker compose restart stalwart meovv +./mailctl doctor --hostname mail.example.com +``` + +Sign in with the permanent Stalwart administrator, create the dedicated `API_SUBMISSION_USER` account referenced by `.env`, put that account's application password in `secrets/api_submission_password`, verify REST submission, then remove the recovery backdoor: + +```bash +./mailctl harden +``` + +Never leave `STALWART_RECOVERY_ADMIN` set on a production deployment. `mailctl reset-password` re-enables a temporary recovery credential during a lockout; reset and verify the permanent account, then immediately run `mailctl harden` again. + +## DNS checklist + +The dashboard and `mailctl doctor` cover the local checks. Before production traffic, verify: + +- A and/or AAAA for the mail hostname +- MX for each hosted domain +- PTR from every sending IP back to the mail hostname +- SPF authorizing the appliance or relay +- Stalwart-generated DKIM records +- DMARC, initially in monitoring mode if desired +- HTTPS certificate and autoconfiguration discovery +- External inbound and outbound port 25 reachability + +The Stalwart domain object contains the generated DNS zone material. Missing PTR, blocked outbound port 25, or poor IP reputation is a relay recommendation, not an appliance failure. + +## REST API + +The complete OpenAPI 3.1 contract is in [`api/openapi.yaml`](api/openapi.yaml). Administrator-created keys are displayed once, stored as SHA-256 digests, scoped to `messages.send` and/or `messages.status`, and restricted to approved sender identities. + +```bash +curl https://mail.example.com/api/v1/messages \ + -H 'Authorization: Bearer meovv_REPLACE_ME' \ + -H 'Idempotency-Key: welcome-customer-1042' \ + -H 'Content-Type: application/json' \ + --data '{ + "from":"Notifications ", + "to":["person@example.net"], + "subject":"Welcome", + "text":"Welcome to our service.", + "html":"

Welcome to our service.

" + }' +``` + +A successful submission returns `202 Accepted`. `delivered` means the destination mail server accepted the recipient; it does not mean a person read the message. + +## Operations + +Create a consistency-safe backup: + +```bash +./mailctl backup +``` + +The command stops Stalwart and MEOVV writers, archives all five named volumes plus Compose configuration and secrets, writes SHA-256 checksums, and restarts the services. Restore is intentionally destructive and only accepts a backup from the same MEOVV and Stalwart release: + +```bash +./mailctl restore --from backups/20260812T103000Z --yes +``` + +Upgrades verify the Ed25519 signature in `release/compatibility.sig`, reject unapproved Stalwart versions or digests, run diagnostics, and create a pre-upgrade backup: + +```bash +./mailctl upgrade +``` + +Other useful commands: + +```bash +./mailctl doctor +./mailctl version +docker compose exec meovv mailctl create-api-key \ + --name 'Production app' \ + --senders 'notifications@example.com,*@internal.example.com' +``` + +## Observability + +- Liveness: `GET /health/live` +- Readiness: `GET /health/ready` +- Prometheus text format: `GET /metrics` +- Structured application logs: standard output +- Stalwart delivery diagnostics and queues: administrator dashboard through the authenticated adapter + +Default retention is 30 days for delivery metadata, 7 days for webhook attempts, and 180 days for administrator audit events. Override with `MEOVV_MESSAGE_RETENTION`, `MEOVV_WEBHOOK_RETENTION`, and `MEOVV_AUDIT_RETENTION` duration values. + +## Development and verification + +```bash +npm ci +npm run dev +npm run check +go test ./cmd/... ./internal/... +go vet ./cmd/... ./internal/... +go build ./cmd/... +MAIL_HOSTNAME=mail.example.com docker compose config --quiet +docker build -t meovv-mail:local . +``` + +The standalone appliance UI is produced by `npm run build:web` in `web-dist`; the container image builds it automatically. See [`docs/architecture.md`](docs/architecture.md), [`docs/operations.md`](docs/operations.md), and [`docs/security.md`](docs/security.md) for system boundaries, production runbooks, and threat controls. + +Pull requests run frontend checks, Go tests/vetting/builds, Compose validation, +container construction, and dependency review. See [`CONTRIBUTING.md`](CONTRIBUTING.md) +and report vulnerabilities through the private process in [`SECURITY.md`](SECURITY.md). + +## Licensing + +Stalwart is distributed unmodified as a separate AGPL service. MEOVV Mail does not link to its code. License notices and corresponding-source information are in [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md). This repository is not a substitute for legal review before customer distribution. + +The MEOVV product layer is currently **all rights reserved**; public source +availability is not an open-source license grant. See [`LICENSE`](LICENSE). If +the project adopts an open-source license later, update `LICENSE`, contribution +terms, package metadata, and release notices together. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..380ca8d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,31 @@ +# Security policy + +MEOVV Mail handles credentials, private correspondence, and internet-facing +mail protocols. Please report suspected vulnerabilities privately. + +## Supported versions + +This repository is currently pre-1.0. Security fixes are applied to the latest +release and the `main` branch only. Older snapshots are not supported. + +## Reporting a vulnerability + +Use the repository's **Security → Report a vulnerability** form to open a +private GitHub Security Advisory. Do not include exploit details, credentials, +message contents, or customer information in a public issue. + +Include the affected version or commit, deployment topology, reproduction +steps, expected impact, and any suggested mitigation. You should receive an +initial acknowledgement within three business days. Disclosure timing will be +coordinated after the report is validated and a remediation is available. + +If private vulnerability reporting has not yet been enabled on the repository, +contact the repository owner privately and ask them to enable it; do not open a +public issue containing vulnerability details. + +## Deployment reports + +Configuration questions, spam-delivery problems, and ordinary operational +failures are not vulnerabilities. Remove domains, IP addresses, credentials, +email addresses, message bodies, and logs containing personal information +before sharing a diagnostic report. diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..fd460bd --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,21 @@ +# Third-party notices + +## Stalwart Mail Server + +MEOVV Mail distributes the unmodified Stalwart Mail Server as a separate container: + +- Project: Stalwart Mail Server +- Version: `v0.16.17` +- Image: `stalwartlabs/stalwart:v0.16.17` +- Digest: `sha256:a8108e19bd927e172d4d8c128907b8dfc93fd180ae8ee07dccdd42cb97eb9dfa` +- License: GNU Affero General Public License, version 3 +- Corresponding source: https://github.com/stalwartlabs/stalwart/tree/v0.16.17 +- Release: https://github.com/stalwartlabs/stalwart/releases/tag/v0.16.17 + +Stalwart is not linked into the MEOVV application. MEOVV communicates with it over documented HTTP/JMAP and SMTP interfaces and ships it unmodified as its own service. Any future modifications to Stalwart must be published with corresponding source under the applicable license. Obtain legal review before customer distribution. + +Other JavaScript and Go dependencies retain their respective upstream licenses. +Their exact versions are recorded in `package-lock.json` and `go.sum`. Every +published binary or appliance release must include a generated software bill of +materials and the applicable third-party license texts; this source repository +does not replace those release artifacts. diff --git a/api/openapi.yaml b/api/openapi.yaml new file mode 100644 index 0000000..d9c2c26 --- /dev/null +++ b/api/openapi.yaml @@ -0,0 +1,228 @@ +openapi: 3.1.0 +info: + title: MEOVV Mail Send API + version: 1.0.0 + description: | + Submit application email and inspect destination-server acceptance state. + A `delivered` result means that the destination mail server accepted the + message; it does not mean that a person opened or read it. +servers: + - url: https://mail.example.com +security: + - bearerAuth: [] +paths: + /api/v1/messages: + post: + operationId: submitMessage + summary: Submit a message + description: Requires `messages.send`. A key may only use its approved sender identities. + parameters: + - $ref: '#/components/parameters/IdempotencyKey' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SubmitMessage' + examples: + welcome: + value: + from: Notifications + to: [person@example.net] + subject: Welcome + text: Welcome to our service. + html:

Welcome to our service.

+ responses: + '202': + description: Accepted by the local submission service. + headers: + Location: + schema: { type: string } + content: + application/json: + schema: { $ref: '#/components/schemas/SubmissionReceipt' } + example: + id: msg_E6uFQ2YfANvHfZrC + status: queued + submitted_at: '2026-08-12T08:30:00Z' + '400': { $ref: '#/components/responses/Problem' } + '401': { $ref: '#/components/responses/Problem' } + '403': { $ref: '#/components/responses/Problem' } + '409': { $ref: '#/components/responses/Problem' } + '413': { $ref: '#/components/responses/Problem' } + '422': { $ref: '#/components/responses/Problem' } + '429': + description: Per-key submission limit exceeded. + headers: + Retry-After: + schema: { type: integer } + content: + application/problem+json: + schema: { $ref: '#/components/schemas/Problem' } + get: + operationId: listMessages + summary: List message status history + description: Requires `messages.status`. Results are restricted to the calling API key. + parameters: + - { name: cursor, in: query, schema: { type: string } } + - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 25 } } + - { name: status, in: query, schema: { $ref: '#/components/schemas/MessageState' } } + - { name: sender, in: query, schema: { type: string, format: email } } + - { name: recipient, in: query, schema: { type: string, format: email } } + - { name: from, in: query, schema: { type: string, format: date-time } } + - { name: to, in: query, schema: { type: string, format: date-time } } + responses: + '200': + description: Cursor-paginated messages. + content: + application/json: + schema: + type: object + required: [data] + properties: + data: { type: array, items: { $ref: '#/components/schemas/MessageStatus' } } + next_cursor: { type: [string, 'null'] } + '401': { $ref: '#/components/responses/Problem' } + '403': { $ref: '#/components/responses/Problem' } + /api/v1/messages/{id}: + get: + operationId: getMessage + summary: Read overall and per-recipient delivery state + description: Requires `messages.status`; only the API key that submitted the message may read it. + parameters: + - name: id + in: path + required: true + schema: { type: string, pattern: '^msg_' } + responses: + '200': + description: Current delivery state. + content: + application/json: + schema: { $ref: '#/components/schemas/MessageStatus' } + '401': { $ref: '#/components/responses/Problem' } + '403': { $ref: '#/components/responses/Problem' } + '404': { $ref: '#/components/responses/Problem' } +webhooks: + deliveryEvent: + post: + summary: Versioned at-least-once delivery event + description: | + Verify `X-MEOVV-Signature` as HMAC-SHA256 over + `{X-MEOVV-Timestamp}.{raw_body}`. Event IDs stay constant across retries. + Duplicates and cross-message reordering are possible. + parameters: + - { name: X-MEOVV-Timestamp, in: header, required: true, schema: { type: string } } + - { name: X-MEOVV-Signature, in: header, required: true, schema: { type: string, pattern: '^v1=' } } + - { name: X-MEOVV-Event-ID, in: header, required: true, schema: { type: string } } + requestBody: + required: true + content: + application/json: + schema: { $ref: '#/components/schemas/WebhookEvent' } + responses: + '204': { description: Event accepted. } +components: + securitySchemes: + bearerAuth: + type: http + scheme: bearer + bearerFormat: MEOVV API key + parameters: + IdempotencyKey: + name: Idempotency-Key + in: header + description: Replays the original receipt for 24 hours; re-use with different content is rejected. + schema: { type: string, minLength: 1, maxLength: 255 } + responses: + Problem: + description: Request failed. + content: + application/problem+json: + schema: { $ref: '#/components/schemas/Problem' } + schemas: + SubmitMessage: + type: object + required: [from, to, subject] + anyOf: + - required: [text] + - required: [html] + properties: + from: { type: string, description: Must match a sender identity approved for the API key. } + to: { type: array, maxItems: 100, items: { type: string, format: email } } + cc: { type: array, items: { type: string, format: email } } + bcc: { type: array, items: { type: string, format: email } } + reply_to: { type: string, format: email } + subject: { type: string } + text: { type: string } + html: { type: string } + headers: + type: object + additionalProperties: { type: string } + description: X-* headers plus List-Unsubscribe and List-Unsubscribe-Post. + attachments: + type: array + items: + type: object + required: [filename, content_base64] + properties: + filename: { type: string } + content_type: { type: string, default: application/octet-stream } + content_base64: { type: string, contentEncoding: base64 } + description: The decoded message may not exceed 25 MiB and all recipient fields combined may not exceed 100 addresses. + MessageState: + type: string + enum: [queued, processing, deferred, delivered, partial, bounced, failed] + RecipientState: + type: object + required: [address, status] + properties: + address: { type: string, format: email } + status: { type: string, enum: [queued, processing, deferred, delivered, bounced, failed] } + last_response: { type: string } + last_attempt_at: { type: [string, 'null'], format: date-time } + SubmissionReceipt: + type: object + required: [id, status, submitted_at] + properties: + id: { type: string } + status: { const: queued } + submitted_at: { type: string, format: date-time } + MessageStatus: + type: object + required: [id, sender, subject, status, submitted_at, recipients] + properties: + id: { type: string } + sender: { type: string } + subject: { type: string } + status: { $ref: '#/components/schemas/MessageState' } + size_bytes: { type: integer } + submitted_at: { type: string, format: date-time } + updated_at: { type: string, format: date-time } + failure_reason: { type: string } + recipients: { type: array, items: { $ref: '#/components/schemas/RecipientState' } } + WebhookEvent: + type: object + required: [id, type, created_at, data] + properties: + id: { type: string } + type: + type: string + enum: [message.queued, message.delivered, message.deferred, message.bounced, message.failed] + created_at: { type: string, format: date-time } + data: + type: object + required: [message_id, status] + properties: + message_id: { type: string } + recipient: { type: [string, 'null'] } + status: { type: string } + Problem: + type: object + required: [type, title, status, detail, code] + properties: + type: { type: string, format: uri } + title: { type: string } + status: { type: integer } + detail: { type: string } + code: { type: string } diff --git a/app/globals.css b/app/globals.css new file mode 100644 index 0000000..149a971 --- /dev/null +++ b/app/globals.css @@ -0,0 +1,220 @@ +:root { + --bg: #f5f5f8; + --surface: #ffffff; + --surface-muted: #f8f8fb; + --surface-hover: #f1f0f8; + --border: #e5e4ea; + --border-strong: #d7d5df; + --text: #201f28; + --text-soft: #65636f; + --text-muted: #94919d; + --accent: #6756e8; + --accent-strong: #5949d1; + --accent-soft: #eeebff; + --green: #1e9b67; + --green-soft: #eaf8f1; + --amber: #bf7818; + --amber-soft: #fff5df; + --red: #cf4d55; + --shadow: 0 18px 45px rgba(32, 29, 48, .12); +} + +:root[data-theme="dark"] { + --bg: #15151a; + --surface: #1e1e24; + --surface-muted: #24242c; + --surface-hover: #2a2933; + --border: #32313b; + --border-strong: #41404b; + --text: #f4f3f8; + --text-soft: #b9b6c3; + --text-muted: #868390; + --accent-soft: #2f294f; + --green-soft: #18372a; + --amber-soft: #3a2d18; + color-scheme: dark; +} + +* { box-sizing: border-box; } +html, body { min-height: 100%; } +body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; } +button, input, textarea { color: inherit; font: inherit; } +button { border: 0; background: none; cursor: pointer; } +button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } +svg { stroke-width: 1.8; } + +.brand { display: flex; align-items: center; height: 36px; gap: 8px; white-space: nowrap; } +.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--accent); box-shadow: 0 5px 12px rgba(103, 86, 232, .22); } +.brand-name { font-weight: 760; letter-spacing: -.02em; font-size: 17px; } +.brand-product { color: var(--text-soft); font-weight: 470; font-size: 16px; margin-left: -3px; } + +.mail-shell { height: 100vh; min-height: 690px; overflow: hidden; background: var(--bg); } +.mail-header { height: 68px; display: grid; grid-template-columns: 230px minmax(280px, 720px) 1fr; align-items: center; gap: 24px; padding: 0 22px; border-bottom: 1px solid var(--border); background: var(--surface); position: relative; z-index: 20; } +.search-box { height: 42px; border: 1px solid transparent; border-radius: 11px; background: var(--surface-muted); display: flex; align-items: center; gap: 10px; padding: 0 13px; transition: border-color .2s, background .2s; } +.search-box:focus-within { border-color: var(--border-strong); background: var(--surface); } +.search-box > svg { width: 18px; color: var(--text-muted); } +.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); } +.search-box input::placeholder { color: var(--text-muted); } +.search-box kbd { font-family: inherit; font-size: 11px; color: var(--text-muted); border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 3px 6px; } +.search-box > svg:last-child { border-left: 1px solid var(--border); padding-left: 10px; width: 27px; } +.header-actions { justify-self: end; display: flex; align-items: center; gap: 4px; } +.header-actions > button, .admin-top-actions > button:not(.view-inbox) { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: var(--text-soft); position: relative; } +.header-actions > button:hover, .admin-top-actions > button:hover { background: var(--surface-hover); color: var(--text); } +.header-actions svg { width: 19px; } +.sync-status { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 12px; margin-right: 12px; } +.sync-status i { width: 7px; height: 7px; border-radius: 50%; background: #29a66e; box-shadow: 0 0 0 3px var(--green-soft); } +.header-actions .user-avatar { background: #2e2c39; color: white; font-size: 12px; font-weight: 650; margin-left: 6px; position: relative; } +.user-avatar span { position: absolute; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; right: -1px; bottom: -1px; background: #32ac74; } +.mobile-menu { display: none; } + +.mail-layout { display: grid; grid-template-columns: 230px minmax(360px, 430px) minmax(500px, 1fr); height: calc(100vh - 68px); } +.mail-sidebar { border-right: 1px solid var(--border); background: var(--surface); padding: 18px 12px; overflow-y: auto; } +.compose-button { height: 42px; margin: 0 6px 18px; width: calc(100% - 12px); border-radius: 10px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 650; box-shadow: 0 7px 16px rgba(103, 86, 232, .22); } +.compose-button:hover { background: var(--accent-strong); transform: translateY(-1px); } +.compose-button svg { width: 17px; } +.folders, .labels { display: grid; gap: 2px; } +.folders button { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; height: 36px; border-radius: 8px; padding: 0 11px; color: var(--text-soft); text-align: left; } +.folders button svg { width: 17px; } +.folders button:hover, .folders button.active { background: var(--surface-hover); color: var(--text); } +.folders button.active { color: var(--accent); font-weight: 620; background: var(--accent-soft); } +.folders button b { font-size: 11px; font-weight: 650; color: inherit; } +.label-heading { border-top: 1px solid var(--border); margin: 18px 7px 8px; padding-top: 17px; display: flex; justify-content: space-between; align-items: center; color: var(--text-muted); text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: .08em; } +.label-heading button { width: 24px; height: 24px; display: grid; place-items: center; color: var(--text-muted); } +.label-heading svg { width: 15px; } +.labels button { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; height: 33px; border-radius: 7px; padding: 0 11px; color: var(--text-soft); text-align: left; font-size: 13px; } +.labels button:hover { background: var(--surface-hover); } +.labels button span { color: var(--text-muted); font-size: 11px; } +.label-dot { width: 7px; height: 7px; border-radius: 50%; } +.label-dot.clients { background: #5678dc; }.label-dot.design { background: #d85f81; }.label-dot.team { background: #52a874; }.label-dot.updates { background: #ad76d8; } +.storage-widget { margin: 25px 8px 4px; padding-top: 17px; border-top: 1px solid var(--border); } +.storage-widget > div:first-child { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); } +.storage-widget strong { color: var(--text-soft); font-weight: 600; } +.storage-track { margin: 8px 0 6px; background: var(--border); height: 4px; border-radius: 5px; overflow: hidden; } +.storage-track i { display: block; width: 34%; height: 100%; background: var(--accent); } +.storage-widget p { color: var(--text-muted); font-size: 10px; margin: 0; } +.storage-widget button { margin-top: 14px; display: flex; align-items: center; gap: 7px; color: var(--accent); font-size: 11px; } +.storage-widget button svg { width: 14px; } + +.inbox-panel { min-width: 0; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; } +.list-toolbar, .reader-toolbar { height: 50px; min-height: 50px; padding: 0 13px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 3px; color: var(--text-muted); } +.list-toolbar button, .reader-toolbar button { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; } +.list-toolbar button:hover, .reader-toolbar button:hover { color: var(--text); background: var(--surface-hover); } +.list-toolbar svg, .reader-toolbar svg { width: 17px; } +.list-toolbar > div:first-child { display: flex; align-items: center; gap: 0; margin-right: 2px; } +.list-toolbar > div:first-child > button { width: 22px; height: 22px; border: 1.5px solid var(--border-strong); border-radius: 6px; } +.list-toolbar > div:first-child > button.checked { border-color: var(--accent); color: white; background: var(--accent); } +.list-toolbar > div:first-child > svg { width: 13px; } +.toolbar-divider { height: 19px; width: 1px; background: var(--border); margin: 0 5px; } +.list-toolbar .range { margin-left: auto; font-size: 11px; } +.message-list { overflow-y: auto; flex: 1; } +.list-title { padding: 19px 20px 12px; display: flex; align-items: baseline; justify-content: space-between; } +.list-title h1 { margin: 0; font-size: 19px; letter-spacing: -.02em; } +.list-title span { color: var(--text-muted); font-size: 11px; } +.message-list article { height: 114px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 22px 36px minmax(0, 1fr) 26px; align-items: start; gap: 10px; padding: 13px 13px 11px; cursor: pointer; position: relative; transition: background .15s; } +.message-list article:hover { background: var(--surface-muted); } +.message-list article.selected { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); } +.message-list article.unread .message-meta strong, .message-list article.unread h2 { font-weight: 720; color: var(--text); } +.row-check { width: 16px; height: 16px; border: 1.5px solid var(--border-strong); border-radius: 5px; display: grid; place-items: center; margin-top: 8px; opacity: 0; } +article:hover .row-check, .row-check.active { opacity: 1; } +.row-check.active { background: var(--accent); border-color: var(--accent); color: white; } +.row-check svg { width: 11px; } +.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: white; font-size: 10px; font-weight: 700; margin-top: 1px; } +.avatar.small { width: 29px; height: 29px; } +.avatar.coral { background: #d86f67; }.avatar.ink { background: #373641; }.avatar.violet { background: #7967c7; }.avatar.blue { background: #527dc4; }.avatar.green { background: #429b6d; }.avatar.amber { background: #c18a48; } +.message-summary { min-width: 0; } +.message-meta { display: flex; justify-content: space-between; gap: 7px; align-items: center; } +.message-meta strong { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.message-meta span { color: var(--text-muted); font-size: 10px; white-space: nowrap; } +.subject-line { display: flex; align-items: center; gap: 5px; margin-top: 3px; } +.subject-line h2 { margin: 0; font-size: 12px; font-weight: 590; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.subject-line b { color: var(--text-muted); font-size: 9px; font-weight: 600; } +.message-summary > p { margin: 3px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.row-labels { display: flex; gap: 5px; margin-top: 7px; } +.row-labels span { font-size: 8px; text-transform: uppercase; letter-spacing: .04em; padding: 2px 5px; border-radius: 4px; background: var(--surface-hover); color: var(--text-muted); display: flex; align-items: center; gap: 2px; } +.row-labels svg { width: 9px; } +.star { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 6px; color: var(--text-muted); } +.star svg { width: 16px; } +.star.active { color: #e0a62e; } +.star.active svg { fill: currentColor; } +.empty-state { min-height: 400px; display: grid; place-content: center; justify-items: center; color: var(--text-muted); } +.empty-state > svg { width: 36px; height: 36px; opacity: .5; } +.empty-state h2 { font-size: 15px; color: var(--text-soft); margin: 12px 0 2px; }.empty-state p { margin: 0; font-size: 12px; } + +.reader-panel { background: var(--surface); min-width: 0; display: flex; flex-direction: column; } +.reader-toolbar span { flex: 1; } +.reader-back { display: none !important; } +.reader-content { overflow-y: auto; padding: 28px clamp(28px, 4vw, 64px) 60px; max-width: 920px; width: 100%; margin: 0 auto; } +.subject-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 24px; } +.subject-header > div { flex: 1; min-width: 0; } +.subject-header h1 { margin: 0 0 9px; font-size: clamp(21px, 2.2vw, 28px); letter-spacing: -.035em; line-height: 1.25; } +.subject-header > div > div { display: flex; gap: 5px; } +.subject-header span { font-size: 9px; text-transform: uppercase; letter-spacing: .05em; border-radius: 4px; background: var(--surface-hover); color: var(--text-muted); padding: 3px 6px; } +.sender-header { display: grid; grid-template-columns: 38px 1fr auto 32px; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding-bottom: 18px; } +.sender-header strong { font-size: 13px; }.sender-header p { display: flex; align-items: center; margin: 2px 0 0; color: var(--text-muted); font-size: 10px; }.sender-header p svg { width: 11px; }.sender-header time { color: var(--text-muted); font-size: 10px; }.sender-header button { color: var(--text-muted); }.sender-header button svg { width: 17px; } +.remote-images { margin-top: 18px; height: 36px; padding: 0 11px; border: 1px solid var(--border); background: var(--surface-muted); color: var(--text-muted); border-radius: 7px; display: flex; align-items: center; gap: 8px; font-size: 10px; } +.remote-images svg { width: 14px; color: var(--green); }.remote-images button { margin-left: auto; color: var(--accent); font-weight: 600; font-size: 10px; } +.message-body { color: var(--text-soft); font-size: 14px; line-height: 1.75; padding: 22px 2px; } +.message-body p { margin: 0 0 17px; }.message-body strong { color: var(--text); }.message-body ul { padding-left: 21px; }.message-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; background: var(--surface-hover); padding: 2px 5px; border-radius: 4px; font-size: 12px; } +.attachments { border-top: 1px solid var(--border); padding: 18px 0; }.attachments > p { color: var(--text-muted); font-size: 10px; display: flex; align-items: center; gap: 5px; }.attachments > p svg { width: 13px; }.attachments > button { width: min(320px, 100%); height: 58px; padding: 8px; border: 1px solid var(--border); border-radius: 9px; display: grid; grid-template-columns: 40px 1fr 30px; align-items: center; gap: 9px; text-align: left; }.attachments > button:hover { border-color: var(--border-strong); background: var(--surface-muted); }.attachments > button > span { width: 40px; height: 40px; border-radius: 7px; background: #fff0f1; color: #ce505c; display: grid; place-items: center; }.attachments > button svg { width: 17px; }.attachments strong, .attachments small { display: block; }.attachments strong { font-size: 11px; }.attachments small { color: var(--text-muted); font-size: 9px; margin-top: 3px; }.attachments > button > svg { color: var(--text-muted); } +.reply-actions { display: flex; gap: 8px; margin-top: 9px; }.reply-actions button { height: 36px; padding: 0 14px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text-soft); font-size: 11px; }.reply-actions button:hover { background: var(--surface-hover); color: var(--text); }.reply-actions svg { width: 15px; } + +.compose { position: fixed; right: 28px; bottom: 0; z-index: 50; width: min(570px, calc(100vw - 32px)); height: 570px; border: 1px solid var(--border); border-bottom: 0; border-radius: 13px 13px 0 0; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; animation: compose-in .22s ease-out; } +@keyframes compose-in { from { transform: translateY(18px); opacity: 0; } } +.compose header { min-height: 45px; background: #302e3d; color: #fff; padding: 0 13px 0 16px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; }.compose header > div:first-child { display: flex; align-items: center; gap: 8px; }.compose-dot { width: 7px; height: 7px; border-radius: 50%; background: #9485ff; }.compose-actions { display: flex; }.compose-actions button { color: #cfccd7; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 6px; }.compose-actions button:hover { background: rgba(255,255,255,.1); color: white; } +.compose-fields { position: relative; padding: 4px 16px 0; }.compose-fields label { min-height: 41px; display: flex; align-items: center; border-bottom: 1px solid var(--border); gap: 8px; }.compose-fields label span { color: var(--text-muted); font-size: 11px; }.compose-fields input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 12px; }.cc-button { position: absolute; right: 17px; top: 14px; color: var(--text-muted); font-size: 10px; } +.compose > textarea { flex: 1; resize: none; border: 0; outline: 0; padding: 18px; background: transparent; color: var(--text); line-height: 1.6; }.compose > textarea::placeholder { color: var(--text-muted); } +.compose footer { min-height: 58px; border-top: 1px solid var(--border); padding: 8px 11px; display: flex; align-items: center; justify-content: space-between; }.compose-tools, .compose-status { display: flex; align-items: center; gap: 3px; }.compose footer button:not(.send-button) { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; color: var(--text-muted); }.compose footer button:hover:not(.send-button) { background: var(--surface-hover); color: var(--text); }.send-button { height: 36px; padding: 0 12px; border-radius: 8px; background: var(--accent); color: white; display: flex; align-items: center; gap: 7px; font-weight: 600; }.send-button kbd { font: inherit; font-size: 8px; padding-left: 5px; opacity: .7; }.format-a { font-family: Georgia, serif; font-size: 18px; text-decoration: underline; }.compose-status span { color: var(--text-muted); font-size: 9px; margin-right: 4px; } +.toast { position: fixed; left: 50%; bottom: 25px; transform: translateX(-50%); z-index: 80; min-width: 290px; height: 44px; padding: 0 10px 0 14px; background: #292731; color: white; box-shadow: var(--shadow); border-radius: 9px; display: flex; align-items: center; gap: 9px; font-size: 12px; animation: toast-in .2s ease-out; }.toast > svg { width: 17px; color: #6fd2a3; }.toast button { margin-left: auto; color: #b9b6c3; width: 28px; height: 28px; display: grid; place-items: center; }.toast button svg { width: 15px; }@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } } + +/* Administration */ +.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; background: var(--bg); } +.admin-sidebar { min-height: 100vh; position: sticky; top: 0; height: 100vh; background: #22212b; color: #d9d7e2; padding: 18px 14px; display: flex; flex-direction: column; } +.admin-sidebar .brand { margin: 0 8px 27px; }.admin-sidebar .brand-product { color: #9c99a8; }.admin-sidebar .brand-name { color: #fff; } +.admin-sidebar nav { display: grid; gap: 3px; }.admin-sidebar nav button, .sidebar-bottom > button:not(.admin-user) { min-height: 40px; border-radius: 8px; padding: 0 11px; display: flex; align-items: center; gap: 10px; color: #aaa7b5; text-align: left; font-size: 12px; }.admin-sidebar nav button:hover, .admin-sidebar nav button.active, .sidebar-bottom > button:hover { background: #302e3d; color: #fff; }.admin-sidebar nav button.active { color: #fff; box-shadow: inset 2px 0 #8b7cf2; }.admin-sidebar nav svg, .sidebar-bottom svg { width: 17px; }.nav-badge { margin-left: auto; background: #4b425a; color: #d8cbff; border-radius: 10px; padding: 2px 6px; font-size: 9px; } +.sidebar-bottom { margin-top: auto; display: grid; gap: 3px; }.admin-user { margin-top: 12px; border-top: 1px solid #393744; padding: 15px 7px 0; display: grid; grid-template-columns: 32px 1fr 20px; align-items: center; gap: 9px; color: #d9d7e2; text-align: left; }.admin-user > span { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 8px; background: #57506b; font-size: 10px; font-weight: 700; }.admin-user strong,.admin-user small { display: block; }.admin-user strong { font-size: 11px; }.admin-user small { color: #8f8b99; font-size: 9px; margin-top: 2px; }.admin-user > svg { width: 16px; color: #777481; } +.admin-main { min-width: 0; }.admin-top { height: 72px; border-bottom: 1px solid var(--border); background: var(--surface); padding: 0 30px; display: flex; align-items: center; }.admin-top h1 { font-size: 16px; margin: 0; letter-spacing: -.02em; }.admin-top p { color: var(--text-muted); font-size: 10px; margin: 3px 0 0; }.admin-top-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; }.admin-top-actions .view-inbox { height: 34px; padding: 0 12px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-soft); font-size: 11px; }.admin-top-actions .view-inbox:hover { background: var(--surface-muted); color: var(--text); }.admin-top-actions i { position: absolute; width: 6px; height: 6px; right: 7px; top: 7px; border-radius: 50%; background: var(--red); } +.overview, .admin-section { width: min(1200px, calc(100% - 56px)); margin: 26px auto 60px; } +.status-banner { min-height: 68px; padding: 12px 15px; display: grid; grid-template-columns: 39px 1fr auto; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; }.status-banner > span { width: 37px; height: 37px; border-radius: 9px; color: var(--green); background: var(--green-soft); display: grid; place-items: center; }.status-banner svg { width: 19px; }.status-banner strong { font-size: 12px; }.status-banner p { color: var(--text-muted); margin: 3px 0 0; font-size: 10px; }.status-banner button { color: var(--accent); display: flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 600; }.status-banner button svg { width: 14px; } +.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin: 14px 0; }.metric-grid article { min-width: 0; min-height: 146px; padding: 17px; border: 1px solid var(--border); background: var(--surface); border-radius: 11px; }.metric-grid header { display: flex; align-items: center; justify-content: space-between; }.metric-grid header small { color: var(--text-muted); font-size: 9px; }.metric-icon { width: 31px; height: 31px; border-radius: 8px; display: grid; place-items: center; }.metric-icon svg { width: 16px; }.metric-icon.purple { color: var(--accent); background: var(--accent-soft); }.metric-icon.green { color: var(--green); background: var(--green-soft); }.metric-icon.blue { color: #4c78c9; background: #edf3ff; }.metric-icon.amber { color: var(--amber); background: var(--amber-soft); }.metric-grid article > strong { display: block; font-size: 25px; letter-spacing: -.04em; margin-top: 15px; }.metric-grid article > p { margin: 3px 0 0; color: var(--text-muted); font-size: 10px; }.metric-grid em { color: var(--green); font-style: normal; margin-left: 5px; }.storage-line { display: block; margin-top: 10px; height: 4px; background: var(--border); border-radius: 3px; overflow: hidden; }.storage-line i { display: block; width: 34%; height: 100%; background: #cf9242; } +.overview-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 14px; margin-top: 14px; }.overview-grid > article { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; min-width: 0; }.delivery-chart { padding: 17px; }.delivery-chart > header, .domain-card > header, .recent-card > header { display: flex; justify-content: space-between; align-items: flex-start; }.overview h2 { margin: 0; font-size: 12px; }.overview header p { margin: 4px 0 0; color: var(--text-muted); font-size: 9px; }.delivery-chart header button { height: 29px; padding: 0 8px; border: 1px solid var(--border); border-radius: 7px; color: var(--text-soft); display: flex; align-items: center; gap: 5px; font-size: 9px; }.delivery-chart header button svg { width: 12px; }.chart { height: 158px; margin-top: 15px; display: grid; grid-template-columns: 25px 1fr; }.y-labels { display: flex; flex-direction: column; justify-content: space-between; color: var(--text-muted); font-size: 8px; padding-bottom: 2px; }.bars { border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; align-items: flex-end; justify-content: space-around; gap: 3px; padding: 0 8px; }.bars span { display: block; flex: 1; max-width: 11px; background: #bcb5eb; border-radius: 3px 3px 0 0; opacity: .65; }.bars span.recent { background: var(--accent); opacity: .9; }.x-labels { margin: 8px 2px 0 26px; display: flex; justify-content: space-between; color: var(--text-muted); font-size: 8px; } +.attention-card { padding: 16px; }.attention-card header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 12px; }.attention-card header span { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px; background: #fff0e1; color: #bc6b1f; display: grid; place-items: center; font-size: 9px; }.attention-item { display: grid; grid-template-columns: 31px 1fr; gap: 10px; padding: 15px 0; border-bottom: 1px solid var(--border); }.attention-item:last-child { border: 0; padding-bottom: 0; }.attention-item > span { width: 31px; height: 31px; border-radius: 8px; display: grid; place-items: center; }.attention-item .warning { background: var(--amber-soft); color: var(--amber); }.attention-item .info { background: var(--accent-soft); color: var(--accent); }.attention-item svg { width: 15px; }.attention-item strong { font-size: 10px; }.attention-item p { color: var(--text-muted); margin: 3px 0 6px; font-size: 9px; line-height: 1.4; }.attention-item button { color: var(--accent); font-size: 9px; display: flex; align-items: center; gap: 4px; }.attention-item button svg { width: 11px; } +.overview-grid.lower { grid-template-columns: 1fr 1fr; }.domain-card,.recent-card { padding: 16px; }.domain-card header,.recent-card header { padding-bottom: 11px; border-bottom: 1px solid var(--border); }.domain-card header button { color: var(--accent); font-size: 9px; }.recent-card header button { color: var(--text-muted); }.recent-card header svg { width: 14px; }.domain-row { min-height: 57px; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }.domain-row:last-child,.delivery-row:last-child { border: 0; }.domain-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }.domain-icon svg { width: 14px; }.domain-row strong,.domain-row small { display: block; }.domain-row strong { font-size: 10px; }.domain-row small { margin-top: 3px; color: var(--text-muted); font-size: 8px; }.domain-row > span:last-child { font-size: 8px; display: flex; align-items: center; gap: 5px; }.domain-row .healthy { color: var(--green); }.domain-row .pending { color: var(--amber); }.domain-row > span:last-child i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }.delivery-row { min-height: 57px; display: grid; grid-template-columns: 29px 1fr auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--border); }.delivery-row > span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; }.delivery-row > span.delivered { color: var(--green); background: var(--green-soft); }.delivery-row > span.deferred { color: var(--amber); background: var(--amber-soft); }.delivery-row svg { width: 13px; }.delivery-row strong,.delivery-row small { display: block; }.delivery-row strong { font-size: 10px; }.delivery-row small { color: var(--text-muted); font-size: 8px; margin-top: 3px; }.delivery-row em { color: var(--text-muted); font-style: normal; font-size: 8px; } +.section-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }.section-heading h2 { font-size: 21px; margin: 0; letter-spacing: -.03em; }.section-heading p { margin: 5px 0 0; color: var(--text-muted); font-size: 11px; }.section-heading button { background: var(--accent); color: white; border-radius: 8px; padding: 0 13px; height: 36px; display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; }.section-heading button svg { width: 15px; }.settings-card { border: 1px solid var(--border); background: var(--surface); border-radius: 11px; overflow: hidden; }.table-head { height: 39px; display: grid; grid-template-columns: minmax(200px, 1fr) 1fr 170px 40px; align-items: center; padding: 0 15px 0 62px; background: var(--surface-muted); color: var(--text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }.settings-row { min-height: 66px; display: grid; grid-template-columns: 36px minmax(150px, 1fr) 1fr 170px 40px; align-items: center; gap: 10px; padding: 0 15px; border-top: 1px solid var(--border); }.row-icon { width: 31px; height: 31px; border-radius: 8px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }.row-icon svg { width: 15px; }.settings-row strong { font-size: 11px; }.settings-row > span:not(.row-icon) { color: var(--text-soft); font-size: 10px; }.settings-row em { font-style: normal; display: flex; align-items: center; gap: 6px; font-size: 9px; }.settings-row em i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }.settings-row em.good { color: var(--green); }.settings-row em.warn { color: var(--amber); }.settings-row button { color: var(--text-muted); }.settings-row button svg { width: 17px; } + +.admin-empty { min-height: 210px; display: grid; place-content: center; justify-items: center; color: var(--text-muted); }.admin-empty > svg { width: 30px; height: 30px; opacity: .5; }.admin-empty strong { margin-top: 11px; color: var(--text-soft); font-size: 12px; }.admin-empty span { margin-top: 4px; font-size: 9px; }.admin-modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(27,25,35,.58); }.admin-modal { width: min(480px,100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); animation: fade-in .18s ease-out; }.admin-modal > header { display: grid; grid-template-columns: 38px 1fr 32px; gap: 11px; align-items: center; padding-bottom: 17px; border-bottom: 1px solid var(--border); }.admin-modal h3 { margin: 0; font-size: 16px; }.admin-modal header p { margin: 4px 0 0; color: var(--text-muted); font-size: 9px; }.admin-modal header > button { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 7px; color: var(--text-muted); }.admin-modal header > button:hover { background: var(--surface-hover); }.admin-modal header > button svg { width: 17px; }.admin-modal label { display: block; margin-top: 18px; color: var(--text-soft); font-size: 11px; font-weight: 650; }.admin-modal input { display: block; width: 100%; height: 43px; margin-top: 7px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); outline: 0; }.admin-modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }.admin-modal label small { display: block; color: var(--text-muted); font-size: 9px; margin-top: 7px; font-weight: 400; }.admin-modal > footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }.admin-modal > footer button { height: 36px; padding: 0 13px; border: 1px solid var(--border); border-radius: 8px; font-size: 10px; }.admin-modal > footer .primary { border-color: var(--accent); background: var(--accent); color: #fff; }.secret-result { padding: 26px 4px 6px; text-align: center; }.secret-result > svg { width: 32px; height: 32px; color: var(--green); }.secret-result strong { display: block; margin-top: 11px; }.secret-result p { color: var(--text-muted); font-size: 10px; }.secret-result code { display: block; overflow-wrap: anywhere; margin: 18px 0 12px; padding: 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-muted); color: var(--text); font-size: 11px; text-align: left; }.secret-result button { height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; }.secret-result button svg { width: 14px; } + +/* Setup */ +.setup-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(370px, 44%) 1fr; background: var(--surface); } +.setup-aside { position: relative; min-height: 100vh; background: #22212b; color: white; padding: 38px clamp(35px, 6vw, 90px); display: flex; flex-direction: column; overflow: hidden; }.setup-aside::after { content: ""; position: absolute; width: 380px; height: 380px; border: 1px solid #3c3948; border-radius: 50%; right: -210px; bottom: 70px; box-shadow: 0 0 0 70px #292733, 0 0 0 71px #3c3948, 0 0 0 140px #25232f, 0 0 0 141px #34323f; }.setup-aside .brand { position: relative; z-index: 1; }.setup-aside .brand-product { color: #a7a3b1; }.setup-copy { margin: auto 0; max-width: 480px; position: relative; z-index: 1; }.eyebrow { color: #a99cff; font-size: 10px; letter-spacing: .14em; font-weight: 700; }.setup-copy h1 { font-size: clamp(34px, 4vw, 56px); letter-spacing: -.055em; line-height: 1.02; margin: 20px 0; }.setup-copy p { color: #aaa7b4; font-size: 15px; line-height: 1.65; max-width: 390px; }.setup-assurance { display: grid; grid-template-columns: 28px 1fr; gap: 11px; position: relative; z-index: 1; }.setup-assurance > svg { color: #9c8eff; width: 21px; }.setup-assurance strong,.setup-assurance span { display: block; }.setup-assurance strong { font-size: 11px; }.setup-assurance span { margin-top: 4px; color: #8e8b98; font-size: 9px; } +.setup-main { min-height: 100vh; display: flex; flex-direction: column; padding: 34px clamp(35px, 7vw, 110px); }.setup-progress { display: grid; grid-template-columns: 50px 1fr 50px; align-items: center; gap: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; font-size: 9px; }.setup-progress > span:last-child { text-align: right; }.setup-progress > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }.setup-progress i { height: 3px; border-radius: 4px; background: var(--border); }.setup-progress i.active { background: var(--accent); }.setup-main section { width: min(510px, 100%); margin: auto; animation: fade-in .25s ease-out; }@keyframes fade-in { from { opacity: .4; transform: translateY(5px); } }.step-icon { width: 45px; height: 45px; border-radius: 12px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }.step-icon svg { width: 21px; }.setup-main section h2 { margin: 19px 0 8px; font-size: 27px; letter-spacing: -.04em; }.setup-main section > p { color: var(--text-muted); margin: 0 0 27px; line-height: 1.5; }.setup-main label { display: block; color: var(--text-soft); font-size: 11px; margin-top: 18px; font-weight: 600; }.setup-main input { display: block; margin-top: 7px; width: 100%; height: 43px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); padding: 0 12px; outline: 0; }.setup-main input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }.field-note { margin-top: 12px; display: flex; gap: 7px; align-items: center; color: var(--green); font-size: 10px; }.field-note svg { width: 14px; }.accent-choice { display: flex; gap: 9px; margin-top: 9px; }.color-choice { width: 28px; height: 28px; border-radius: 50%; box-shadow: none; }.color-choice.active { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }.delivery-choice { width: 100%; min-height: 80px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: grid; grid-template-columns: 42px 1fr 24px; gap: 12px; align-items: center; text-align: left; }.delivery-choice:hover,.delivery-choice.active { border-color: var(--accent); background: var(--accent-soft); }.delivery-choice > span { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 9px; color: var(--accent); background: var(--surface); }.delivery-choice > span svg { width: 19px; }.delivery-choice strong { font-size: 12px; }.delivery-choice p { margin: 4px 0 0; color: var(--text-muted); font-size: 10px; }.delivery-choice > svg { color: var(--accent); width: 19px; }.setup-main > footer { display: flex; justify-content: space-between; align-items: center; }.setup-main footer button { height: 39px; border-radius: 8px; padding: 0 15px; font-size: 11px; font-weight: 600; }.setup-main footer .secondary { border: 1px solid var(--border); }.setup-main footer .secondary:disabled { opacity: 0; pointer-events: none; }.setup-main footer .primary { background: var(--accent); color: #fff; display: flex; align-items: center; gap: 8px; }.setup-main footer svg { width: 15px; } + +.setup-finished { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: var(--bg); }.setup-finished > div { width: min(620px,100%); padding: clamp(24px,5vw,48px); border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }.setup-finished h1 { margin: 20px 0 10px; font-size: 30px; letter-spacing: -.04em; }.setup-finished p { color: var(--text-soft); line-height: 1.6; }.setup-finished p code { color: var(--accent); font-weight: 650; }.setup-finished pre { max-height: 250px; overflow: auto; margin: 22px 0 12px; padding: 15px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-muted); font: 10px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }.setup-warning { display: flex; align-items: center; gap: 7px; color: var(--green); font-size: 10px; }.setup-warning svg { width: 15px; }.setup-finished .primary { height: 42px; margin-top: 24px; padding: 0 15px; display: flex; align-items: center; gap: 8px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 650; }.setup-finished .primary svg { width: 16px; } + +/* Authentication */ +.app-loading { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px; background: var(--surface); color: var(--text-muted); }.app-loading .brand { margin-bottom: 18px; }.app-loading > svg { width: 21px; color: var(--accent); }.app-loading > span { font-size: 11px; } +.spin { animation: spin .8s linear infinite; }@keyframes spin { to { transform: rotate(360deg); } } +.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(390px, 43%) 1fr; background: var(--surface); }.login-story { min-height: 100vh; padding: 40px clamp(36px,6vw,92px); color: #fff; background: #22212b; display: flex; flex-direction: column; position: relative; overflow: hidden; }.login-story::before,.login-story::after { content: ""; position: absolute; border: 1px solid #3d394b; border-radius: 50%; }.login-story::before { width: 520px; height: 520px; right: -290px; top: 20%; box-shadow: 0 0 0 85px #292733,0 0 0 86px #3a3745; }.login-story::after { width: 180px; height: 180px; left: -110px; bottom: 14%; }.login-story .brand,.login-story > div,.login-security { position: relative; z-index: 1; }.login-story .brand-product { color: #aaa6b5; }.login-story > div { margin: auto 0; max-width: 450px; }.login-story h1 { margin: 20px 0 13px; font-size: clamp(43px,5vw,68px); line-height: 1; letter-spacing: -.06em; }.login-story p { color: #aaa7b4; line-height: 1.65; font-size: 15px; }.login-security { display: flex; align-items: center; gap: 9px; color: #aaa7b4; font-size: 10px; }.login-security svg { width: 18px; color: #9f92ff; }.login-screen > main { display: grid; place-items: center; padding: 32px; }.login-card { width: min(410px,100%); }.login-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px; color: var(--accent); background: var(--accent-soft); }.login-icon svg { width: 22px; }.login-card h2 { margin: 22px 0 7px; font-size: 27px; letter-spacing: -.04em; }.login-card > p { margin: 0 0 28px; color: var(--text-muted); }.login-card label { display: block; margin-top: 18px; color: var(--text-soft); font-size: 11px; font-weight: 650; }.login-card input { display: block; width: 100%; height: 45px; margin-top: 7px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); outline: 0; }.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }.form-error { min-height: 39px; margin-top: 16px; padding: 9px 11px; display: flex; align-items: center; gap: 8px; border-radius: 8px; background: #fff0f1; color: #ae3f49; font-size: 10px; line-height: 1.4; }.form-error svg { width: 16px; min-width: 16px; }.login-submit { width: 100%; height: 43px; margin-top: 19px; display: flex; justify-content: center; align-items: center; gap: 8px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 650; }.login-submit:hover { background: var(--accent-strong); }.login-submit:disabled,.setup-main .primary:disabled { opacity: .7; cursor: wait; }.login-submit svg { width: 17px; }.login-card > small { display: block; margin-top: 16px; color: var(--text-muted); text-align: center; font-size: 9px; } + +@media (max-width: 1180px) { + .mail-header { grid-template-columns: 200px minmax(260px, 1fr) auto; }.sync-status { display: none; } + .mail-layout { grid-template-columns: 205px minmax(340px, 400px) 1fr; } + .reader-content { padding-inline: 28px; } +} + +@media (max-width: 960px) { + .mail-header { grid-template-columns: 34px 160px 1fr auto; padding-inline: 13px; gap: 10px; }.mail-header > .mobile-menu { display: grid; place-items: center; color: var(--text-soft); }.search-box { grid-column: 3; }.header-actions > button:not(.user-avatar):not(:first-of-type) { display: none; }.brand-product { display: none; } + .mail-layout { grid-template-columns: minmax(330px, 390px) 1fr; }.mail-sidebar { position: fixed; left: 0; top: 68px; bottom: 0; width: 230px; z-index: 30; transform: translateX(-100%); box-shadow: var(--shadow); transition: transform .2s; }.mail-sidebar.open { transform: translateX(0); }.inbox-panel { grid-column: 1; }.reader-panel { grid-column: 2; } + .metric-grid { grid-template-columns: 1fr 1fr; }.overview-grid { grid-template-columns: 1fr; } + .setup-screen { grid-template-columns: 1fr; }.setup-aside { min-height: 300px; padding-block: 28px; }.setup-copy { margin: 60px 0 40px; }.setup-copy h1 { max-width: 600px; }.setup-assurance { display: none; }.setup-main { min-height: 660px; } + .login-screen { grid-template-columns: 1fr; }.login-story { min-height: 260px; padding-block: 28px; }.login-story > div { margin: 52px 0 25px; }.login-story h1 { font-size: 39px; }.login-security { display: none; }.login-screen > main { min-height: 580px; } +} + +@media (max-width: 720px) { + .mail-shell { min-height: 100vh; height: auto; }.mail-header { height: 62px; grid-template-columns: 32px 38px 1fr auto; }.mail-header .brand-name { display: none; }.search-box { height: 38px; }.search-box kbd,.search-box > svg:last-child { display: none; }.mail-layout { display: block; height: calc(100vh - 62px); }.mail-sidebar { top: 62px; }.inbox-panel { height: 100%; }.reader-panel { position: fixed; inset: 62px 0 0; z-index: 18; transform: translateX(100%); }.message-list article.selected + * {} .reader-panel { display: none; } + .compose { width: 100%; height: calc(100vh - 20px); max-height: none; left: 0; right: 0; } + .admin-shell { display: block; }.admin-sidebar { display: none; }.admin-top { padding-inline: 16px; }.admin-top .mobile-menu { display: grid; margin-right: 10px; }.overview,.admin-section { width: calc(100% - 26px); margin-top: 14px; }.status-banner { grid-template-columns: 38px 1fr; }.status-banner button { display: none; }.metric-grid { grid-template-columns: 1fr; }.overview-grid.lower { grid-template-columns: 1fr; }.table-head { display: none; }.settings-row { grid-template-columns: 36px 1fr 30px; padding: 12px; }.settings-row > span:not(.row-icon),.settings-row em { grid-column: 2; }.settings-row button { grid-column: 3; grid-row: 1; } + .setup-aside { min-height: 250px; }.setup-copy { margin: 45px 0 20px; }.setup-copy h1 { font-size: 34px; }.setup-main { padding: 25px 22px; min-height: 620px; }.setup-main section h2 { font-size: 23px; } + .login-story { min-height: 205px; padding: 25px 24px; }.login-story > div { margin: 34px 0 10px; }.login-story h1 { font-size: 34px; margin-block: 13px 8px; }.login-story p { font-size: 12px; margin: 0; }.login-screen > main { min-height: calc(100vh - 205px); padding: 28px 24px; }.login-card h2 { font-size: 23px; } +} + +@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } } diff --git a/app/page.tsx b/app/page.tsx new file mode 100644 index 0000000..f825d28 --- /dev/null +++ b/app/page.tsx @@ -0,0 +1,646 @@ +"use client"; +/* eslint-disable jsx-a11y/no-autofocus -- Focus is moved into the newly opened modal dialog. */ +/* eslint-disable @typescript-eslint/no-explicit-any -- Stalwart JMAP payloads are runtime-discovered until the pinned adapter returns them. */ +/* eslint-disable react-hooks/set-state-in-effect -- Initial JMAP and admin data are intentionally loaded from effects. */ +/* eslint-disable jsx-a11y/no-static-element-interactions -- The modal backdrop supplements its explicit close button. */ +/* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role -- Mail rows are keyboard-operable composites with nested selection and star controls. */ + +import DOMPurify from "dompurify"; +import { + AlertTriangle, + Archive, + ArrowLeft, + ArrowRight, + Bell, + Check, + CheckCircle2, + ChevronDown, + ChevronRight, + CircleUserRound, + Clock3, + Copy, + Download, + FileText, + Forward, + Gauge, + Globe2, + HelpCircle, + Inbox, + KeyRound, + LifeBuoy, + Mail, + Menu, + Moon, + MoreHorizontal, + Paperclip, + Pencil, + Plus, + RefreshCw, + Reply, + Search, + Send, + Server, + Settings, + ShieldCheck, + SlidersHorizontal, + Smile, + Sparkles, + Star, + Sun, + Tag, + Trash2, + Users, + Webhook, + X, + Zap, +} from "lucide-react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; + +type FolderName = "Inbox" | "Starred" | "Snoozed" | "Sent" | "Drafts" | "Archive" | "Spam" | "Trash"; +type Message = { + id: number | string; + sender: string; + email: string; + initials: string; + color: string; + subject: string; + preview: string; + time: string; + date: string; + unread: boolean; + starred: boolean; + labels: string[]; + folder: FolderName; + body: string; + attachments?: { name: string; size: string; kind: string }[]; + threadCount?: number; + serverId?: string; + mailboxIds?: string[]; +}; + +type ComposeMessage = { to: string; cc: string; bcc: string; subject: string; body: string }; + +const initialMessages: Message[] = [ + { + id: 1, + sender: "Lina Park", + email: "lina@northstar.studio", + initials: "LP", + color: "coral", + subject: "Q3 design review — final notes", + preview: "I pulled the final comments into one place. The new navigation feels much calmer now…", + time: "10:42", + date: "Aug 12, 2026, 10:42 AM", + unread: true, + starred: true, + labels: ["Design"], + folder: "Inbox", + threadCount: 4, + body: `

Hi Alex,

I pulled the final comments into one place. The new navigation feels much calmer now, and the product team is aligned on the reduced color palette.

The only open item is the export flow. I’ve attached the marked-up review so we can close it in tomorrow’s session.

Thanks,
Lina

`, + attachments: [{ name: "Q3-design-review.pdf", size: "2.4 MB", kind: "PDF" }], + }, + { + id: 2, + sender: "GitHub", + email: "notifications@github.com", + initials: "GH", + color: "ink", + subject: "[acme/platform] Production deploy succeeded", + preview: "Deployment #2841 completed successfully in 3m 12s. All health checks are passing.", + time: "9:18", + date: "Aug 12, 2026, 9:18 AM", + unread: true, + starred: false, + labels: ["Updates"], + folder: "Inbox", + body: `

Production deploy succeeded

Deployment #2841 completed successfully in 3m 12s.

All 18 health checks are passing. Version 2026.08.12-rc3 is now serving 100% of production traffic.

`, + }, + { + id: 3, + sender: "Owen Chen", + email: "owen@springlabs.io", + initials: "OC", + color: "violet", + subject: "Re: Partnership timeline", + preview: "Thursday at 2 PM works. I’ll bring our solutions architect so we can cover the SSO questions…", + time: "8:51", + date: "Aug 12, 2026, 8:51 AM", + unread: false, + starred: false, + labels: ["Clients"], + folder: "Inbox", + threadCount: 3, + body: `

Thursday at 2 PM works for us.

I’ll bring our solutions architect so we can cover the SSO and data-residency questions in the same call. The pilot scope looks right from our side.

Looking forward to it,
Owen

`, + }, + { + id: 4, + sender: "Maya Thompson", + email: "maya@meovv.company", + initials: "MT", + color: "blue", + subject: "Team offsite: venue options", + preview: "I found three places that fit the dates and budget. My vote is for the lakeside workshop space…", + time: "Yesterday", + date: "Aug 11, 2026, 4:26 PM", + unread: false, + starred: true, + labels: ["Team"], + folder: "Inbox", + body: `

Hey team,

I found three places that fit the dates and budget. My vote is for the lakeside workshop space—the main room has enough wall space for planning, and there’s a quiet garden for one-on-ones.

Please add your preference before Friday.

`, + attachments: [{ name: "venue-comparison.xlsx", size: "148 KB", kind: "XLSX" }], + }, + { + id: 5, + sender: "Postmaster", + email: "postmaster@mail.meovv.company", + initials: "PM", + color: "green", + subject: "Weekly deliverability report", + preview: "98.7% of outbound mail was accepted on the first attempt. No blocklist listings detected.", + time: "Yesterday", + date: "Aug 11, 2026, 7:00 AM", + unread: false, + starred: false, + labels: ["System"], + folder: "Inbox", + body: `

Your weekly deliverability summary is ready.

SPF, DKIM, and DMARC are aligned for all active domains.

`, + }, + { + id: 6, + sender: "Nora Ibrahim", + email: "nora@meovv.company", + initials: "NI", + color: "amber", + subject: "Updated hiring plan", + preview: "Finance approved the two platform roles. I’ve updated the headcount model and interview loop…", + time: "Mon", + date: "Aug 10, 2026, 3:14 PM", + unread: false, + starred: false, + labels: ["Team"], + folder: "Inbox", + body: `

Finance approved the two platform roles.

I’ve updated the headcount model and interview loop. We can publish both positions after your final review.

`, + attachments: [{ name: "hiring-plan-v4.pdf", size: "864 KB", kind: "PDF" }], + }, + { + id: 7, + sender: "Linear", + email: "updates@linear.app", + initials: "LI", + color: "violet", + subject: "Your workspace digest", + preview: "14 issues completed, 9 created, and 2 projects moved to the next milestone this week.", + time: "Mon", + date: "Aug 10, 2026, 8:05 AM", + unread: false, + starred: false, + labels: ["Updates"], + folder: "Inbox", + body: `

Here’s what happened in your workspace this week:

14 issues completed · 9 created · 2 projects advanced

`, + }, + { + id: 8, + sender: "Alex Morgan", + email: "meghdad@meovv.company", + initials: "ME", + color: "blue", + subject: "Re: Architecture decision record", + preview: "The signed decision record and follow-up actions are attached for the platform group.", + time: "Sun", + date: "Aug 9, 2026, 2:31 PM", + unread: false, + starred: false, + labels: ["Engineering"], + folder: "Sent", + body: `

Hi all,

The signed decision record and follow-up actions are attached for the platform group. Please use this as the source of truth going forward.

`, + }, +]; + +const folders: { name: FolderName; icon: typeof Inbox; count?: number }[] = [ + { name: "Inbox", icon: Inbox, count: 5 }, + { name: "Starred", icon: Star }, + { name: "Snoozed", icon: Clock3 }, + { name: "Sent", icon: Send }, + { name: "Drafts", icon: FileText, count: 2 }, + { name: "Archive", icon: Archive }, + { name: "Spam", icon: ShieldCheck }, + { name: "Trash", icon: Trash2 }, +]; + +const adminNav = [ + { id: "overview", label: "Overview", icon: Gauge }, + { id: "domains", label: "Domains", icon: Globe2 }, + { id: "people", label: "People & aliases", icon: Users }, + { id: "delivery", label: "Delivery", icon: Send }, + { id: "api", label: "API keys", icon: KeyRound }, + { id: "webhooks", label: "Webhooks", icon: Webhook }, + { id: "backups", label: "Backups", icon: Download }, +]; + +function SafeHtml({ html }: { html: string }) { + const sanitized = useMemo(() => DOMPurify.sanitize(html, { FORBID_TAGS: ["style", "iframe", "form"], FORBID_ATTR: ["style"] }), [html]); + return
; +} + +function Logo({ compact = false }: { compact?: boolean }) { + return ( +
+ + {!compact && <>MEOVVMail} +
+ ); +} + +function base64url(bytes: ArrayBuffer) { + return btoa(String.fromCharCode(...new Uint8Array(bytes))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); +} + +function escapeHTML(value: string) { + return value.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """); +} + +function addressList(value: string) { + return value.split(",").map((email) => email.trim()).filter(Boolean).map((email) => ({ email })); +} + +function Login({ onAuthenticated }: { onAuthenticated: () => void }) { + const [account, setAccount] = useState(""); + const [password, setPassword] = useState(""); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(""); + const signIn = async (event: React.FormEvent) => { + event.preventDefault(); + setBusy(true); setError(""); + try { + const verifier = base64url(crypto.getRandomValues(new Uint8Array(48)).buffer); + const challenge = base64url(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier))); + const redirectUri = `${location.origin}/auth/callback`; + const authorization = await fetch("/api/auth", { + method: "POST", headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ type: "authCode", accountName: account, secret: password, clientId: "meovv-web", redirectUri, codeChallenge: challenge, codeChallengeMethod: "S256" }), + }); + const authorized = await authorization.json(); + const clientCode = authorized.clientCode ?? authorized.client_code ?? authorized.code; + if (!authorization.ok || authorized.authenticated === false || !clientCode) throw new Error(authorized.detail ?? authorized.error ?? "The email address or password was not accepted."); + setPassword(""); + const exchange = await fetch("/api/session/exchange", { + method: "POST", headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ client_code: clientCode, code_verifier: verifier, account, client_id: "meovv-web", redirect_uri: redirectUri }), + }); + const result = await exchange.json(); + if (!exchange.ok) throw new Error(result.detail ?? "Could not establish a secure session."); + onAuthenticated(); + } catch (reason) { setError(reason instanceof Error ? reason.message : "Sign-in failed."); } + finally { setBusy(false); } + }; + return

Sign in to MEOVV Mail

Use your organization email account.

{error &&
{error}
}Protected with OAuth authorization code and PKCE.
; +} + +function Avatar({ message, small = false }: { message: Message; small?: boolean }) { + return {message.initials}; +} + +function Compose({ onClose, onSend }: { onClose: () => void; onSend: (message: ComposeMessage) => Promise | void }) { + const [more, setMore] = useState(false); + const [to, setTo] = useState(""); + const [cc, setCC] = useState(""); + const [bcc, setBCC] = useState(""); + const [subject, setSubject] = useState(""); + const [body, setBody] = useState(""); + const [status, setStatus] = useState("Draft saved"); + useEffect(() => { + const timer = setTimeout(() => setStatus("Draft saved"), 650); + return () => clearTimeout(timer); + }, [subject, body]); + return ( +
+
New message
+
+ + + {more && <>} + +
+