:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --line: #e2e8e1;
  --text: #1f2a22;
  --muted: #6d7b70;
  --brand: #2e7d32;
  --brand-2: #43a047;
  --brand-soft: #e6f0e6;
  --chip: #eef2ec;
  --warn: #9a6212;
  --warn-bg: #fdf3e1;
  --bad: #c0392b;
  --bad-bg: #fbeae8;
  --mark: #fff1a8;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}
h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.offscreen { position: fixed; left: -9999px; top: 0; }
[hidden] { display: none !important; }

/* Iconos */
.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 9px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--brand); }
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .value:focus-visible, .linkish:focus-visible {
  outline: 3px solid rgba(46, 125, 50, .35); outline-offset: 1px;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #276c2b; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--chip); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 9px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon-only { padding: 7px; }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.linkish:hover { text-decoration: underline; }

/* Icono copiar junto a cada dato, con check al copiar */
.copy {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--brand); cursor: pointer;
  transition: background .12s, color .12s;
}
.copy:hover { background: var(--brand-soft); }
.copy:focus-visible { outline: 3px solid rgba(46, 125, 50, .35); outline-offset: 1px; }
.copy .icon { width: 18px; height: 18px; }
.copy .when-copied { display: none; }
.copy.copied { background: var(--brand-2); color: #fff; }
.copy.copied .when-idle { display: none; }
.copy.copied .when-copied { display: inline-grid; }
.copy .when-idle, .copy .when-copied { place-items: center; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .logo { height: 36px; width: auto; }
.topbar .titles { padding-left: 14px; border-left: 1px solid var(--line); }
.topbar .titles h1 { font-size: 15px; margin: 0; }
.topbar .titles p { margin: 0; font-size: 12px; color: var(--muted); }
.spacer { flex: 1; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab {
  background: none; border: 0; padding: 8px 12px; border-radius: 8px; font: inherit; font-size: 14px;
  color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { background: var(--chip); color: var(--text); }
.tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.badge { background: var(--warn); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 600; }

.user-menu { position: relative; }
.user-menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 8px; color: var(--muted); font-size: 14px;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--chip); color: var(--text); }
.user-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); width: 240px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .08);
}
.user-menu .menu p { margin: 0 0 8px; word-break: break-all; }
.user-menu .menu .btn { justify-content: flex-start; }

.content { max-width: 880px; margin: 0 auto; padding: 22px 18px 80px; }
.content.wide { max-width: 1240px; }

