:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f5;
  --text: #16191d;
  --muted: #687079;
  --line: #e3e6ea;
  --accent: #0f766e;
  --accent-2: #0d9488;
  --accent-soft: #e6f4f2;
  --danger: #c2410c;
  --danger-soft: #fdece3;
  --unread: #0f766e;
  --shadow: 0 10px 30px rgba(15, 23, 42, .12);
  --radius: 10px;
  --tiktok: #111111;
  --instagram: #d62976;
  --facebook: #1877f2;
  --youtube: #e62117;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1215;
    --panel: #161a1e;
    --panel-2: #1d2227;
    --text: #e8eaed;
    --muted: #949ca5;
    --line: #2a3036;
    --accent: #2dd4bf;
    --accent-2: #5eead4;
    --accent-soft: #123a36;
    --danger: #fb923c;
    --danger-soft: #3a2116;
    --unread: #2dd4bf;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --tiktok: #e8eaed;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
kbd {
  font: 11px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px; background: var(--panel);
}
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 270px minmax(320px, 400px) 1fr;
  height: 100vh;
  height: 100dvh;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
  padding: 16px 12px 0;
}
.list-pane {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.reader-pane { min-width: 0; overflow: auto; background: var(--bg); }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 16px; }
.brand-logo svg { width: 34px; height: 34px; display: block; }
.brand-logo rect { fill: var(--accent); }
.brand-logo path { fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-domain { color: var(--muted); font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #062b27; } }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--danger); }
.btn.danger:not(.ghost) { border-color: var(--danger); }
.btn.big { width: 100%; justify-content: flex-start; padding: 10px 14px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.icon-btn {
  border: 0; background: transparent; padding: 7px; border-radius: 8px; cursor: pointer; display: inline-flex;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn.on { color: #e3a008; }

.quick { display: grid; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }

/* ---------- Folders ---------- */
.folders { display: grid; gap: 1px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.folders button {
  display: flex; justify-content: space-between; align-items: center;
  border: 0; background: transparent; padding: 7px 10px; border-radius: 7px; cursor: pointer; text-align: left;
}
.folders button:hover { background: var(--panel-2); }
.folders button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count { font-size: 12px; font-weight: 700; color: var(--unread); }
.count.muted { color: var(--muted); font-weight: 500; }

/* ---------- Aliases ---------- */
.section-title {
  display: flex; justify-content: space-between; padding: 12px 6px 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted);
}
.alias-tools { padding: 0 2px 8px; display: grid; gap: 6px; }
.alias-tools input, .search-row input {
  width: 100%; border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 7px 10px;
}
.alias-tools input:focus, .search-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--panel); }
.net-filter { display: flex; flex-wrap: wrap; gap: 4px; }
.net-filter button {
  border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 2px 9px;
  font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.net-filter button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.alias-list { list-style: none; margin: 0 -12px; padding: 0 6px 16px; overflow: auto; flex: 1; min-height: 0; }
.alias-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; position: relative;
}
.alias-item:hover { background: var(--panel-2); }
.alias-item.active { background: var(--accent-soft); }
.alias-item.disabled .alias-addr { text-decoration: line-through; color: var(--muted); }
.alias-addr { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.alias-addr .dom { color: var(--muted); font-weight: 400; }
.alias-sub { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; min-width: 0; }
.alias-note { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alias-right { display: flex; align-items: center; gap: 2px; }
.alias-copy { opacity: 0; padding: 3px; }
.alias-item:hover .alias-copy, .alias-item.active .alias-copy { opacity: 1; }
.alias-copy .ic { width: 15px; height: 15px; }
.empty-aliases { padding: 10px; color: var(--muted); font-size: 13px; }

/* Network badges */
.nets { display: inline-flex; gap: 3px; flex: none; }
.net {
  width: 16px; height: 16px; border-radius: 4px; display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 800; color: #fff; line-height: 1;
}
.net-tiktok { background: var(--tiktok); color: var(--panel); }
.net-instagram { background: var(--instagram); }
.net-facebook { background: var(--facebook); }
.net-youtube { background: var(--youtube); }
.net-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 3px; border-radius: 99px;
  background: var(--panel-2); font-size: 12px; border: 1px solid var(--line);
}

/* ---------- List pane ---------- */
.list-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 6px 16px; }
.list-head h1 { font-size: 18px; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-row { padding: 0 12px 10px; border-bottom: 1px solid var(--line); }

.alias-bar { padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--accent-soft); display: grid; gap: 6px; }
.alias-bar-top { display: flex; align-items: center; gap: 6px; }
.alias-bar-addr { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alias-bar-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }

.msg-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; }
.msg {
  display: grid; grid-template-columns: 1fr auto; gap: 1px 10px;
  padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative;
}
.msg:hover { background: var(--panel-2); }
.msg.active { background: var(--accent-soft); }
.msg.unread::before {
  content: ""; position: absolute; left: 6px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--unread);
}
.msg-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.msg.unread .msg-from, .msg.unread .msg-subject { font-weight: 700; }
.msg-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.msg-subject { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-snippet { grid-column: 1 / -1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-to { grid-column: 1 / -1; font-size: 11px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .star { color: #e3a008; }
.list-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.list-foot { padding: 8px; text-align: center; }

/* ---------- Reader ---------- */
.empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); padding: 20px; }
.empty svg { width: 46px; height: 46px; margin: 0 auto 6px; fill: none; stroke: currentColor; stroke-width: 1.4; opacity: .5; }
.reader { max-width: 900px; margin: 0 auto; padding: 18px 24px 40px; }
.reader-toolbar { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.reader-toolbar .spacer { flex: 1; }
.reader h2 { font-size: 20px; margin: 0 0 12px; line-height: 1.3; word-break: break-word; }
.reader-meta {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: grid; gap: 3px; font-size: 13px; margin-bottom: 14px;
}
.reader-meta .row { display: flex; gap: 8px; min-width: 0; }
.reader-meta .k { color: var(--muted); width: 44px; flex: none; }
.reader-meta .v { overflow-wrap: anywhere; }
.reader-meta .alias-tag { color: var(--accent); font-weight: 600; }
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px;
  font-size: 13px; color: var(--muted); margin-bottom: 10px;
}
.body-frame { width: 100%; border: 0; border-radius: var(--radius); background: #fff; display: block; min-height: 120px; }
.body-text {
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; font-size: 14px;
}
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.attachment {
  display: inline-flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--line);
  background: var(--panel); border-radius: 8px; color: inherit; text-decoration: none; font-size: 13px; max-width: 100%;
}
.attachment:hover { border-color: var(--accent); }
.attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Dialogs ---------- */
.dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(460px, calc(100vw - 24px));
  background: var(--panel); color: var(--text); box-shadow: var(--shadow);
}
.dialog.wide { width: min(720px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(10, 14, 18, .45); }
.dialog form { padding: 20px; display: grid; gap: 12px; }
.dialog h2 { margin: 0 0 2px; font-size: 18px; overflow-wrap: anywhere; }
.dialog label, .dialog .field { display: grid; gap: 5px; font-weight: 500; font-size: 13px; }
.dialog input:not([type="checkbox"]):not([type="file"]), .dialog textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel);
  font-weight: 400; font-size: 14px;
}
.dialog textarea { resize: vertical; min-height: 160px; line-height: 1.5; }
.dialog input:focus, .dialog textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.addr-input { display: flex; align-items: center; gap: 6px; }
.addr-input input { flex: 1; min-width: 0; }
.suffix { color: var(--muted); font-weight: 500; white-space: nowrap; }
.switch { display: flex !important; grid-template-columns: none; align-items: center; gap: 8px; font-weight: 400 !important; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.actions.spread { justify-content: space-between; }
.actions.spread > div { display: flex; gap: 8px; }
.error { color: var(--danger); margin: 0; font-size: 13px; }
.cc-toggle summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.cc-toggle[open] { display: grid; gap: 10px; }
.attach-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.file-btn { display: inline-flex !important; cursor: pointer; }
.chips { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; margin: 0; padding: 0; }
.chips li { background: var(--panel-2); border-radius: 99px; padding: 3px 4px 3px 10px; font-size: 12px; display: flex; align-items: center; gap: 4px; }
.chips button { border: 0; background: transparent; cursor: pointer; padding: 0 4px; color: var(--muted); }
.net-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.net-toggles button {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: transparent;
  border-radius: 99px; padding: 4px 10px 4px 5px; cursor: pointer; font-size: 13px; opacity: .55;
}
.net-toggles button.on { opacity: 1; border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--panel); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow);
  transition: opacity .18s, transform .18s; max-width: calc(100vw - 32px); font-weight: 500; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

.only-mobile { display: none; }
.scrim { display: none; }

/* ---------- Dominios ---------- */
.count.warn { color: var(--danger); }
.domains-pane {
  grid-column: 2 / -1; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel);
}
.app.view-domains .list-pane, .app.view-domains .reader-pane { display: none !important; }
.domains-body { overflow: auto; padding: 4px 20px 32px; }
.domains-status { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.domains-status.error { color: var(--danger); }
.dom-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dom-filters button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px;
}
.dom-filters button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dom-search { width: 100%; max-width: 360px; margin-bottom: 12px; }
.dom-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dom-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
  padding: 10px 14px; border-top: 1px solid var(--line);
}
.dom-row:first-child { border-top: 0; }
.dom-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dom-when { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.dom-when.urgent { color: var(--danger); font-weight: 600; }
.dom-badge { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.dom-badge.renews { background: var(--accent-soft); color: var(--accent); }
.dom-badge.cancelled, .dom-badge.deleting { background: var(--danger-soft); color: var(--danger); }
.dom-badge.registering, .dom-badge.unknown { background: var(--panel-2); color: var(--muted); }
.dom-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.dom-setup { max-width: 620px; line-height: 1.6; }
.dom-setup code { background: var(--panel-2); padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.dom-setup ol { padding-left: 20px; }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 250px 1fr; }
  .reader-pane { display: none; }
  .app.view-reader .list-pane { display: none; }
  .app.view-reader .reader-pane { display: block; }
}

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
  .list-pane { border-right: 0; }
  .domains-pane { grid-column: auto; }
  .domains-body { padding: 4px 16px 32px; }
  .reader { padding: 12px 16px 32px; }
  .alias-copy { opacity: 1; }
}

/* ---------- Inicio de sesión ---------- */
.brand-logout { margin-left: auto; color: var(--muted); }
.login-screen {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--bg); padding: 16px;
}
.login-card {
  width: min(360px, 100%); display: grid; gap: 14px; justify-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card .brand-logo svg { width: 44px; height: 44px; display: block; }
.login-card label { display: grid; gap: 6px; width: 100%; font-weight: 600; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card .btn.big { justify-content: center; }
.login-card .error { margin: 0; width: 100%; }
