:root {
  --bg: #f7f2ea;
  --bg-strong: #efe3d3;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(105, 79, 58, 0.15);
  --text: #2b2018;
  --muted: #6d5a4b;
  --accent: #c05f2c;
  --accent-strong: #93431c;
  --danger: #b33a2f;
  --success: #2f7a55;
  --shadow: 0 16px 40px rgba(80, 52, 34, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-main: "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 30%),
    linear-gradient(145deg, #f7f2ea, #f0dfca 60%, #ead2bc);
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(93, 67, 45, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  padding: 0.85rem 1rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(192, 95, 44, 0.2);
  border-color: var(--accent);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  border-radius: 999px;
  padding: 0.8rem 1.1rem;
  font-weight: 600;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.secondary-btn {
  background: rgba(192, 95, 44, 0.12);
  color: var(--accent-strong);
}

.ghost-btn,
.icon-btn {
  background: rgba(105, 79, 58, 0.08);
  color: var(--text);
}

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

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  color: var(--accent-strong);
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 1rem;
  top: 1rem;
  max-width: 360px;
  padding: 1rem 1.1rem;
  border-radius: 16px;
  background: rgba(43, 32, 24, 0.95);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 1000;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card,
.panel,
.hero-panel {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(100%, 460px);
  padding: 2rem;
  border-radius: 32px;
}

.login-card h1 {
  margin-bottom: 0.75rem;
}

.login-copy {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.stack-form,
.settings-form,
.product-form {
  display: grid;
  gap: 1rem;
}

.app-shell {
  display: grid;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  background: rgba(46, 30, 22, 0.96);
  color: #fff;
  padding: 1.2rem;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 50;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding-bottom: 1.5rem;
}

.sidebar-brand p {
  margin: 0.2rem 0 0;
  color: rgba(255, 255, 255, 0.7);
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #d4854d, #8b401c);
  font-weight: 800;
}

.nav-links {
  display: grid;
  gap: 0.65rem;
}

.nav-link {
  text-align: left;
  border-radius: 14px;
  padding: 0.95rem 1rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
}

.nav-link.active,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.content-shell {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  background: rgba(247, 242, 234, 0.7);
}

.topbar h2 {
  margin: 0.15rem 0 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.page-content {
  padding: 0 1rem 2rem;
}

.page-section {
  display: grid;
  gap: 1rem;
}

.hero-panel,
.panel {
  border-radius: var(--radius-lg);
}

.hero-panel {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.products-hero,
.toolbar,
.bulk-bar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dashboard-grid,
.split-grid,
.products-cards,
.category-list {
  display: grid;
  gap: 1rem;
}

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

.kpi-card {
  padding: 1.1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(240, 223, 202, 0.65));
  border: 1px solid rgba(105, 79, 58, 0.12);
}

.kpi-card strong {
  font-size: 1.8rem;
  display: block;
  margin: 0.6rem 0 0.2rem;
}

.split-grid {
  grid-template-columns: 1fr;
}

.panel {
  padding: 1rem;
}

.alert-list,
.category-list {
  margin-top: 0.75rem;
}

.alert-item,
.category-chip,
.product-card {
  border-radius: 16px;
  border: 1px solid rgba(105, 79, 58, 0.12);
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1rem;
  background: rgba(255, 255, 255, 0.8);
}

.category-list {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.category-chip {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.8);
}

.filters-bar,
.form-panel {
  display: grid;
  gap: 1rem;
}

.filters-bar {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.file-input {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(105, 79, 58, 0.08);
  color: var(--text);
  padding: 0.8rem 1rem;
  font-weight: 600;
}

.file-input input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.bulk-bar {
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  margin-bottom: 1rem;
  background: rgba(192, 95, 44, 0.09);
}

.table-wrap {
  overflow-x: auto;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.products-table th,
.products-table td {
  text-align: left;
  padding: 0.9rem 0.75rem;
  border-bottom: 1px solid rgba(105, 79, 58, 0.1);
  vertical-align: top;
}

.products-table th {
  color: var(--muted);
  font-size: 0.85rem;
}

.status-pill,
.stock-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-ativo {
  background: rgba(47, 122, 85, 0.14);
  color: var(--success);
}

.status-inativo {
  background: rgba(109, 90, 75, 0.14);
  color: var(--muted);
}

.stock-normal {
  background: rgba(47, 122, 85, 0.14);
  color: var(--success);
}

.stock-baixo,
.stock-zerado {
  background: rgba(179, 58, 47, 0.14);
  color: var(--danger);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.products-cards {
  display: none;
  margin-top: 1rem;
}

.product-card {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.85);
  display: grid;
  gap: 0.75rem;
}

.product-card header,
.product-card .meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.product-form,
.settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-span {
  grid-column: 1 / -1;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.check-field input {
  width: auto;
}

@media (min-width: 980px) {
  .app-shell {
    grid-template-columns: 280px 1fr;
  }

  .sidebar {
    transform: translateX(0);
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .content-shell {
    min-width: 0;
  }

  .page-content,
  .topbar {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .split-grid {
    grid-template-columns: 1.35fr 1fr;
  }

  #menuToggle {
    display: none;
  }
}

@media (max-width: 979px) {
  .topbar-actions span {
    display: none;
  }
}

@media (max-width: 720px) {
  .hero-panel,
  .products-hero,
  .toolbar,
  .bulk-bar,
  .panel-head,
  .product-card header,
  .product-card .meta-line {
    flex-direction: column;
    align-items: stretch;
  }

  .product-form,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .products-table {
    display: none;
  }

  .products-cards {
    display: grid;
  }
}
