@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Manrope:wght@400;600;700&display=swap");

:root {
  --bg-gradient: radial-gradient(circle at 18% 18%, #1d3a30 0, #162f27 35%, #10251f 68%, #0d201a 100%);
  --panel: #f7f2e9;
  --panel-strong: #fbf7f0;
  --panel-muted: #efe8dd;
  --panel-border: rgba(214, 206, 196, 0.8);
  --emerald-100: #e3efe7;
  --emerald-200: #c0d7c9;
  --emerald-400: #63b487;
  --emerald-500: #2f7c54;
  --emerald-600: #276746;
  --emerald-700: #1b5b3d;
  --text: #1e2a23;
  --text-soft: #56645c;
  --link: #245c3d;
  --shadow: 0 22px 40px -28px rgba(8, 20, 14, 0.6);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --border-soft: #d7cfc3;
  --font-sans: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Fraunces", "Times New Roman", serif;
}

body {
  background: var(--bg-gradient);
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

h1, h2, h3, .brand {
  font-family: var(--font-display);
  letter-spacing: 0.2px;
}

input,
select,
textarea,
button {
  font-family: var(--font-sans);
}

.background-filter {
  background-image: var(--bg-gradient);
  filter: none;
}

.background-filter::after {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(90deg, rgba(12, 26, 21, 0.95), rgba(14, 30, 24, 0.85));
  color: #f2f2f0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 24px rgba(7, 14, 12, 0.35);
}

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

.brand {
  font-weight: 700;
  letter-spacing: 0.4px;
}

.menu-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 52px);
}

.sidebar {
  background: linear-gradient(180deg, rgba(16, 34, 28, 0.95), rgba(12, 26, 22, 0.98));
  color: #d9e4dd;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(4px);
  overflow-y: auto;
  max-height: calc(100vh - 52px);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-overlay {
  display: none;
}

.sidebar-title {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1.6px;
  opacity: 0.8;
  margin-bottom: 6px;
}

.nav-link {
  padding: 12px 14px;
  border-radius: 12px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  font-weight: 600;
  color: #dbe4dc;
  display: block;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(2px);
}

.nav-link.active {
  background: linear-gradient(90deg, #7fa381, #9ebc9d);
  color: #0e1e18;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.logout-link {
  background: transparent;
  color: #f5d565;
  font-weight: 700;
}

.logout-link:hover {
  color: #ffe68a;
  text-decoration: underline;
}

.content {
  padding: 24px;
  background: transparent;
}

.content-inner {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.2)), var(--panel-muted);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  min-height: calc(100vh - 52px - 48px);
  border: 1px solid rgba(120, 110, 96, 0.12);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.btn-secondary {
  background: linear-gradient(90deg, #7f8f7c, #5e6a5d);
  color: #fff;
}

.btn-link {
  background: transparent;
  color: #f2f2f0;
  padding: 8px 10px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 52px;
    bottom: 0;
    width: 240px;
    transition: left 0.2s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
    z-index: 95;
  }

  .sidebar.open {
    left: 0;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .content {
    padding: 14px;
  }

  .content-inner {
    border-radius: 18px;
    padding: 16px;
    min-height: auto;
  }

  .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 90;
  }

  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }

  .brand {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-info .user-name {
    display: none;
  }
}

/* Typography alignment across pages */
h1 {
  font-size: 22px;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
}

.page-header-card h1,
.page-header h1 {
  font-size: 22px;
}

.page-header-card p,
.page-header p,
.subtitle {
  font-size: 13px;
}

.card h2,
.section-heading h2 {
  font-size: 14px;
}

.report-table th,
.report-table td,
.data-table th,
.data-table td {
  font-size: 13px;
}

.form-grid label,
.line-row label {
  font-size: 13px;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
input,
select,
textarea {
  font-size: 13px;
}

/* Dashboard alignment tweaks to match the MMM layout density */
body.dashboard-body {
  font-size: 14px;
}

.dashboard-body .content-inner {
  background: #e9e3d9;
}

.dashboard-body .hero-card {
  max-width: none;
  padding: 18px 20px;
  background: #f4efe7;
  border: 1px solid #d9d2c9;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.12);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  align-items: start;
}

.dashboard-body .hero-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.dashboard-body .hero-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

.dashboard-body .hero-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  justify-self: end;
  gap: 10px;
}

.dashboard-grid {
  gap: 12px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 140px;
  gap: 16px;
  grid-auto-flow: dense;
}

.dashboard-layout .card {
  grid-column: span var(--col-span, 1);
  grid-row: span var(--row-span, 1);
  position: relative;
  touch-action: none;
  overflow: hidden;
}

.dashboard-layout .card.is-dragging {
  z-index: 10;
  opacity: 0.85;
  cursor: grabbing;
}

.dashboard-layout .resize-handle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 14px;
  height: 14px;
  border-right: 2px solid rgba(36, 92, 61, 0.6);
  border-bottom: 2px solid rgba(36, 92, 61, 0.6);
  cursor: se-resize;
  opacity: 0.65;
}

.dashboard-layout .card:hover .resize-handle {
  opacity: 1;
}

@media (min-width: 1200px) {
  .dashboard-layout {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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

@media (max-width: 720px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
}

.dashboard-body .card {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d9d2c9;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.12);
}

.dashboard-body .card h2 {
  font-size: 14px;
}

.dashboard-body .chart-card {
  min-height: 240px;
}

.dashboard-body .chart-card .chart-card__header {
  margin-bottom: 6px;
}

.dashboard-body .chart-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.dashboard-body .chart-canvas-wrap.pie {
  max-width: 320px;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.dashboard-body .chart-canvas-wrap.pie canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.dashboard-body .chart-canvas-wrap.bar {
  width: 100%;
  height: 220px;
}

.dashboard-body .chart-canvas-wrap.bar canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.dashboard-body .stat-chip {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(111, 141, 115, 0.18);
  color: #1f3b2c;
}

.dashboard-body .stat-chip strong {
  font-size: 16px;
}

.dashboard-body .primary-button,
.dashboard-body .secondary-button {
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
}

.dashboard-body .secondary-button {
  border-color: rgba(123, 138, 123, 0.6);
}

.dashboard-body .table-wrapper {
  border-radius: 12px;
  border: 1px solid #d9d2c9;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.dashboard-body .report-table thead {
  background: #96b28d;
}

.dashboard-body .report-table th {
  color: #0f2d1f;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
}

.dashboard-body .report-table td {
  font-size: 13px;
  padding: 10px 12px;
}

@media (max-width: 900px) {
  .dashboard-body .hero-card {
    grid-template-columns: 1fr;
  }

  .dashboard-body .hero-actions {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
  }
}
