:root {
  color-scheme: light;
  --bg: #f6f1e9;
  --bg-deep: #efe3d2;
  --card: #fffaf2;
  --ink: #231b14;
  --muted: #6d6257;
  --accent: #c2702a;
  --accent-2: #2f6f63;
  --accent-3: #b34f2a;
  --border: #e2d3c2;
  --danger: #cb4a2d;
  --ok: #2f7a63;
  --shadow: 0 24px 48px rgba(35, 23, 14, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, #fbf4ea 0%, #f6ecdd 38%, #efe0cf 100%),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.3) 0px,
      rgba(255, 255, 255, 0.3) 12px,
      transparent 12px,
      transparent 24px
    );
  color: var(--ink);
  min-height: 100vh;
}

body.no-scroll {
  overflow: hidden;
}

h1,
h2,
h3 {
  font-family: "Fraunces", "Georgia", serif;
  margin: 0 0 0.4rem 0;
}

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

input,
select,
button {
  font-family: inherit;
}

.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.25;
}

.orb--one {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, #f3b77e 0%, transparent 65%);
  top: -120px;
  left: -60px;
}

.orb--two {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, #7ec4b0 0%, transparent 60%);
  bottom: -180px;
  right: -140px;
}

.orb--three {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, #f5d1a9 0%, transparent 65%);
  top: 35%;
  right: 12%;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 90px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--accent-2);
  margin-bottom: 10px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}

.brand h1 {
  font-size: clamp(2rem, 3vw, 3rem);
}

.top-actions {
  position: relative;
}

.gear-button {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gear-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(56, 35, 20, 0.18);
}

.gear-button:focus-visible {
  outline: 2px solid rgba(194, 112, 42, 0.5);
  outline-offset: 2px;
}

.gear-icon {
  width: 20px;
  height: 20px;
  fill: #3a2a1b;
}

.gear-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-width: 180px;
  display: grid;
  gap: 4px;
  padding: 8px;
  z-index: 10;
}

.gear-menu button {
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.gear-menu button:hover {
  background: rgba(194, 112, 42, 0.12);
}

.menu-icon {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--accent-3);
}

.search-panel {
  background: rgba(255, 250, 242, 0.9);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.search-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  background: #fffdf9;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 14px;
}

.search-icon {
  font-size: 1.1rem;
}

.search-bar input {
  border: none;
  background: transparent;
  font-size: 1rem;
  outline: none;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.qty-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffdf9;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
}

.qty-field label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.qty-field input {
  width: 70px;
  border: none;
  background: transparent;
  text-align: center;
}

.search-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.table-panel {
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.table-header,
.table-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) 1fr 0.9fr 0.6fr 0.6fr;
  gap: 12px;
  align-items: center;
}

