:root {
  color-scheme: light;
  --ink: #0b1725;
  --ink-soft: #183046;
  --mint: #27d19c;
  --mint-dark: #0c8f6a;
  --cyan: #4bc7e5;
  --paper: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eaf0ed;
  --text: #142230;
  --muted: #607080;
  --line: #d7e1dc;
  --danger: #c53f50;
  --warning: #a76a00;
  --success: #07835f;
  --shadow: 0 18px 45px rgba(11, 23, 37, .11);
  --radius: 18px;
  --sidebar: 264px;
  --sidebar-background: #ffffff;
  --sidebar-foreground: #142230;
  --sidebar-muted: #526776;
  --sidebar-border: #d7e1dc;
  --sidebar-hover: #eaf0ed;
  --sidebar-active: #087a5a;
  --sidebar-active-background: rgba(39, 209, 156, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #09131e;
  --surface: #0f2030;
  --surface-2: #162a3c;
  --text: #edf7f3;
  --muted: #9eb1bd;
  --line: #284052;
  --danger: #ff7182;
  --warning: #f2bd5e;
  --success: #4de2b4;
  --shadow: 0 18px 45px rgba(0, 0, 0, .3);
  --sidebar-background: #0b1725;
  --sidebar-foreground: #f4f7f5;
  --sidebar-muted: #aebfc9;
  --sidebar-border: rgba(255, 255, 255, .06);
  --sidebar-hover: rgba(255, 255, 255, .07);
  --sidebar-active: #27d19c;
  --sidebar-active-background: rgba(39, 209, 156, .1);
}

* { box-sizing: border-box; }

html { background: var(--paper); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--text); background: var(--paper); }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--mint-dark); }
img { max-width: 100%; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--cyan) 70%, transparent); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 1000; left: 1rem; top: -5rem; padding: .75rem 1rem; border-radius: 10px; color: var(--ink); background: var(--mint); }
.skip-link:focus { top: 1rem; }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--muted); }
.brand-mark { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: var(--ink); background: linear-gradient(135deg, var(--mint), var(--cyan)); box-shadow: 0 12px 30px rgba(39, 209, 156, .25); }
.brand-mark i { font-size: 1.35rem; }

