/*
 * Despacho + portal. One stylesheet for both apps.
 * Palette and faces come from the site (styles.css); the apps add a quieter
 * working surface, semantic colours and a dark theme for evening work.
 */
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-latin-400-700-normal.woff2") format("woff2-variations"),
       url("/assets/fonts/newsreader-latin-400-700-normal.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-latin-400-500-italic.woff2") format("woff2-variations"),
       url("/assets/fonts/newsreader-latin-400-500-italic.woff2") format("woff2");
  font-weight: 400 500; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("/assets/fonts/figtree-latin-wght-normal.woff2") format("woff2-variations"),
       url("/assets/fonts/figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900; font-style: normal; font-display: swap;
}

:root {
  --ground: #f3eee3;
  --surface: #fffdf8;
  --surface-2: #f8f4ea;
  --surface-3: #efe8d8;
  --ink: #221f19;
  --ink-2: #3b372f;
  --muted: #5d5648;
  --faint: #736b5a;
  --line: #e3dccb;
  --line-2: #d4cab4;
  --green: #174036;
  --green-2: #1f5445;
  --green-ink: #174036;
  --green-wash: #e6ece4;
  --brass: #a5813f;
  --brass-ink: #7a5b23;
  --brass-wash: #f3ead6;
  --rail: #123329;
  --rail-ink: #f1ecdf;
  --rail-muted: rgba(241, 236, 223, .62);
  --rail-hover: rgba(241, 236, 223, .08);
  --rail-active: rgba(200, 171, 115, .16);

  --ok: #2f6f4e;   --ok-wash: #e3efe6;
  --warn: #8f5a0e; --warn-wash: #f7ebd3;
  --bad: #a03d2e;  --bad-wash: #f6e2dc;
  --info: #2f5f7a; --info-wash: #e2ecf1;
  --idle: #6b6454; --idle-wash: #ece7dc;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Figtree", "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-s: 6px; --r: 10px; --r-l: 16px;
  --sh-1: 0 1px 0 rgba(34, 31, 25, .04), 0 1px 3px rgba(34, 31, 25, .06);
  --sh-2: 0 2px 6px rgba(34, 31, 25, .06), 0 12px 32px rgba(34, 31, 25, .10);
  --sh-3: 0 8px 24px rgba(20, 18, 14, .14), 0 32px 80px rgba(20, 18, 14, .22);
  --focus: 0 0 0 3px rgba(165, 129, 63, .45);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f1714;
    --surface: #16201c;
    --surface-2: #1b2722;
    --surface-3: #22302a;
    --ink: #ede7d9;
    --ink-2: #d6cfbf;
    --muted: #b3ab99;
    --faint: #958e7e;
    --line: #26332d;
    --line-2: #334239;
    --green: #2d6b58;
    --green-2: #377b66;
    --green-ink: #8cc3ab;
    --green-wash: #1b2d26;
    --brass: #c8ab73;
    --brass-ink: #d9bf8a;
    --brass-wash: #2a2619;
    --rail: #0b120f;
    --rail-ink: #ede7d9;
    --rail-muted: rgba(237, 231, 217, .55);
    --rail-hover: rgba(237, 231, 217, .06);
    --rail-active: rgba(200, 171, 115, .14);
    --ok: #7cc39b;   --ok-wash: #183026;
    --warn: #e0b36a; --warn-wash: #33291a;
    --bad: #ec8f7e;  --bad-wash: #3a1f1a;
    --info: #8dbfdb; --info-wash: #1a2a33;
    --idle: #a59d8b; --idle-wash: #242b27;
    --sh-1: 0 1px 0 rgba(0, 0, 0, .25);
    --sh-2: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
    --sh-3: 0 8px 24px rgba(0, 0, 0, .45), 0 32px 80px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--ground); color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--green-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-s); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fbf8f1; }
.btn-primary:hover { background: var(--green-2); border-color: var(--green-2); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.08); background: var(--ok); border-color: var(--ok); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-3); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  color: var(--muted); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { color: #f6f2e8; }
  :root:not([data-theme="light"]) .btn-ok { color: #0f1714; }
  :root:not([data-theme="light"]) .toast { background: #26352f; }
}

.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.busy { pointer-events: none; }
.btn.busy > :not(.spin) { opacity: .0; }
.btn.busy { position: relative; }
.btn.busy::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.busy { color: transparent !important; }
.btn-primary.busy::after, .btn-ok.busy::after { border-color: #fff; border-right-color: transparent; }
.btn.busy::after { border-color: var(--ink); border-right-color: transparent; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--idle-wash); color: var(--idle);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--ok-wash); color: var(--ok); }
.pill.warn { background: var(--warn-wash); color: var(--warn); }
.pill.bad { background: var(--bad-wash); color: var(--bad); }
.pill.info { background: var(--info-wash); color: var(--info); }
.pill.brass { background: var(--brass-wash); color: var(--brass-ink); }
.pill.green { background: var(--green-wash); color: var(--green-ink); }

/* ---------- inputs ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 8px 11px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brass); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23978f7d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); flex-wrap: wrap; }
.seg button {
  height: 30px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.seg button .count { margin-left: 6px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 28px; padding: 0 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line-2); color: var(--ink-2); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--brass); background: var(--brass-wash); }
.chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fbf8f1; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--sh-1); }
.card-pad { padding: 20px; }
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px;
  min-height: 44px; padding: 10px 10px 10px 16px; border-radius: 12px;
  background: #1d2a25; color: #f1ecdf; box-shadow: var(--sh-3); font-size: 14px;
  animation: toast-in .28s var(--ease);
}
.toast.bad { background: #5a221a; }
.toast button { color: #e6cf9f; font-weight: 700; padding: 6px 10px; border-radius: 8px; }
.toast button:hover { background: rgba(255, 255, 255, .08); }
.toast.out { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@media (max-width: 760px) { .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* ---------- skeleton ---------- */
.sk { border-radius: 8px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: sk 1.3s ease-in-out infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- auth screens (both apps) ---------- */
.auth {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(165, 129, 63, .10), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(23, 64, 54, .10), transparent 60%),
    var(--ground);
}
.auth-card { width: min(100%, 420px); padding: 36px 32px 30px; }
.auth-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 700; font-size: 14px; letter-spacing: .01em; }
.auth-mark svg { width: 30px; height: 30px; }
.auth h1 { font-size: 30px; line-height: 1.15; margin-bottom: 10px; }
.auth p { color: var(--muted); }
.auth .actions { margin-top: 26px; display: grid; gap: 10px; }
.auth .foot { margin-top: 22px; font-size: 13px; color: var(--muted); }
.auth .note { margin-top: 18px; padding: 12px 14px; border-radius: 10px; font-size: 14px; background: var(--surface-2); color: var(--ink-2); }
.auth .note.bad { background: var(--bad-wash); color: var(--bad); }
.auth .note.ok { background: var(--ok-wash); color: var(--ok); }
.auth ol { margin: 14px 0 0; padding-left: 20px; color: var(--ink-2); display: grid; gap: 8px; font-size: 14px; }
.auth code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.sent-anim { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-wash); color: var(--ok); margin-bottom: 18px; animation: pop .45s var(--ease); }
.sent-anim svg { width: 24px; height: 24px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

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

.auth .relink { display: grid; gap: 12px; margin-top: 20px; text-align: left; }
.auth .relink .done { padding: 12px 14px; border-radius: 10px; background: var(--ok-wash); color: var(--ink); font-size: 14px; }

/* Sistema · Agentes: running and recent jobs */
.sec-col ul.plain { margin: 6px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.6; }
.sec-col ul.plain a { color: var(--green); }
