:root {
  --bg: #f7f4ee;
  --bg-alt: #efe6d8;
  --text: #2c241f;
  --card: #fff9ef;
  --primary: #db5a2b;
  --primary-dark: #aa3916;
  --line: #d8cdbb;
  --success: #2e7d32;
  --error: #b71c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 15% 10%, var(--bg-alt), transparent 40%), var(--bg);
  color: var(--text);
  font-family: "Manrope", sans-serif;
  min-height: 100vh;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(135deg, rgba(219, 90, 43, 0.04) 25%, transparent 25%),
    linear-gradient(225deg, rgba(219, 90, 43, 0.04) 25%, transparent 25%);
  background-size: 40px 40px;
  z-index: -1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 249, 239, 0.95);
  position: sticky;
  top: 0;
  backdrop-filter: blur(5px);
}

.brand {
  font-family: "DM Serif Display", serif;
  text-decoration: none;
  color: var(--text);
  font-size: 1.3rem;
}

.navlinks {
  display: flex;
  gap: 0.75rem;
}

.navlinks a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.05);
}

.hero {
  animation: rise 0.5s ease both;
}

.metric h2 {
  margin: 0;
  color: var(--primary);
  font-size: 2rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.cards-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.inline-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 0.5rem;
}

input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font-size: 1rem;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  text-align: left;
  vertical-align: top;
}

.alerts {
  display: grid;
  gap: 0.5rem;
}

.alert {
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  color: #fff;
}

.alert.success {
  background: var(--success);
}

.alert.error {
  background: var(--error);
}

.chart-wrap {
  position: relative;
  height: 280px;
}

#priceChart {
  width: 100% !important;
  height: 100% !important;
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .cards-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-wrap: wrap;
    gap: 0.6rem;
  }
}

@media (max-width: 640px) {
  .cards-4 {
    grid-template-columns: 1fr;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 0.8rem;
    padding: 0.5rem;
  }

  td {
    border: none;
    padding: 0.3rem 0.4rem;
  }
}
