:root {
  --background: #f6f8fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0b8de3;
  --primary-dark: #0a61b2;
  --navy: #111827;
  --green: #16a34a;
  --red: #ef4444;
  --purple: #7c3aed;
  --yellow-bg: #fff9db;
  --yellow-border: #fde68a;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
}

.auth-card {
  width: min(448px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.13);
  padding: 42px 40px 38px;
  text-align: center;
}

.auth-logo {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.16);
  margin-bottom: 26px;
}

.auth-card h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.14;
  letter-spacing: 0;
}

.auth-subtitle {
  margin: 14px 0 32px;
  color: var(--muted);
  font-weight: 650;
}

.google-button,
.primary-button,
.ghost-button,
.icon-button,
.danger-button {
  border: 0;
  border-radius: 12px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 750;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border 0.16s ease;
}

.google-button {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  color: #334155;
}

.google-mark {
  color: #4285f4;
  font-size: 19px;
  font-weight: 900;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 28px 0;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--border);
}

.field {
  text-align: left;
  margin-bottom: 20px;
}

.field label {
  display: block;
  text-align: center;
  color: #334155;
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 10px;
}

.input-wrap {
  position: relative;
}

.input-wrap span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.input-wrap input {
  padding-left: 42px;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 141, 227, 0.13);
}

.primary-button {
  width: 100%;
  background: #111827;
  color: #fff;
}

.primary-button.blue {
  background: var(--primary);
}

.danger-button {
  background: var(--red);
  color: #fff;
  padding: 0 18px;
}

.ghost-button {
  background: #fff;
  color: #334155;
  border: 1px solid var(--border);
  padding: 0 18px;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  color: #64748b;
  font-size: 14px;
  font-weight: 650;
}

.link-button {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font-weight: 750;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  background: #111827;
  color: #fff;
  padding: 13px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 14px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 256px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  flex-shrink: 0;
  z-index: 40;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
}

.brand img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 9px 20px rgba(15, 23, 42, 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.creator p,
.tip p {
  margin: 0;
}

.brand p {
  color: #bfdbfe;
  font-size: 12px;
}

.nav {
  padding: 8px 12px;
  display: grid;
  gap: 4px;
  align-content: start;
  flex: 1;
}

.nav a {
  color: #dbeafe;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  border-radius: 12px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 750;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.tip {
  margin: 0 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  padding: 14px;
}

.tip p:first-child,
.creator p:first-child {
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 750;
}

.tip p:last-child,
.creator p:last-child {
  color: #dbeafe;
  font-size: 12px;
  margin-top: 5px;
}

.creator {
  text-align: center;
  padding: 0 24px 20px;
}

.live-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  color: #dcfce7;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.live-count span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.account-box {
  margin: 0 12px 16px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
}

.account-box p {
  margin: 0 0 10px;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.account-box button {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 800;
}

.account-box button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.main-wrap {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.mobile-header,
.mobile-footer {
  display: none;
}

main {
  flex: 1;
  padding: 32px;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.page.narrow {
  max-width: 900px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.page-head h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.15;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.month-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 10px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  white-space: nowrap;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  background: transparent;
  color: #475569;
}

.icon-button:hover {
  background: #f1f5f9;
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stats-grid {
  display: grid;
  gap: 16px;
}

.stats-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card,
.panel,
.summary-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.stat-card {
  min-height: 124px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.stat-card p {
  margin: 0;
}

.stat-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  margin-top: 8px !important;
  font-size: 28px;
  font-weight: 850;
}

.stat-sub {
  margin-top: 6px !important;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-sub.good {
  color: var(--green);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  font-size: 20px;
}

.blue-bg { background: #0ea5e9; }
.green-bg { background: #22c55e; }
.red-bg { background: #ef4444; }
.purple-bg { background: #8b5cf6; }
.emerald-bg { background: #10b981; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--yellow-border);
  background: var(--yellow-bg);
  color: #854d0e;
  border-radius: 16px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.55;
}

.panel {
  overflow: hidden;
}

.panel-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  margin: 0;
  font-size: 14px;
}

.panel-header a {
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.form-panel {
  padding: 20px;
}

.form-grid {
  display: grid;
  gap: 12px;
  align-items: end;
}

.cash-form {
  grid-template-columns: 1.1fr 1fr 1fr 1.5fr 1fr;
}

.load-form {
  grid-template-columns: 1fr 1fr 1.5fr 1fr;
}

.form-grid label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.form-grid button {
  min-height: 48px;
}

.empty-state {
  text-align: center;
  padding: 42px 18px;
  color: var(--muted);
  font-size: 14px;
}

.recent-row,
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.72);
}

.recent-row:last-child,
.history-row:last-child {
  border-bottom: 0;
}

.row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.round-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.round-icon.in {
  color: var(--green);
  background: #dcfce7;
}

.round-icon.out {
  color: var(--red);
  background: #fee2e2;
}

.row-title {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.money {
  font-weight: 850;
  white-space: nowrap;
}

.money.good {
  color: var(--green);
}

.money.bad {
  color: var(--red);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.72);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.in {
  background: #dcfce7;
  color: #15803d;
}

.pill.out {
  background: #fee2e2;
  color: #b91c1c;
}

.pill.cash {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.load {
  background: #ede9fe;
  color: #6d28d9;
}

.delete-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
}

.delete-btn:hover {
  background: #fee2e2;
  color: var(--red);
}

.capital-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.capital-edit input {
  min-height: 28px;
  width: 110px;
  border-radius: 7px;
  font-size: 12px;
}

.capital-link {
  margin-top: 8px;
  background: transparent;
  border: 0;
  color: var(--primary);
  display: inline-flex;
  gap: 6px;
  padding: 0;
  font-size: 12px;
  font-weight: 800;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
}

.search {
  position: relative;
}

.search span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.search input {
  padding-left: 42px;
}

.summary-bar {
  display: flex;
  gap: 42px;
  flex-wrap: wrap;
  padding: 18px 20px;
}

.summary-bar p {
  margin: 0;
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.summary-value {
  margin-top: 4px !important;
  font-size: 20px;
  font-weight: 850;
}

.history-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

.history-group {
  display: grid;
  gap: 10px;
}

.history-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.modal-backdrop,
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  padding: 24px;
}

.modal h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.not-found {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.not-found h1 {
  margin: 0;
  color: #cbd5e1;
  font-size: 72px;
  font-weight: 300;
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    z-index: 35;
    display: block;
  }

  .mobile-header {
    display: block;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--card);
    border-bottom: 1px solid var(--border);
  }

  .mobile-header-main {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
  }

  .mobile-header img {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: cover;
  }

  .mobile-header h1 {
    margin: 0;
    font-size: 16px;
  }

  .mobile-credit {
    margin: -6px 0 8px;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
  }

  .mobile-footer {
    display: block;
    border-top: 1px solid var(--border);
    padding: 12px;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
  }

  main {
    padding: 22px 16px;
  }

  .stats-grid.three,
  .card-grid,
  .cash-form,
  .load-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .auth-card {
    padding: 34px 24px;
  }

  .page-head {
    flex-direction: column;
  }

  .stats-grid.three,
  .stats-grid.two,
  .card-grid,
  .cash-form,
  .load-form,
  .filters {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 23px;
  }

  th,
  td {
    padding: 12px;
  }

  .summary-bar {
    gap: 22px;
  }

  .auth-links {
    gap: 12px;
    flex-direction: column;
  }
}