.table-header {
  padding: 8px 12px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.table-body {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.table-row {
  padding: 10px 12px;
  border-radius: 12px;
  background: #fffdf9;
  border: 1px solid transparent;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.table-row:hover {
  border-color: rgba(194, 112, 42, 0.4);
  box-shadow: 0 12px 28px rgba(194, 112, 42, 0.12);
}

.table-row.selected {
  border-color: rgba(47, 122, 99, 0.5);
  box-shadow: 0 12px 28px rgba(47, 122, 99, 0.16);
}

.table-row.low {
  border-color: rgba(203, 74, 45, 0.4);
  box-shadow: 0 12px 28px rgba(203, 74, 45, 0.12);
}

.table-row.create-row {
  border-style: dashed;
  border-color: rgba(47, 122, 99, 0.4);
}

.item-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background-image: var(--photo-url), linear-gradient(135deg, #f4d1a7, #f9ead9);
  background-size: cover;
  background-position: center;
  position: relative;
  font-size: 1.1rem;
}

.item-avatar::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px dashed rgba(35, 27, 20, 0.2);
  bottom: -4px;
  right: -4px;
  background: rgba(255, 255, 255, 0.6);
}

.item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.item-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.cell-muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.status-tag {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(47, 122, 99, 0.12);
  color: var(--ok);
}

.status-tag.low {
  background: rgba(203, 74, 45, 0.12);
  color: var(--danger);
}

.empty-state {
  padding: 18px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  background: #efe5d6;
  color: var(--ink);
  font-weight: 600;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.secondary {
  background: var(--accent-2);
  color: #fff;
}

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

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

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 10, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}

.overlay[hidden] {
  display: none;
}

.detail-panel,
.status-panel,
.login-panel {
  width: min(1100px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel {
  max-width: 520px;
}

.detail-header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.detail-body {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.detail-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #fffdf9;
  display: grid;
  gap: 12px;
}

.detail-avatar {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background-image: var(--photo-url), linear-gradient(135deg, #f4d1a7, #f9ead9);
  background-size: cover;
  background-position: center;
}

.detail-fields {
  display: grid;
  gap: 10px;
}

.detail-fields label,
.login-form label {
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.detail-fields label span,
.login-form label span {
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.detail-fields input,
.detail-fields select,
.login-form input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.detail-actions input {
  width: 90px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  text-align: center;
}

.status-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.status-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #fffdf9;
  display: grid;
  gap: 6px;
}

.status-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--muted);
}

.status-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.status-hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.log-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

.log-type {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
  color: var(--accent-3);
}

.login-form {
  display: grid;
  gap: 16px;
}

.google-signin {
  display: flex;
  justify-content: center;
}

body.login-only .page,
body.login-only .ambient {
  display: none;
}

body.login-only .overlay {
  background: #f7f1e7;
}

body.login-only .login-panel {
  max-width: 420px;
  border-radius: 18px;
  box-shadow: none;
}

body.login-only .detail-header {
  margin-bottom: 12px;
}

html.dashboard-host .marketing {
  display: none;
}

html.marketing-host .page,
html.marketing-host .ambient {
  display: none;
}

html.marketing-host .marketing {
  display: grid;
}

.marketing {
  display: none;
  min-height: 100vh;
  padding: 10vh 8vw 12vh;
  background:
    radial-gradient(circle at 10% 10%, rgba(249, 214, 173, 0.6), transparent 55%),
    radial-gradient(circle at 90% 0%, rgba(233, 196, 140, 0.5), transparent 50%),
    linear-gradient(140deg, #f7f0e4 0%, #f3e0c6 45%, #efe6da 100%);
  color: #231c12;
}

.marketing-hero {
  max-width: 720px;
  display: grid;
  gap: 18px;
}

.marketing-kicker {
  font-family: "Fraunces", serif;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.78rem;
}

.marketing-hero h1 {
  font-size: clamp(2.6rem, 4vw, 4rem);
  line-height: 1.05;
  margin: 0;
}

.marketing-hero p {
  font-size: 1.1rem;
  margin: 0;
  color: rgba(35, 28, 18, 0.8);
}

.marketing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.marketing-grid {
  margin-top: 48px;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.marketing-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid rgba(35, 28, 18, 0.1);
  box-shadow: 0 18px 40px rgba(35, 28, 18, 0.12);
}

.marketing-card h2 {
  font-size: 1.1rem;
  margin: 0 0 8px;
}

.marketing-card p {
  margin: 0;
  color: rgba(35, 28, 18, 0.75);
  font-size: 0.95rem;
}

.mono {
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

[data-animate] {
  opacity: 0;
  transform: translateY(12px);
  animation: fade-up 0.7s ease forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-header,
  .table-row {
    grid-template-columns: minmax(180px, 2fr) 1fr 0.8fr 0.6fr 0.6fr;
  }
}

@media (max-width: 700px) {
  .page {
    padding: 32px 16px 70px;
  }

  .table-header {
    display: none;
  }

  .table-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .table-row > div {
    justify-content: space-between;
  }

  .table-row > div::before {
    content: attr(data-label);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.65rem;
    color: var(--muted);
  }
}