.public-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(360px, .82fr); background: var(--ink); color: #f4f7f5; overflow: hidden; }
.public-visual { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: clamp(2rem, 5vw, 5rem); isolation: isolate; }
.public-visual::before { content: ""; position: absolute; z-index: -2; inset: 0; background: linear-gradient(90deg, rgba(11,23,37,.9), rgba(11,23,37,.2)), url('/assets/images/pulso-social.jpg') center/cover; opacity: .85; }
.public-visual::after { content: ""; position: absolute; z-index: -1; inset: 0; background: radial-gradient(circle at 30% 68%, rgba(39,209,156,.19), transparent 34%); }
.public-brand { display: flex; align-items: center; gap: .85rem; font-weight: 760; font-size: 1.05rem; letter-spacing: -.01em; }
.public-copy { max-width: 720px; }
.eyebrow { margin: 0 0 .65rem; color: var(--mint); font-size: .78rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.public-copy h1 { margin: 0; font-size: clamp(3rem, 8vw, 7.2rem); line-height: .88; letter-spacing: -.075em; }
.public-copy h1 span { display: block; color: var(--mint); }
.public-copy p { max-width: 570px; margin: 1.5rem 0 0; color: #c6d6de; font-size: clamp(1rem, 1.8vw, 1.25rem); line-height: 1.65; }
.copyright { color: #8197a6; font-size: .8rem; }
.login-panel { display: grid; place-content: center; padding: clamp(2rem, 6vw, 6rem); background: var(--surface); color: var(--text); }
.login-card { max-width: 420px; }
.login-card h2 { margin: .5rem 0; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.045em; }
.login-card > p { margin: 0 0 2rem; color: var(--muted); line-height: 1.65; }
.security-note { display: flex; align-items: flex-start; gap: .75rem; margin-top: 1.25rem; color: var(--muted); font-size: .84rem; line-height: 1.5; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); transition: grid-template-columns .2s ease; }
.app-shell.sidebar-collapsed { --sidebar: 82px; }
.sidebar { position: sticky; top: 0; height: 100vh; z-index: 30; display: flex; flex-direction: column; padding: 1rem; color: var(--sidebar-foreground); background: var(--sidebar-background); border-right: 1px solid var(--sidebar-border); transition: color .2s ease, background-color .2s ease, border-color .2s ease; }
.sidebar-brand { display: flex; align-items: center; gap: .8rem; min-height: 54px; padding: .2rem; color: var(--sidebar-foreground); text-decoration: none; font-weight: 760; white-space: nowrap; overflow: hidden; }
.sidebar-brand .brand-mark { flex: 0 0 44px; width: 44px; height: 44px; }
.sidebar nav { display: grid; gap: .35rem; margin-top: 1.5rem; }
.nav-link { display: flex; align-items: center; gap: .85rem; min-height: 46px; padding: .7rem .9rem; border-radius: 12px; color: var(--sidebar-muted); text-decoration: none; white-space: nowrap; overflow: hidden; transition: color .15s, background .15s; }
.nav-link i { flex: 0 0 24px; text-align: center; }
.nav-link:hover { color: var(--sidebar-foreground); background: var(--sidebar-hover); }
.nav-link.active { color: var(--sidebar-active); background: var(--sidebar-active-background); box-shadow: inset 3px 0 var(--sidebar-active); }
.sidebar-footer { margin-top: auto; display: grid; gap: .4rem; }
.sidebar-meta { display: grid; gap: .18rem; margin-top: .6rem; padding: .8rem .9rem .45rem; border-top: 1px solid var(--sidebar-border); color: var(--sidebar-muted); overflow: hidden; }
.sidebar-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .7rem; }
.sidebar-version { font: 600 .7rem ui-monospace, SFMono-Regular, Consolas, monospace; }
.sidebar-collapse { width: 100%; justify-content: flex-start; }
.sidebar-collapsed .sidebar-label, .sidebar-collapsed .sidebar-brand strong { opacity: 0; width: 0; }
.sidebar-collapsed .sidebar-meta { justify-items: center; padding-inline: .2rem; }
.sidebar-collapsed .sidebar-copyright { display: none; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 25; min-height: 72px; display: flex; align-items: center; gap: 1rem; padding: .75rem clamp(1rem, 2.5vw, 2rem); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 87%, transparent); backdrop-filter: blur(18px); }
.mobile-menu { display: none; }
.topbar-title { min-width: 0; margin-right: auto; }
.topbar-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title small { display: block; margin-top: .15rem; color: var(--muted); }
.icon-button, .ghost-button { appearance: none; border: 0; cursor: pointer; color: inherit; background: transparent; }
.icon-button { width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 12px; }
.icon-button:hover, .ghost-button:hover { background: var(--surface-2); }
.user-menu { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; border-radius: 50%; color: var(--ink); background: linear-gradient(135deg, var(--mint), var(--cyan)); font-weight: 800; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-meta { line-height: 1.2; }
.user-meta strong { display: block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.user-meta small { color: var(--muted); font-size: .74rem; }

.page { width: min(1540px, 100%); margin: 0 auto; padding: clamp(1rem, 2.5vw, 2rem); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: .5rem 0 1.5rem; }
.page-heading h1 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.7rem); line-height: 1; letter-spacing: -.055em; }
.page-heading p { margin: .55rem 0 0; color: var(--muted); }
.heading-actions { display: flex; gap: .65rem; flex-wrap: wrap; }

