:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f6f7fb;
  color: #1f2937;
}

body {
  margin: 0;
  min-height: 100vh;
  display: block;
  padding: 1.5rem;
  background: radial-gradient(circle at top, #ffffff, #f6f7fb 55%, #f0f2f8 100%);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  color: #0f172a;
}

.note {
  margin: 0;
  font-size: 0.95rem;
  color: #64748b;
}

.status {
  display: none;
}

.form,
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 0.35rem;
}

input,
select {
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  font-size: 0.95rem;
  background: #fff;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%),
    linear-gradient(to right, #e2e8f0, #e2e8f0);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%, calc(100% - 2.5rem) 50%;
  background-size: 6px 6px, 6px 6px, 1px 1.6rem;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}

button {
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.primary-button {
  background: #4f46e5;
  color: #fff;
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.2);
}

.primary-button:hover {
  background: #4338ca;
}

.secondary-button {
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #e2e8f0;
}

.secondary-button:hover {
  background: #e2e8f0;
}

.secondary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
}

.sidebar-collapsed .app-shell {
  grid-template-columns: 80px 1fr;
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label {
  display: none;
}

.sidebar-collapsed .brand {
  justify-content: center;
}

.sidebar-collapsed .sidebar {
  padding: 1rem 0.75rem;
}

.sidebar-collapsed .nav-button {
  justify-content: center;
}

.sidebar-collapsed .nav-icon {
  margin: 0;
}

.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.logged-out {
  background:
    radial-gradient(circle at 20% 80%, rgba(79, 70, 229, 0.18), transparent 50%),
    radial-gradient(circle at 85% 15%, rgba(14, 165, 233, 0.12), transparent 40%),
    radial-gradient(circle at top, #ffffff, #f6f7fb 55%, #f0f2f8 100%);
  color: #1f2937;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.logged-out body {
  background: transparent;
}

.logged-out .app-shell {
  display: none;
}

.logged-in .login-screen {
  display: none;
}

.login-screen {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

@media (max-width: 600px) {
  body {
    padding: 1.5rem;
  }

  .login-content {
    padding: 2rem;
  }

  .login-content h1 {
    font-size: 2.2rem;
  }
}

.login-card {
  position: relative;
  width: min(520px, 100%);
  border-radius: 26px;
  padding: 1px;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 26px;
  padding: 1px;
  background: linear-gradient(140deg, rgba(79, 70, 229, 0.6), rgba(99, 102, 241, 0.15));
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.login-card .login-glow {
  position: absolute;
  inset: -20px;
  border-radius: 32px;
  background: radial-gradient(circle at top, rgba(99, 102, 241, 0.25), transparent 60%);
  filter: blur(24px);
  z-index: 0;
}

.login-content {
  position: relative;
  z-index: 1;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(18px);
  padding: 2.5rem;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.login-content h1 {
  font-size: 2.4rem;
  margin: 0 0 0.75rem;
  color: #0f172a;
}

.login-subtitle {
  margin: 0 0 2rem;
  font-size: 1rem;
  color: #64748b;
}

.login-form {
  display: grid;
  gap: 1.25rem;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 0 12px rgba(148, 163, 184, 0.15);
}

.input-row:focus-within {
  border-color: rgba(79, 70, 229, 0.5);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.input-icon svg {
  width: 20px;
  height: 20px;
  fill: #94a3b8;
}

.input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: #0f172a;
  font-size: 1rem;
  outline: none;
}

.input-row input::placeholder {
  color: #94a3b8;
}

.icon-toggle {
  border: none;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-toggle svg {
  width: 20px;
  height: 20px;
  fill: #94a3b8;
}

.icon-toggle:hover svg {
  fill: rgba(232, 245, 238, 0.9);
}

.eye-off {
  display: none;
}

.login-error {
  min-height: 1.2rem;
  color: #b91c1c;
  font-size: 0.95rem;
  display: none;
}

.login-button {
  height: 54px;
  border-radius: 999px;
  border: none;
  background: #4f46e5;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.3);
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.login-footnote {
  margin: 1.5rem 0 0;
  font-size: 0.85rem;
  color: #94a3b8;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  border: 1px solid #eef2f7;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  position: sticky;
  top: 1.5rem;
  height: fit-content;
  transition: width 0.25s ease;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #4f46e5;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
}

.sidebar-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f1f5f9;
  display: grid;
  place-items: center;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  fill: #475569;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-button {
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.nav-button.active {
  background: #eef2ff;
  color: #3730a3;
  border-color: #e0e7ff;
}

.nav-button.logout {
  margin-top: auto;
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fee2e2;
}

.content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 20px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.topbar-title h1 {
  font-size: 1.5rem;
}

.topbar-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: #64748b;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #475569;
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.view-section {
  margin-top: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06);
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.5rem;
  color: #0f172a;
}

.stat-wide {
  grid-column: span 2;
}

.settings-group {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 1px solid #eef2f7;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.settings-group h3 {
  margin-top: 0;
}

.settings-group .field {
  margin-bottom: 0.75rem;
}

.settings-group .primary-button {
  align-self: flex-start;
  padding: 0.7rem 1.6rem;
}

.form-message {
  min-height: 1rem;
  margin-top: 0.5rem;
  color: #475569;
  font-size: 0.9rem;
}

.tables-section {
  text-align: left;
}

.tables-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.history-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.export-menu {
  position: relative;
}

.export-menu-list {
  position: absolute;
  top: 110%;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 140px;
  z-index: 10;
}

.export-menu-list.open {
  display: flex;
}

.export-menu-list button {
  width: 100%;
  text-align: left;
  background: #f8fafc;
  color: #0f172a;
}

.export-menu-list button:hover {
  background: #e2e8f0;
}

.modal-confirm {
  max-width: 420px;
}

.field.compact {
  margin: 0;
}

.field.compact span {
  font-size: 0.85rem;
}

.tables-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.tables-list {
  display: grid;
  gap: 1rem;
}

.empty-state {
  padding: 1.25rem;
  border: 1px dashed #cbd5f5;
  border-radius: 16px;
  margin-bottom: 1rem;
  background: #f8fafc;
  color: #64748b;
}

.table-card {
  border: 1px solid #eef2f7;
  border-radius: 18px;
  padding: 1.25rem;
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.table-card.inactive {
  opacity: 0.75;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: #0f172a;
}

.table-details,
.table-live {
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: #475569;
}

.status-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-badge.running {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.status-badge.idle {
  background: #f1f5f9;
  color: #64748b;
}

.table-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}

.action-button {
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  border: none;
  background: #4f46e5;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.action-button:hover {
  background: #4338ca;
}

.action-button.secondary {
  background: #fee2e2;
  color: #b91c1c;
}

.action-button.secondary:hover {
  background: #fecaca;
}

.action-button:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  font-size: 1rem;
}

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

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 20px;
  padding: 1.75rem;
  width: min(460px, 100%);
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.2);
  border: 1px solid #eef2f7;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-header h3 {
  margin: 0;
}

.modal-header button {
  background: #f1f5f9;
  color: #64748b;
  font-size: 1.2rem;
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-error {
  min-height: 1rem;
  color: #8a2f1e;
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-actions button {
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  background: #4f46e5;
  color: #fff;
  font-weight: 600;
}

.danger-button {
  background: #ef4444;
  color: #fff;
}

.danger-button:hover {
  background: #dc2626;
}

.modal-summary {
  display: grid;
  gap: 0.5rem;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.history-table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 16px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.history-table th,
.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-active {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.status-deleted {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.amount-cell {
  font-weight: 700;
  color: #0f172a;
}

.history-table th {
  background: #f8fafc;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

@media (max-width: 900px) {
  body {
    padding: 1rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar-collapsed .brand-text,
  .sidebar-collapsed .nav-label {
    display: inline;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

code {
  background: #f1e4d5;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
}
