/* Page-specific styles for domains, mailboxes, account, admin and legal views.
   Uses tokens from app.css (with fallbacks) and the shared contract classes. */
:root { --pg-peach: #f4a583; --pg-peach-soft: #fdeee6; --pg-peach-ink: #7a3a1a; --pg-blue-soft: #e6eef6; }
:root[data-theme="dark"] { --pg-peach: #f2b48f; --pg-peach-soft: #3a2a22; --pg-peach-ink: #f2b48f; --pg-blue-soft: #1d2b3a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --pg-peach: #f2b48f; --pg-peach-soft: #3a2a22; --pg-peach-ink: #f2b48f; --pg-blue-soft: #1d2b3a; }
}

/* ---- shared bits ---- */
.pg-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.pg-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pg-sub { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.avatar.pg-av { width: 38px; height: 38px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--pg-blue-soft); color: var(--accent); font-weight: 700; font-size: 15px; text-transform: uppercase; }
.avatar.pg-av.peach { background: var(--pg-peach-soft); color: var(--pg-peach-ink); }
.avatar.pg-av.lg { width: 56px; height: 56px; font-size: 22px; }
.pg-stats { margin: 0; }
.pg-section-title { margin: 0; }
.pg-grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) { .pg-grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---- domains ---- */
.dom-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.dom-card { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  box-shadow: 0 1px 2px rgba(28, 39, 51, .05); min-width: 0; }
.dom-card .dom-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
/* Long names wrap after a dot (<wbr> in the markup), at most two lines; the full name is in the title. */
.dom-name { font-weight: 700; color: var(--fg); text-decoration: none; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.dom-name:hover { color: var(--accent); text-decoration: underline; }
.dom-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.dom-meta small { color: var(--muted); font-size: 13px; }
.dom-card .dom-open { flex: none; min-width: 76px; }
.dom-head h1 { flex: 1; min-width: 0; flex-wrap: nowrap; }
.dom-head h1 .badge { flex: none; }
.dom-tabs button { flex: none; white-space: nowrap; }
@media (max-width: 640px) {
  .dom-head h1 { flex-basis: 100%; font-size: 19px; }
  .dom-head .avatar.pg-av.lg { width: 40px; height: 40px; font-size: 16px; }
  .dom-title { -webkit-line-clamp: 3; line-clamp: 3; }
}
.pg-card > .card-head { margin-bottom: 0; }
@media (max-width: 480px) {
  .dom-card .avatar { display: none; }
  .dom-name { -webkit-line-clamp: 3; line-clamp: 3; }
}
.dom-title { min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
/* three equal tiles in one look; still one row on phones, just tighter */
.dom-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.dom-stats .stat { grid-template-rows: auto auto 1fr; align-items: start; }
.dom-stats .stat-label { align-self: center; }
@media (max-width: 640px) {
  .dom-stats { gap: 8px; }
  .dom-stats .stat { padding: 10px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "label" "value" "sub"; gap: 2px; }
  .dom-stats .stat-ico { display: none; }
  .dom-stats .stat-value { font-size: 20px; }
  .dom-stats .stat-label, .dom-stats .stat-sub { font-size: 12px; overflow-wrap: anywhere; }
}

/* ---- one-field forms (add domain, extra address, catch-all): label / control + button / hint / error ---- */
.inline-form { display: grid; gap: 6px; min-width: 0; }
.inline-form > label { margin: 0; }
.inline-form-row { display: flex; gap: 10px; align-items: stretch; min-width: 0; }
.inline-form-row > :first-child { flex: 1; min-width: 0; }
.inline-form-row > button { flex: none; }
.inline-form > .hint { margin: 0; }
.inline-form > .msg { margin-top: 4px; }
@media (max-width: 560px) {
  .inline-form-row { flex-direction: column; }
  .inline-form-row > button { width: 100%; }
}
/* "@domain" suffix: one line, ellipsis for very long domains (full text in the title) */
.inline-form .suffix .at, .mb-create .suffix .at { display: block; flex: 0 1 auto; max-width: 58%; line-height: 38px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }
.inline-form .suffix input, .mb-create .suffix input { flex: 1 1 96px; min-width: 96px; }
.badge .ico { width: 12px; height: 12px; stroke-width: 3; }
.steps li b .ico { width: 14px; height: 14px; stroke-width: 3; }

.pg-steps-card { padding: 14px 18px; }
.pg-steps-card .steps { margin: 0; }
.rec-list { display: grid; gap: 8px; }
.rec.rec-card { border-radius: 14px; padding: 0; gap: 0; background: var(--panel); box-shadow: 0 1px 2px rgba(28, 39, 51, .05); overflow: hidden; }
.rec.rec-card .rec-head { display: block; margin: 0; font-size: inherit; font-weight: inherit; text-transform: none; letter-spacing: 0; color: inherit; }
.rec-toggle { width: 100%; min-height: 46px; padding: 8px 14px; gap: 8px 10px; flex-wrap: wrap; justify-content: flex-start; text-align: left;
  background: transparent; color: var(--fg); border: 0; border-radius: 0; font-weight: 400; }
.rec-toggle:hover:not(:disabled) { background: var(--panel-2); filter: none; }
.rec-toggle:focus-visible { outline-offset: -2px; border-radius: 14px; }
.rec-toggle .type { font-weight: 700; font-size: 12px; border-radius: 999px; padding: 2px 10px; background: var(--pg-blue-soft); color: var(--accent); flex: none; }
.rec-card.t-mx .rec-toggle .type, .rec-card.t-cname .rec-toggle .type { background: var(--pg-peach-soft); color: var(--pg-peach-ink); }
.rec-toggle .rec-title { flex: 1; min-width: 0; font-size: var(--fs-md); overflow-wrap: break-word; }
@media (max-width: 640px) {
  .rec-toggle { padding: 8px 12px; gap: 6px 8px; }
  .rec-toggle .rec-title { font-size: 14px; }
  .rec-toggle .type { padding: 2px 8px; font-size: 11px; }
  .rec-body { padding: 10px 12px 12px; }
}
.rec-toggle .rec-state { display: inline-flex; flex: none; }
.rec-toggle > .ico { width: 18px; height: 18px; color: var(--muted); transition: transform .15s ease; }
.rec-toggle[aria-expanded="true"] > .ico { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .rec-toggle > .ico { transition: none; } }
.rec-body { display: grid; gap: 8px; padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.rec-body[hidden] { display: none; }
.rec-body > .hint:empty { display: none; }
.rec.rec-card .rec-field { align-items: center; padding: 4px 0; border-top: 1px dashed var(--line); }
.rec.rec-card .rec-field:first-of-type { border-top: 0; }
.rec.rec-card .rec-field .k { padding-top: 0; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 14px; color: var(--fg); }
.status-line[hidden] { display: none; }
.status-line .status-main { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.status-line .status-ico { width: 20px; height: 20px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; background: var(--ok-bg); color: var(--ok); }
.status-line .status-ico .ico { width: 13px; height: 13px; stroke-width: 3; }
.status-line .status-text { font-weight: 600; color: var(--ok); margin-right: 4px; }
.pg-head + .status-line { margin-top: 8px; }
.pg-toolbar .spacer { flex: 1; }
.rec .spacer { flex: 1; }
.pg-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pg-toolbar-hint { margin: -6px 0 0; }
.pg-tabpanel { border-radius: 14px; }

/* ---- mailboxes ---- */
.mb-list { display: grid; gap: 0; }
.mb-item { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px 4px; border-top: 1px solid var(--line); }
.mb-item:first-child { border-top: 0; }
.mb-item .main { flex: 1; min-width: 220px; display: grid; gap: 2px; }
.mb-item .main small { color: var(--muted); font-size: 13px; }
.mb-item .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mb-send { margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.mb-item .main .mb-send.blocked { display: grid; gap: 4px; justify-items: start; }
.mb-item .bar-wrap { margin: 6px 0 0; max-width: 360px; }
.mb-item .subpanel { flex-basis: 100%; }
.mb-create { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--bg); display: grid; gap: 14px; min-width: 0; }
/* Two fields side by side, top-aligned: an error under one field never moves the other. The hint line is the
   reserved slot: a field error replaces it instead of pushing the row down. */
.mb-create-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.mb-create-grid [data-field]:has(> .field-err) > .hint { display: none; }
.mb-create-grid .hint, .mb-create-grid .field-err { min-height: 21px; margin-top: 4px; }
@media (max-width: 640px) { .mb-create-grid { grid-template-columns: minmax(0, 1fr); } }
.mb-created { padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--ok-bg); }
.mb-created .status-main { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.subpanel.stack { gap: 12px; }
.subpanel.stack > p { margin: 0; }
/* connection settings dialog */
dialog.conn-dlg { width: min(94vw, 720px); padding: 24px; }
.conn { display: grid; gap: 16px; min-width: 0; }
.conn-top { display: grid; gap: 6px; padding-right: 4px; }
.conn-top h2 { overflow-wrap: anywhere; }
.conn-top p { margin: 0; overflow-wrap: anywhere; }
.conn-ok { color: var(--ok); font-weight: 600; }
.conn-ok .ico { width: 15px; height: 15px; stroke-width: 3; vertical-align: -2px; margin-right: 4px; }
.conn-cred, .conn-card { display: grid; gap: 2px; align-content: start; min-width: 0; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: var(--panel); }
.conn-cred { background: var(--accent-soft); border-color: var(--accent); border-left-width: 4px; }
.conn-cred h3, .conn-card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.conn-cred h3 { color: var(--accent-ink); }
.conn-cred code { background: var(--panel); font-size: 13.5px; }
.conn-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.conn-row { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 40px; padding: 3px 0; border-top: 1px dashed var(--line); }
.conn-cred .conn-row { border-top-color: var(--line-strong); }
h3 + .conn-row { border-top: 0; }
.conn-row .k { font-size: var(--fs-sm); color: var(--muted); }
.conn-row code { justify-self: start; max-width: 100%; padding: 4px 8px; overflow-wrap: anywhere; word-break: break-all; }
.conn-row code.conn-pw.masked { white-space: nowrap; overflow: hidden; word-break: normal; }
.conn-acts { display: inline-flex; gap: 6px; }
.conn-acts .copied { color: var(--ok); border-color: var(--ok); }
.conn .hint { margin: 6px 0 0; }
.conn-note { display: flex; gap: 6px; align-items: flex-start; margin: 8px 0 0; font-size: var(--fs-sm); font-weight: 600; color: var(--warn); }
.conn-note .ico { width: 16px; height: 16px; margin-top: 1px; }
.conn-more { border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-size: var(--fs-sm); }
.conn-more > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; color: var(--accent-ink); border-radius: 12px; }
.conn-more-body { display: grid; gap: 4px; padding: 2px 14px 14px; }
.conn-foot-notes { display: grid; gap: 4px; }
.conn-foot-notes .hint { margin: 0; }
.conn-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); }
.conn-actions .spacer { flex: 1; }
.conn-actions .conn-close { min-width: 120px; }
@media (max-width: 640px) {
  dialog.conn-dlg { padding: 16px; width: min(96vw, 720px); }
  .conn-grid { grid-template-columns: minmax(0, 1fr); }
  .conn-row { grid-template-columns: 92px minmax(0, 1fr) auto; gap: 8px; }
  .conn-cred, .conn-card { padding: 12px; }
  .conn-actions .conn-close { flex: 1; }
}

/* ---- account ---- */
.acct { display: grid; gap: 16px; }
.acct-profile { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.acct-profile .who { display: grid; gap: 2px; min-width: 0; }
.acct-profile .who strong { overflow-wrap: anywhere; }
.acct-sec { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
@media (max-width: 860px) { .acct-sec { grid-template-columns: minmax(0, 1fr); } }
.acct .pw-info:empty { display: none; }
.acct-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 12px 0 0; border-top: 1px solid var(--line); }
.card-head + .acct-row { border-top: 0; padding-top: 0; }
.acct-row > div { flex: 1; min-width: min(100%, 240px); }
.acct-row p { margin: 2px 0 0; }
.acct .card.stack > .card-head { margin-bottom: 0; }
/* 2FA setup: QR next to the numbered steps */
.tfa-setup { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.tfa-qr { flex: none; width: 176px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.tfa-qr .qr { display: block; width: 100%; height: auto; }
.tfa-steps { flex: 1; min-width: 220px; margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 14px; }
.tfa-secret { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.tfa-secret code { letter-spacing: .08em; }
@media (max-width: 480px) { .tfa-qr { margin: 0 auto; } }
.card.danger-zone { border-color: var(--bad); }
.danger-zone h2 { color: var(--bad); }

/* ---- admin: moved to css/admin.css (loaded by js/admin.js) ---- */

/* ---- legal ---- */
.legal-doc { border-radius: 16px; padding: 24px; }
.legal-doc section + section { margin-top: 14px; }
.legal-doc h2 { font-size: 16px; margin-bottom: 4px; }

/* ---- stat tiles ---- */
.pg-stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .pg-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pg-stats .stat { padding: 10px 12px; }
  .pg-stats .stat-value { font-size: 22px; }
  .pg-stats .stat-ico { width: 30px; height: 30px; border-radius: 10px; }
  .pg-stats .stat-ico .ico { width: 16px; height: 16px; }
}

/* ---- admin: plan select ---- */
td[data-label="Plan"] select { min-width: 9.5rem; width: auto; text-overflow: clip; }
