:root {
  --bg: #f3f5f2;
  --card: #ffffff;
  --ink: #17201b;
  --muted: #66736b;
  --line: #e2e7e3;
  --accent: #128c5e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f4ec;
  --ok: #128c5e;
  --pend: #b7791f;
  --pend-soft: #fdf3e1;
  --err: #c53b3b;
  --err-soft: #fbe9e9;
  --info-soft: #eef1f5;
  --bubble: #dcf8c6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --card: #171e1b; --ink: #e7ece9; --muted: #95a39b; --line: #27302c;
    --accent: #25b37a; --accent-ink: #06130d; --accent-soft: #143326;
    --pend: #e2a640; --pend-soft: #33280f; --err: #ee6b6b; --err-soft: #3a1a1a; --info-soft: #1f2724;
    --bubble: #1f4434; --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 19px; }
h2 { font-size: 15px; font-weight: 650; }
code { background: var(--info-soft); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 24px; max-width: 1240px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent); position: relative; flex: none;
}
.logo::after {
  content: ""; position: absolute; left: 12px; top: 9px; width: 9px; height: 16px;
  border: solid var(--accent-ink); border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.top-status { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.user-box { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }

.pill, .tag {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; background: var(--info-soft); color: var(--muted); white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok, .tag.ok { background: var(--accent-soft); color: var(--ok); }
.pill.pend, .tag.pend { background: var(--pend-soft); color: var(--pend); }
.pill.err, .tag.err { background: var(--err-soft); color: var(--err); }
.pill.pend::before { animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.banner {
  max-width: 1192px; margin: 0 auto 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--info-soft); color: var(--ink); font-size: 14px;
}
.banner.warn { background: var(--pend-soft); color: var(--pend); font-weight: 600; }
@media (max-width: 1240px) { .banner { margin-left: 24px; margin-right: 24px; } }

.grid {
  max-width: 1240px; margin: 0 auto; padding: 0 24px 40px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
}
.span-2 { grid-column: span 2; }
@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); padding: 0 16px 32px; }
  .span-2 { grid-column: auto; }
  .top { padding: 16px; }
  .banner { margin-left: 16px; margin-right: 16px; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 600px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.stat .n { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat.ok .n { color: var(--ok); } .stat.pend .n { color: var(--pend); } .stat.err .n { color: var(--err); }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.facts > div { display: flex; flex-direction: column; min-width: 0; }
.facts .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts .v { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress { height: 6px; background: var(--info-soft); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }

.controls, .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 14px; padding: 9px 15px; border-radius: 10px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn.danger-outline { color: var(--err); }
.btn.danger-outline:hover:not(:disabled) { border-color: var(--err); background: var(--err-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.small-btn { padding: 6px 11px; font-size: 13px; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font: inherit; font-size: 13px; }
.icon-btn:hover { background: var(--info-soft); color: var(--ink); }
.icon-btn.del:hover { color: var(--err); background: var(--err-soft); }

textarea, input[type=search], input[type=text], input[type=password] {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; resize: vertical;
}
textarea { min-height: 96px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.note { margin: 0; font-size: 13px; color: var(--muted); }

.qr-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qr-box {
  width: 200px; height: 200px; border-radius: 12px; border: 1px dashed var(--line);
  display: grid; place-items: center; text-align: center; background: var(--bg); flex: none;
}
.qr-box img { width: 188px; height: 188px; border-radius: 8px; background: #fff; padding: 6px; }
.qr-msg { padding: 14px; font-size: 14px; color: var(--muted); }
.qr-msg b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.help { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); flex: 1; min-width: 180px; }
.help li { margin-bottom: 4px; }

.modes { display: grid; gap: 8px; }
.mode { display: block; cursor: pointer; }
.mode input { position: absolute; opacity: 0; }
.mode span {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted);
}
.mode span b { color: var(--ink); }
.mode span em { font-style: normal; font-weight: 700; color: var(--ink); }
.mode input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.mode input:checked + span em { color: var(--accent); }
.mode input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.preview { border-radius: 12px; background: var(--info-soft); padding: 14px; }
.preview-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.bubble {
  background: var(--bubble); border-radius: 10px 10px 10px 2px; padding: 9px 12px; max-width: 92%;
  white-space: pre-wrap; word-break: break-word; font-size: 14.5px;
}
.bubble a { color: inherit; }

.search { padding: 8px 12px; }
.list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .who { flex: 1; min-width: 0; }
.list .who .p { font-weight: 600; font-variant-numeric: tabular-nums; }
.list .who .nm { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .empty { justify-content: center; color: var(--muted); font-size: 14px; padding: 18px; }
.list .edit { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: 1; }
.list .edit input { padding: 6px 8px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--err-soft); color: var(--err); }

.table-wrap { overflow: auto; max-height: 360px; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--card); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
td.detail { white-space: normal; color: var(--muted); min-width: 200px; }
tbody tr:last-child td { border-bottom: 0; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--err); color: #fff; }

.modal-wrap { position: fixed; inset: 0; background: rgba(10, 16, 13, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: 100%; max-width: 420px; }
.modal-msg { margin: 0; white-space: pre-line; font-size: 15px; }
.row.end { justify-content: flex-end; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }

/* Login e páginas de senha */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; margin-bottom: 18px; }
.login form, .account form { display: flex; flex-direction: column; gap: 14px; }
.login label, .account label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.login .btn { justify-content: center; padding: 11px 15px; }
.login .err, .msg.err { color: var(--err); background: var(--err-soft); border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.msg.ok { color: var(--ok); background: var(--accent-soft); border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.link { color: var(--accent); font-size: 14px; text-align: center; text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }
input[type=email] { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.account .modal { max-width: 440px; max-height: calc(100vh - 32px); overflow: auto; }
.account h3 { margin: 0; font-size: 15px; }
.account hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
[hidden] { display: none !important; }