.grid { display: grid; gap: 1rem; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card, .card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 0 rgba(255,255,255,.08); }
.stat-card { position: relative; overflow: hidden; padding: 1.25rem; }
.stat-card::after { content: ""; position: absolute; right: -35px; bottom: -50px; width: 120px; height: 120px; border-radius: 50%; background: color-mix(in srgb, var(--accent, var(--mint)) 12%, transparent); }
.stat-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--accent, var(--mint)); background: color-mix(in srgb, var(--accent, var(--mint)) 12%, transparent); }
.stat-card small { display: block; margin-top: 1.2rem; color: var(--muted); }
.stat-card strong { display: block; margin-top: .35rem; font-size: clamp(1.5rem, 3vw, 2.25rem); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.card { overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 1.25rem; }
.dashboard-grid { grid-template-columns: minmax(0, 1.5fr) minmax(280px, .5fr); margin-top: 1rem; }
.pulse-panel { min-height: 280px; padding: 1.5rem; color: #edf7f3; background: var(--ink); }
.pulse-panel .pulse-line { height: 120px; margin: 2rem -1.5rem 0; background: linear-gradient(transparent 48%, rgba(39,209,156,.16) 49%, rgba(39,209,156,.16) 51%, transparent 52%), radial-gradient(ellipse at 68% 50%, rgba(75,199,229,.13), transparent 50%); position: relative; overflow: hidden; }
.pulse-panel .pulse-line::after { content: ""; position: absolute; inset: 38px -8%; border-top: 4px solid var(--mint); transform: skewX(-18deg) rotate(-2deg); filter: drop-shadow(0 0 9px rgba(39,209,156,.65)); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; min-height: 42px; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 12px; cursor: pointer; text-decoration: none; font-weight: 720; font-size: .88rem; transition: transform .12s, box-shadow .12s, background .12s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button-primary { color: var(--ink); background: var(--mint); box-shadow: 0 8px 20px rgba(39,209,156,.18); }
.button-primary:hover { background: color-mix(in srgb, var(--mint) 87%, white); }
.button-secondary { color: var(--text); border-color: var(--line); background: var(--surface); }
.button-danger { color: white; background: var(--danger); }
.button-small { min-height: 34px; padding: .45rem .65rem; font-size: .78rem; }
.button-wide { width: 100%; }
.button-row { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1rem; }

.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .9rem 1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface); font-size: .73rem; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td { max-width: 340px; }
.cell-truncate { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.charge { color: var(--danger); }
.credit { color: var(--success); }
.balance { font-weight: 800; }
.actions-column { position: sticky; right: 0; z-index: 2; background: var(--surface); box-shadow: -8px 0 14px rgba(11,23,37,.04); }
tr:hover .actions-column { background: var(--surface-2); }
.draggable { cursor: grab; user-select: none; }
.draggable.dragging { opacity: .4; }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 760; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { color: var(--success); background: color-mix(in srgb, var(--success) 11%, transparent); }
.badge-muted { color: var(--muted); background: var(--surface-2); }
.badge-warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent); }
.badge-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

.company-tree, .company-tree ul { list-style: none; margin: 0; padding: 0; }
.company-tree ul { margin-left: 1.25rem; border-left: 1px dashed var(--line); }
.company-node { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.company-node > i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--mint-dark); background: color-mix(in srgb, var(--mint) 12%, transparent); }
.company-node .grow { flex: 1; min-width: 0; }
.company-node strong, .company-node small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-node small { margin-top: .2rem; color: var(--muted); }

.empty-state { display: grid; place-items: center; min-height: 270px; padding: 2rem; text-align: center; }
.empty-state > div > i { font-size: 2rem; color: var(--mint); }
.empty-state h2 { margin: 1rem 0 .4rem; }
.empty-state p { max-width: 480px; margin: 0 0 1.25rem; color: var(--muted); line-height: 1.6; }
.pending-state { min-height: calc(100vh - 72px); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: .42rem; font-size: .84rem; font-weight: 720; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: .68rem .75rem; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: var(--surface); }
.field textarea { min-height: 100px; resize: vertical; }
.field-help { display: block; margin-top: .38rem; color: var(--muted); font-size: .75rem; line-height: 1.4; }
.check-field { display: flex; align-items: flex-start; gap: .7rem; padding: .8rem; border: 1px solid var(--line); border-radius: 12px; }
.check-field input[type="checkbox"] { flex: 0 0 auto; width: 1rem; height: 1rem; min-height: 0; margin: .15rem 0 0; padding: 0; border: 0; accent-color: var(--mint-dark); }
.check-field span { display: block; }
.check-field small { display: block; margin-top: .25rem; color: var(--muted); }
.permissions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; max-height: 280px; overflow: auto; padding: .15rem; }
.permissions-grid .check-field { align-items: flex-start; gap: .55rem; min-height: 50px; padding: .5rem .6rem; border-radius: 10px; }
.permissions-grid .check-field span { min-width: 0; line-height: 1.2; }
.permissions-grid .check-field strong { display: block; overflow-wrap: anywhere; font-size: .78rem; }
.permissions-grid .check-field small { margin-top: .18rem; font-size: .68rem; line-height: 1.25; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgba(4, 12, 20, .7); backdrop-filter: blur(6px); }
.modal { width: min(680px, 100%); max-height: calc(100vh - 2rem); overflow: auto; border: 1px solid var(--line); border-radius: 22px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.modal-large { width: min(960px, 100%); }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal-header h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 1.25rem; }

