:root {
  --bg: #01030a;
  --panel: rgba(5, 9, 20, .88);
  --panel-strong: rgba(3, 7, 16, .96);
  --stroke: rgba(126, 146, 191, .14);
  --stroke-strong: rgba(126, 146, 191, .3);
  --text: #ecf4ff;
  --muted: #9db0d7;
  --cyan: #00e7ff;
  --violet: #8f6cff;
  --green: #1df5a0;
  --yellow: #ffcb61;
  --danger: #ff6685;
  --shadow: 0 24px 80px rgba(0, 0, 0, .4);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(circle at 10% -10%, rgba(79, 140, 255, .16), transparent 35%),
    radial-gradient(circle at 90% 0%, rgba(167, 139, 250, .14), transparent 36%),
    radial-gradient(circle at 50% 100%, rgba(0, 231, 255, .07), transparent 42%),
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.012) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button:disabled { cursor: not-allowed; opacity: .48; }

.glass {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.app-shell { width: min(1480px, calc(100vw - 28px)); margin: 0 auto; padding: 18px 0 36px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 24px; margin-bottom: 18px; }
.dashboard-brand, .login-brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-mark {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(0, 231, 255, .24);
  border-radius: 18px;
  color: var(--cyan);
  background: linear-gradient(135deg, rgba(0, 231, 255, .18), rgba(143, 108, 255, .22)), rgba(9, 16, 31, .74);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 18px 32px rgba(0,0,0,.34), 0 0 0 1px rgba(0,231,255,.1);
  font-size: 1.55rem;
  font-weight: 900;
}
.brand-mark::before { content: ""; position: absolute; inset: 9px; border: 1px solid rgba(255,255,255,.1); border-radius: 13px; transform: rotate(12deg); }
.brand-mark span { position: relative; text-shadow: 0 0 18px rgba(0,231,255,.5); }
.eyebrow { color: var(--cyan); text-transform: uppercase; font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
h1 { margin: 6px 0 8px; font-size: clamp(1.65rem, 1.1rem + 1.4vw, 2.65rem); line-height: 1.05; }
h2 { margin: 5px 0 7px; font-size: 1.2rem; }
.lead { margin-bottom: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.top-actions form { margin: 0; }
.nav-pill, .logout-btn, .status-pill {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  font-size: .82rem;
  font-weight: 800;
  cursor: pointer;
}
.nav-pill { border-color: rgba(0,231,255,.26); background: linear-gradient(135deg, rgba(0,231,255,.12), rgba(29,245,160,.07)); }
.nav-pill:hover { color: var(--green); border-color: rgba(29,245,160,.42); }
.logout-btn { color: var(--danger); border-color: rgba(255,102,133,.24); }
.logout-btn:hover { border-color: rgba(255,102,133,.5); background: rgba(255,102,133,.08); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { position: relative; min-height: 126px; padding: 18px; overflow: hidden; border-radius: var(--radius-lg); }
.stat-card::after { content: ""; position: absolute; right: -26px; bottom: -40px; width: 110px; height: 110px; border-radius: 50%; filter: blur(8px); opacity: .13; }
.stat-card > span { display: block; color: var(--muted); font-size: .82rem; font-weight: 700; }
.stat-card strong { display: block; margin: 13px 0 8px; font-size: clamp(1.55rem, 1.15rem + .8vw, 2.15rem); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-card small { color: var(--muted); font-size: .74rem; }
.accent-cyan::after { background: var(--cyan); }.accent-cyan strong { color: var(--cyan); }
.accent-green::after { background: var(--green); }.accent-green strong { color: var(--green); }
.accent-violet::after { background: var(--violet); }.accent-violet strong { color: #b9a9ff; }
.accent-yellow::after { background: var(--yellow); }.accent-yellow strong { color: var(--yellow); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, .72fr); gap: 18px; align-items: start; }
.entry-panel, .ranking-panel, .audit-panel { padding: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.panel-head p { max-width: 650px; margin-bottom: 0; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.compact-head { align-items: center; }
.date-picker { min-width: 190px; }
.date-picker label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.date-picker input, .login-form input, .reason-input {
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  outline: none;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  background: rgba(8, 14, 28, .9);
  color: var(--text);
}
.date-picker input:focus, .login-form input:focus, .reason-input:focus, .tip-input:focus { border-color: rgba(0,231,255,.48); box-shadow: 0 0 0 3px rgba(0,231,255,.08); }
.tip-list { display: grid; gap: 8px; }
.tip-row {
  min-height: 72px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 30px 42px minmax(150px, 1fr) minmax(80px, .45fr) minmax(148px, .6fr);
  gap: 11px;
  align-items: center;
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(255,255,255,.038), rgba(255,255,255,.018));
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.tip-row:hover { border-color: rgba(0,231,255,.2); background: linear-gradient(180deg, rgba(0,231,255,.045), rgba(255,255,255,.02)); }
.tip-row.is-dirty { border-color: rgba(255,203,97,.32); background: linear-gradient(180deg, rgba(255,203,97,.06), rgba(255,255,255,.018)); }
.row-position { color: rgba(157,176,215,.62); font: 700 .72rem ui-monospace, monospace; }
.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  border: 1px solid rgba(0,231,255,.22);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0,231,255,.12), rgba(143,108,255,.18));
  color: var(--cyan);
  font-size: .76rem;
  font-weight: 900;
}
.small-avatar { width: 34px; height: 34px; border-radius: 11px; font-size: .67rem; }
.person-meta { min-width: 0; display: grid; gap: 4px; }
.person-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.person-meta span, .person-total span { color: var(--muted); font-size: .7rem; }
.person-total { display: grid; gap: 4px; justify-items: end; }
.person-total strong { font-size: .9rem; font-variant-numeric: tabular-nums; }
.amount-control { min-height: 46px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; border: 1px solid rgba(0,231,255,.18); border-radius: 12px; overflow: hidden; background: rgba(0,231,255,.035); }
.amount-control > span { padding-left: 10px; color: var(--cyan); font-size: .68rem; font-weight: 900; }
.tip-input { width: 100%; height: 44px; padding: 0 11px 0 8px; border: 0; outline: none; background: transparent; color: var(--text); text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.tip-input::-webkit-inner-spin-button { appearance: none; }
.field-error { margin: -2px 8px 4px; color: var(--danger); font-size: .74rem; }
.save-bar { position: sticky; bottom: 10px; margin-top: 16px; padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; border: 1px solid var(--stroke-strong); border-radius: 16px; background: rgba(3,7,16,.94); box-shadow: 0 16px 40px rgba(0,0,0,.42); backdrop-filter: blur(16px); }
.reason-field { display: grid; gap: 6px; }
.reason-field > span { color: var(--muted); font-size: .7rem; font-weight: 700; }
.reason-field.is-required > span { color: var(--yellow); }
.reason-field.is-required > span::after { content: " · requerido"; }
.save-summary { display: flex; align-items: center; gap: 12px; }
.save-summary > span { min-width: 105px; color: var(--muted); font-size: .74rem; text-align: right; }
.primary-btn, .ghost-btn {
  min-height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0,231,255,.34);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0,231,255,.2), rgba(143,108,255,.18));
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}
.primary-btn:hover:not(:disabled) { border-color: rgba(29,245,160,.46); box-shadow: 0 0 24px rgba(0,231,255,.09); }
.ghost-btn { border-color: rgba(255,255,255,.13); background: rgba(255,255,255,.04); }
.compact-btn { width: fit-content; margin-top: 8px; }

.side-column { display: grid; gap: 18px; }
.status-pill { min-height: 28px; padding: 0 10px; color: var(--green); border-color: rgba(29,245,160,.26); background: rgba(29,245,160,.07); font-size: .68rem; }
.ranking-list, .audit-list { display: grid; gap: 7px; }
.audit-list { max-height: 410px; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(0,231,255,.35) transparent; }
.ranking-row { min-height: 57px; padding: 8px 9px; display: grid; grid-template-columns: 24px 34px minmax(0, 1fr) auto; gap: 9px; align-items: center; border: 1px solid rgba(255,255,255,.065); border-radius: 13px; background: rgba(255,255,255,.025); }
.rank { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); background: rgba(255,255,255,.05); font-size: .68rem; font-weight: 900; }
.rank-1 { color: var(--yellow); background: rgba(255,203,97,.12); }.rank-2 { color: #d7e0f5; }.rank-3 { color: #e7a56f; }
.ranking-row > div { min-width: 0; display: grid; gap: 3px; }
.ranking-row > div strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.ranking-row > div small { color: var(--muted); font-size: .66rem; }
.rank-total { color: var(--green); font-size: .82rem; font-variant-numeric: tabular-nums; }
.audit-row { min-height: 55px; padding: 9px; display: grid; grid-template-columns: 9px minmax(0, 1fr); gap: 9px; align-items: start; border-bottom: 1px solid rgba(255,255,255,.055); }
.audit-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px rgba(0,231,255,.45); }
.audit-updated { background: var(--yellow); box-shadow: 0 0 10px rgba(255,203,97,.42); }
.audit-row > div { display: grid; gap: 3px; }
.audit-row strong { font-size: .78rem; }.audit-row span { color: var(--text); font-size: .72rem; }.audit-row small { color: var(--muted); font-size: .65rem; }
.inline-empty { padding: 24px 12px; color: var(--muted); text-align: center; font-size: .82rem; }

.empty-state { min-height: 340px; padding: 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-state p { max-width: 540px; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 15px; border-radius: 18px; color: var(--cyan); background: rgba(0,231,255,.09); border: 1px solid rgba(0,231,255,.2); font-size: 1.8rem; }
.form-error { margin-bottom: 12px; padding: 10px 12px; border: 1px solid rgba(255,102,133,.28); border-radius: 12px; background: rgba(255,102,133,.08); color: var(--danger); font-size: .8rem; }

.login-shell { min-height: 100vh; padding: 24px; display: grid; place-items: center; }
.login-panel { width: min(470px, 100%); padding: 28px; }
.login-brand { align-items: flex-start; margin-bottom: 24px; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 4px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.login-form .primary-btn { margin-top: 8px; width: 100%; }
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: min(380px, calc(100vw - 36px)); padding: 11px 15px; border: 1px solid; border-radius: 13px; background: rgba(5,9,20,.96); box-shadow: 0 14px 36px rgba(0,0,0,.4); font-size: .8rem; animation: toast-in .22s ease; }
.toast-success { color: var(--green); border-color: rgba(29,245,160,.3); }.toast-error { color: var(--danger); border-color: rgba(255,102,133,.3); }.toast-info { color: var(--cyan); border-color: rgba(0,231,255,.26); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .app-shell { width: calc(100vw - 18px); padding-top: 9px; }
  .topbar, .panel-head { flex-direction: column; align-items: stretch; }
  .topbar { padding: 18px; }
  .top-actions { justify-content: flex-start; }
  .date-picker { width: 100%; }
  .entry-panel, .ranking-panel, .audit-panel { padding: 14px; border-radius: 20px; }
  .tip-row { grid-template-columns: 26px 38px minmax(0, 1fr) minmax(132px, .7fr); }
  .avatar { width: 38px; height: 38px; border-radius: 12px; }
  .person-total { display: none; }
  .save-bar { grid-template-columns: 1fr; }
  .save-summary { justify-content: space-between; }
  .side-column { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { min-height: 112px; padding: 14px; }
  .stat-card strong { font-size: 1.35rem; }
  .dashboard-brand { align-items: flex-start; }
  .brand-mark { width: 48px; height: 48px; flex-basis: 48px; border-radius: 15px; }
  .tip-row { grid-template-columns: 24px 34px minmax(0, 1fr); gap: 8px; }
  .tip-row .avatar { width: 34px; height: 34px; }
  .amount-control { grid-column: 2 / -1; width: 100%; }
  .save-summary { align-items: stretch; flex-direction: column; }
  .save-summary > span { min-width: 0; text-align: left; }
}