/* Buscador */
.search-bar { display: flex; gap: 10px; align-items: center; }
.search-bar > .btn { flex: none; height: 46px; padding: 0 16px; }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 10px; height: 46px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 10px; padding: 0 14px;
  transition: border-color .12s, box-shadow .12s;
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(46, 125, 50, .12); }
.search-icon { width: 20px; height: 20px; color: var(--muted); }
.search-input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 17px; padding: 0; height: 100%; background: transparent; min-width: 0; }
.search-meta { color: var(--muted); font-size: 13px; margin: 10px 2px 8px; min-height: 18px; }
.kbd-hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 18px; }
kbd { font-family: var(--mono); font-size: 11px; background: var(--panel); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  background: var(--chip); border: 1px solid transparent; color: var(--text);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--line); }
.chip.active { background: var(--brand); color: #fff; }

/* Tarjetas de resultado */
.results { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; transition: border-color .12s, box-shadow .12s;
}
.card.selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(46, 125, 50, .12); }
.card-head { display: flex; gap: 10px; align-items: flex-start; }
.card-title { flex: 1; min-width: 0; }
.card-title h2 { font-size: 17px; overflow-wrap: anywhere; }
.card-title mark { background: var(--mark); color: inherit; border-radius: 2px; }
.card-sub { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 3px; font-size: 13px; }
.card-actions { display: flex; gap: 2px; }
.notes { margin: 8px 0 0; font-size: 13px; color: var(--muted); font-style: italic; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.tag.soft { background: var(--chip); }
.tag.primary { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.account { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.account-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.account-head .bank { font-weight: 600; color: var(--text); }
.account-line { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.account-line .label { width: 42px; font-size: 12px; color: var(--muted); text-transform: uppercase; flex: none; }
.account-line .value {
  min-width: 0; text-align: left; font-size: 17px; background: none; border: 0; padding: 4px 6px; margin-left: 4px;
  border-radius: 6px; cursor: copy; color: var(--text); overflow-wrap: anywhere;
}
.account-line .value:hover { background: var(--brand-soft); }
.alert { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 8px 10px; border-radius: 8px; margin: 8px 0 0; }
.alert .icon { margin-top: 1px; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.empty-account { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.others { margin-top: 8px; font-size: 13px; }
.review-flag { display: flex; align-items: center; gap: 6px; color: var(--warn); font-size: 12px; margin: 10px 0 0; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty .btn { margin-top: 6px; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-box {
  display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-radius: 10px;
  background: #1f2a22; color: #fff; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: 90vw;
}
.toast-box.ok .icon { color: #8bd48f; }
.toast-box.warn { background: var(--warn); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 12px;
}
.login-logo { height: 48px; width: auto; align-self: center; }
.login-card h1 { text-align: center; font-size: 18px; }
.form-error { color: var(--bad); font-size: 13px; margin: 0; min-height: 1em; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-label { font-size: 13px; font-weight: 600; }
.field input, .field textarea, .field select, select {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); width: 100%;
}
.field input:focus, .field textarea:focus, select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(46, 125, 50, .12); }
.field-msg { font-size: 12px; color: var(--muted); min-height: 1em; }
.field-msg.ok { color: var(--brand); }
.field-msg.bad { color: var(--bad); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.check-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.check-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; background: var(--chip); border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.check-chip input { margin: 0; width: auto; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 0; margin: 4px 0 10px; }
legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; margin: 6px 0 12px; }

/* Dialogo */
.dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--text);
}
.dialog.wide { width: min(760px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(20, 30, 22, .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.dialog-body { padding: 16px 18px 20px; }
.editor section, .editor footer { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.editor-account { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.editor-accounts > .btn { margin-top: 10px; }
.account-form { background: var(--bg); border-radius: 10px; padding: 12px; margin: 8px 0; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.editor-review ul { padding: 0; list-style: none; margin: 0 0 8px; }
.editor-review li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; background: var(--warn-bg); color: var(--warn); border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.history { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; }
.history li { padding: 5px 0; border-bottom: 1px dashed var(--line); }

/* Revisar */
.review-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.review-list > li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.issues { margin: 4px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; }

/* Tablas */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; margin-top: 10px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
.table tr.inactive td { color: var(--muted); }
.table select { width: auto; padding: 5px 8px; }
.new-user { margin-top: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.new-user h2 { margin-bottom: 10px; }
.fatal { padding: 40px; text-align: center; color: var(--bad); }

/* Celular */
@media (max-width: 680px) {
  .hide-sm { display: none !important; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .titles { display: none; }
  .tabs { margin-left: 0; overflow-x: auto; }
  .content { padding: 14px 12px 80px; }
  .search-input { font-size: 16px; }
  .account-line .label { width: 34px; }
  .account-line .value { font-size: 15px; padding: 4px 2px; }
  .copy { width: 40px; height: 40px; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}

.merge { margin-top: 12px; }
.merge summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.merge input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; width: 100%; margin-top: 6px; }
.merge-results { list-style: none; padding: 0; margin: 6px 0 0; }
.merge-results li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }

/* Ingreso con Google */
.btn.google { background: #fff; border-color: #c9d1c9; color: var(--text); font-weight: 600; padding: 11px 12px; text-decoration: none; }
.btn.google:hover { border-color: var(--brand); background: var(--bg); }
.g-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #4285f4; color: #fff; font-weight: 700; font-size: 13px; }
.password-alt { margin-top: 6px; }
.password-alt summary { cursor: pointer; font-size: 13px; color: var(--muted); text-align: center; padding: 6px 0; }
.password-alt[open] summary { margin-bottom: 8px; }
.login-body { display: flex; flex-direction: column; gap: 10px; }

/* Tablas anchas: una linea por fila */
.users .table td, .users .table th, .history-view .table td, .history-view .table th { white-space: nowrap; }
.users .table td:last-child { width: 1%; text-align: right; }
.users .table { overflow: visible; }

/* Menu de tres puntos por fila */
.row-menu { position: relative; display: inline-block; }
.row-menu summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover, .row-menu[open] summary { background: var(--chip); color: var(--text); }
.row-menu summary .icon { stroke-width: 3.2; width: 18px; height: 18px; }
.row-menu .menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 200px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .1);
  display: flex; flex-direction: column;
}
.menu-item { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 7px; font: inherit; font-size: 14px; cursor: pointer; color: var(--text); white-space: nowrap; }
.menu-item:hover { background: var(--chip); }
.menu-item.danger { color: var(--bad); }
