/* correo·urupass — identidad: celeste uruguayo + oro sol de mayo */
:root {
  --bg: #F1F5F8;
  --surface: #FFFFFF;
  --ink: #142430;
  --muted: #5B6E7C;
  --line: #DBE4EB;
  --celeste: #1F7AB8;
  --celeste-soft: #E3F0F9;
  --gold: #E3A72F;
  --danger: #C74A3A;
  --ok: #2E8B62;
  --radius: 10px;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.muted { color: var(--muted); }

/* ── Masthead ─────────────────────────────── */
.masthead {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.masthead .dot { color: var(--gold); }
.masthead.small { font-size: 1.25rem; }

/* ── Login ────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(160deg, var(--celeste-soft) 0%, var(--bg) 55%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--celeste);
  border-radius: var(--radius);
  padding: 2.2rem;
  width: min(400px, 92vw);
  box-shadow: 0 10px 40px rgba(20, 36, 48, 0.08);
}
.login-card .masthead { font-size: 1.9rem; margin-bottom: 0.3rem; }
.login-sub { color: var(--muted); margin: 0 0 1.4rem; }

/* ── Formularios ──────────────────────────── */
.field { margin-bottom: 0.9rem; display: flex; flex-direction: column; }
.field label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.field input, .field textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.field input:focus, .field textarea:focus, .searchbox input:focus {
  outline: 2px solid var(--celeste);
  outline-offset: 1px;
  border-color: var(--celeste);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
textarea { resize: vertical; }

.error {
  background: #FBEAE7; color: var(--danger);
  border-radius: 6px; padding: 0.5rem 0.7rem;
  font-size: 0.88rem; margin-bottom: 0.8rem;
}
.okmsg {
  background: #E5F4ED; color: var(--ok);
  border-radius: 6px; padding: 0.5rem 0.7rem;
  font-size: 0.88rem; margin-bottom: 0.8rem;
}

/* ── Botones ──────────────────────────────── */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.5rem 0.9rem;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
  transition: background 0.12s ease;
}
.btn:focus-visible { outline: 2px solid var(--celeste); outline-offset: 2px; }
.btn-primary { background: var(--celeste); color: #fff; }
.btn-primary:hover { background: #1A6AA1; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--celeste-soft); color: var(--celeste); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #FBEAE7; }
.btn-block { width: 100%; display: block; }
.btn[disabled] { opacity: 0.55; cursor: wait; }

/* ── Topbar ───────────────────────────────── */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1.2rem;
  padding: 0.6rem 1.1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.searchbox { flex: 1; display: flex; gap: 0.4rem; max-width: 560px; }
.searchbox input {
  flex: 1;
  font-family: var(--font-body);
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.me { color: var(--muted); }

/* ── Layout tres paneles ──────────────────── */
.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 215px 380px 1fr;
}

/* Carpetas */
.rail {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 0.9rem 0.7rem;
  overflow-y: auto;
}
.folders { list-style: none; margin: 1rem 0 0; padding: 0; }
.folders li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  margin-bottom: 2px;
}
.folders li:hover { background: var(--celeste-soft); }
.folders li.active {
  background: var(--celeste-soft);
  border-left-color: var(--celeste);
  font-weight: 700;
}
.folders .count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--gold);
  color: #3A2B05;
  padding: 0.1rem 0.42rem;
  border-radius: 99px;
}

/* Lista de mensajes */
.msglist {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.msglist-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.65rem 0.9rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-weight: 600;
}
.msglist-head #btn-refresh { margin-left: auto; }
.msgs { list-style: none; margin: 0; padding: 0; }
.msgs li {
  padding: 0.6rem 0.9rem 0.6rem 1.4rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  background: var(--surface);
}
.msgs li:hover { background: var(--celeste-soft); }
.msgs li.active { background: var(--celeste-soft); box-shadow: inset 3px 0 0 var(--celeste); }
.msgs li.unread .m-from, .msgs li.unread .m-subject { font-weight: 700; }
.msgs li.unread::before {
  content: "";
  position: absolute; left: 0.55rem; top: 1rem;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
}
.m-line1 { display: flex; justify-content: space-between; gap: 0.6rem; }
.m-from { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-date { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }
.m-subject {
  font-size: 0.88rem; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 0.15rem;
}
.m-clip { color: var(--muted); font-size: 0.8rem; margin-left: 0.3rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* Lector */
.reader { overflow-y: auto; background: var(--surface); display: flex; flex-direction: column; }
#reader-body { display: flex; flex-direction: column; flex: 1; padding: 1.1rem 1.4rem; }
.reader-actions { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; }
.reader-actions .reader-close { margin-left: auto; display: none; }
#r-subject {
  font-family: var(--font-display);
  font-size: 1.35rem; font-weight: 700;
  margin: 0 0 0.7rem;
}
.reader-meta {
  border-left: 3px solid var(--celeste);
  padding-left: 0.8rem;
  margin-bottom: 0.9rem;
  color: var(--ink);
  line-height: 1.7;
}
.metalabel {
  display: inline-block; min-width: 3.2em;
  color: var(--muted); text-transform: uppercase; font-size: 0.7rem;
}
.attachments { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.attachments a {
  font-family: var(--font-mono); font-size: 0.78rem;
  border: 1px solid var(--line); border-radius: 7px;
  padding: 0.35rem 0.6rem;
  text-decoration: none; color: var(--celeste);
  background: var(--bg);
}
.attachments a:hover { border-color: var(--celeste); }
#r-frame {
  flex: 1; min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  width: 100%;
}

/* ── Modales ──────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 36, 48, 0.45);
  display: grid; place-items: center;
  padding: 1rem;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  border-top: 4px solid var(--celeste);
  padding: 1.3rem;
  width: min(440px, 96vw);
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 18px 60px rgba(20, 36, 48, 0.25);
}
.modal-card.wide { width: min(680px, 96vw); }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.modal-head h3 { font-family: var(--font-display); margin: 0; }
.modal-foot { display: flex; gap: 0.6rem; margin-top: 0.5rem; }

/* ── Toast ────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 0.6rem 1.1rem; border-radius: 8px;
  font-size: 0.9rem; z-index: 99;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 180px 1fr; }
  .reader {
    position: fixed; inset: 0; z-index: 30;
    display: none;
  }
  .reader.open { display: flex; }
  .reader-actions .reader-close { display: inline-block; }
}
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; }
  .rail {
    display: flex; gap: 0.5rem; align-items: center;
    border-right: none; border-bottom: 1px solid var(--line);
    overflow-x: auto; padding: 0.5rem;
  }
  .rail .btn-block { width: auto; flex-shrink: 0; }
  .folders { display: flex; margin: 0; gap: 0.2rem; }
  .folders li { white-space: nowrap; border-left: none; }
  .folders li.active { box-shadow: inset 0 -2px 0 var(--celeste); }
  .topbar { flex-wrap: wrap; gap: 0.5rem; }
  .searchbox { order: 3; max-width: none; width: 100%; }
  .field-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