.signature-box { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.signature-canvas { display: block; width: 100%; height: 190px; touch-action: none; cursor: crosshair; }
.signature-toolbar { display: flex; align-items: center; justify-content: space-between; padding: .55rem .75rem; border-top: 1px solid #d7e1dc; color: #536473; background: #f4f7f5; font-size: .78rem; }
.transfer-layout { display: grid; grid-template-columns: minmax(240px, .7fr) minmax(0, 1.3fr); gap: 1.25rem; }
.qr-card { display: grid; align-content: start; justify-items: center; gap: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); text-align: center; }
.qr-card img { width: min(260px, 100%); aspect-ratio: 1; border-radius: 10px; background: white; }
.copy-link { width: 100%; display: flex; gap: .4rem; }
.copy-link input { min-width: 0; width: 100%; }
.amount-hero { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 820; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.certification { padding: 1rem; border-left: 4px solid var(--mint); border-radius: 0 12px 12px 0; background: color-mix(in srgb, var(--mint) 8%, transparent); line-height: 1.55; }

.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: .8rem; padding-bottom: 1.15rem; }
.timeline-item::before { content: ""; position: absolute; left: 15px; top: 31px; bottom: 0; width: 1px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--mint-dark); background: color-mix(in srgb, var(--mint) 14%, var(--surface)); }
.timeline-content { min-width: 0; padding-top: .25rem; }
.timeline-content p { margin: .2rem 0; }
.technical { color: var(--muted); font: .74rem ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }

.toast-region { position: fixed; z-index: 200; right: 1rem; bottom: 1rem; display: grid; gap: .65rem; width: min(420px, calc(100vw - 2rem)); }
.toast { display: flex; align-items: flex-start; gap: .75rem; padding: .9rem 1rem; border: 1px solid var(--line); border-left: 4px solid var(--mint); border-radius: 13px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast > div { flex: 1; }
.toast strong { display: block; margin-bottom: .2rem; }
.toast p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.toast .button { margin-top: .55rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

.loading-line { height: 3px; position: fixed; z-index: 300; left: 0; right: 0; top: 0; overflow: hidden; background: transparent; }
.loading-line::after { content: ""; display: block; width: 35%; height: 100%; background: var(--mint); animation: loading 1s infinite ease-in-out; }
@keyframes loading { from { transform: translateX(-110%); } to { transform: translateX(320%); } }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .transfer-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .public-shell { grid-template-columns: 1fr; }
  .public-visual { min-height: 52vh; }
  .login-panel { min-height: 48vh; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: min(290px, 86vw); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; }
  .sidebar-collapse { display: none; }
  .user-meta { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .permissions-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { min-height: 64px; }
  .page { padding: 1rem; }
  .card-header { align-items: flex-start; flex-direction: column; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap th, .table-wrap td { display: block; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .table-wrap tbody { display: grid; gap: .8rem; padding: .8rem; }
  .table-wrap tr { padding: .35rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  .table-wrap td { position: relative; min-height: 42px; max-width: none; padding: .65rem .7rem .65rem 42%; border-bottom: 1px dashed var(--line); text-align: left; white-space: normal; }
  .table-wrap td::before { content: attr(data-label); position: absolute; left: .7rem; top: .65rem; width: 36%; color: var(--muted); font-size: .68rem; font-weight: 760; letter-spacing: .04em; text-transform: uppercase; }
  .table-wrap td:last-child { border-bottom: 0; }
  .actions-column { position: static; box-shadow: none; }
  .cell-truncate { max-width: none; white-space: normal; }
}

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