:root {
  --bg: #f4f8ff;
  --bg2: #eef4f4;
  --text: #11203b;
  --muted: #5c6e87;
  --brand: #00a88f;
  --brand-2: #0f7cff;
  --danger: #d54343;
  --card: rgba(255, 255, 255, 0.62);
  --card-border: rgba(255, 255, 255, 0.35);
  --shadow: 0 10px 35px rgba(10, 20, 40, 0.14);
  --radius: 16px;
}

body.dark {
  --bg: #101623;
  --bg2: #162133;
  --text: #eaf1ff;
  --muted: #abc0e3;
  --brand: #1ad1b4;
  --brand-2: #65abff;
  --danger: #ff7f7f;
  --card: rgba(20, 31, 48, 0.6);
  --card-border: rgba(120, 160, 220, 0.2);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", "Segoe UI", sans-serif;
  background: linear-gradient(135deg, var(--bg), var(--bg2));
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(10, 18, 30, 0.38);
  backdrop-filter: blur(6px);
}

.login-card {
  width: min(680px, 100%);
  padding: 18px;
}

.login-grid {
  margin-top: 12px;
}

.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      circle at 10% 10%,
      rgba(0, 168, 143, 0.18),
      transparent 32%
    ),
    radial-gradient(
      circle at 90% 80%,
      rgba(15, 124, 255, 0.18),
      transparent 34%
    );
  z-index: -1;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
}
p {
  margin: 0;
}

.glass {
  backdrop-filter: blur(14px);
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
}

.brand-wrap {
  display: grid;
  grid-template-columns: 44px 1fr;
  column-gap: 10px;
  align-items: center;
}

.brand-logo {
  grid-row: span 2;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(10, 20, 40, 0.25);
}

.subtitle {
  color: var(--muted);
  font-size: 0.92rem;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.inline-control select,
.currency-custom {
  min-width: 82px;
  padding: 8px;
}

.hidden {
  display: none !important;
}

.layout {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
}

.side-nav {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: fit-content;
  position: sticky;
  top: 12px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(
    120deg,
    rgba(0, 168, 143, 0.2),
    rgba(15, 124, 255, 0.2)
  );
  transform: translateX(3px);
}

.content {
  display: grid;
  gap: 14px;
}

.panel {
  display: none;
  padding: 16px;
  animation: fade-up 0.35s ease;
}

.panel.active {
  display: block;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.87rem;
  color: var(--muted);
}

input,
select {
  border: 1px solid rgba(60, 90, 140, 0.2);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.65);
  color: #0f1f3b;
}

body.dark input,
body.dark select {
  background: rgba(10, 18, 32, 0.8);
  color: #e7f0ff;
}

.form-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  cursor: pointer;
}

.btn.subtle {
  background: rgba(110, 140, 180, 0.2);
  color: var(--text);
}

#logoutBtn,
#logoutBtnSettings {
  background: rgba(213, 67, 67, 0.2);
  color: var(--text);
}

.stats-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  padding: 12px;
}

body.dark .stat-card {
  background: rgba(14, 24, 41, 0.72);
}

.stat-card p {
  font-size: 1.2rem;
  font-weight: 600;
}

.table-wrap {
  margin-top: 14px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid rgba(130, 150, 180, 0.26);
  padding: 10px;
  text-align: left;
  font-size: 0.88rem;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 6px;
}

.actions button {
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}

.actions .edit {
  background: rgba(15, 124, 255, 0.2);
}
.actions .delete {
  background: rgba(213, 67, 67, 0.2);
}

.sync-badge {
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 0.84rem;
}

.sync-badge.idle {
  background: rgba(120, 140, 170, 0.2);
}
.sync-badge.syncing {
  background: rgba(15, 124, 255, 0.2);
}
.sync-badge.synced {
  background: rgba(0, 168, 143, 0.2);
}
.sync-badge.error {
  background: rgba(213, 67, 67, 0.2);
}

.filters-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.analytics {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.charts-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.chart-card {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 12px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.trend-toggle {
  display: inline-flex;
  gap: 6px;
}

.trend-btn {
  padding: 7px 10px;
  font-size: 0.84rem;
}

.trend-btn.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}

body.dark .chart-card {
  background: rgba(14, 24, 41, 0.72);
}

canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.36);
}

.settings-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-upload input {
  display: none;
}

.meta-info {
  margin-top: 12px;
  color: var(--muted);
}

.toast-container {
  position: fixed;
  right: 12px;
  bottom: 86px;
  display: grid;
  gap: 8px;
  z-index: 30;
}

.toast {
  background: rgba(16, 28, 50, 0.92);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 200px;
  box-shadow: var(--shadow);
  animation: slide-in 0.25s ease;
}

@keyframes slide-in {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.bottom-nav {
  display: none;
}

@media (max-width: 980px) {
  body {
    padding: 10px;
    padding-bottom: 90px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    display: none;
  }

  .bottom-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 6px;
    z-index: 20;
  }

  .bottom-nav .nav-item {
    text-align: center;
    font-size: 0.8rem;
    padding: 9px 4px;
  }
}

@media print {
  .side-nav,
  .bottom-nav,
  .top-actions,
  .filters-row,
  .settings-actions,
  .form-grid,
  .actions,
  .toast-container {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .panel {
    display: block !important;
    box-shadow: none;
    border: none;
    background: #fff;
  }
}
