:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --ink: #1b2320;
  --muted: #66716d;
  --line: #dfe5df;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --amber: #b7791f;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 16px 50px rgba(24, 33, 30, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #17201d;
  color: #edf6f2;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.app-shell.sidebar-collapsed .sidebar {
  align-items: center;
  padding: 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #29413a;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #a9bbb5;
  font-size: 13px;
}

.sidebar-toggle {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.app-shell.sidebar-collapsed .brand {
  flex-direction: column;
  justify-content: center;
}

.app-shell.sidebar-collapsed .brand-copy,
.app-shell.sidebar-collapsed .sidebar-options {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  margin-left: 0;
}

.sidebar-options {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  min-height: 0;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-nav a {
  color: #c9d8d3;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.side-nav a.active,
.side-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sync-box {
  margin-top: auto;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #c7d6d1;
  font-size: 13px;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--amber);
}

.sync-dot.online {
  background: #22c55e;
}

.main {
  min-width: 0;
}

.workspace {
  padding: 24px;
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1,
.topbar p,
.section-heading h2,
.form-heading h2,
.auth-card h1,
.auth-card p {
  margin: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.15;
}

.topbar p {
  margin-top: 5px;
  color: var(--muted);
}

.topbar-actions,
.auth-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  border: 0;
  min-height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.primary-btn {
  padding: 0 14px;
  color: #ffffff;
  background: var(--teal);
  font-weight: 700;
}

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

.ghost-btn {
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
}

.ghost-btn:hover {
  border-color: #bcc9c1;
}

.icon-btn {
  width: 36px;
  background: #eef3ef;
  color: var(--muted);
}

.btn-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 800;
}

.wide {
  width: 100%;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card,
.inventory-panel,
.form-panel,
.production-panel,
.movements-panel,
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 96px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
}

.kpi-card strong {
  font-size: 26px;
  line-height: 1.1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.inventory-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 160px;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-field,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.search-field input {
  border: 0;
  background: transparent;
  width: 100%;
  min-width: 0;
  outline: 0;
}

.search-field span {
  color: var(--muted);
  padding-left: 11px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--ink);
  outline-color: var(--teal);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.product-name {
  font-weight: 750;
}

.muted {
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef3ef;
  color: #32413c;
}

.chip.pet {
  background: #dcfce7;
  color: #166534;
}

.chip.videogame {
  background: #dbeafe;
  color: #1d4ed8;
}

.chip.anime {
  background: #fee2e2;
  color: #991b1b;
}

.chip.producao,
.chip.decoracao {
  background: #fef3c7;
  color: #92400e;
}

.chip.baixo {
  background: #ffe4e6;
  color: #be123c;
}

.chip.pronto,
.chip.utilidade {
  background: #ccfbf1;
  color: #0f766e;
}

.actions-cell {
  width: 72px;
}

.action-trigger {
  width: 38px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.action-trigger:hover,
.action-trigger[aria-expanded="true"] {
  border-color: #b8c5be;
  background: #eef3ef;
}

.action-menu {
  position: fixed;
  z-index: 30;
  min-width: 212px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 46px rgba(24, 33, 30, 0.16);
}

.action-menu button {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 650;
}

.action-menu button:hover {
  background: #eef3ef;
}

.action-menu .danger-action {
  color: var(--red);
}

.form-panel {
  padding: 16px;
  position: sticky;
  top: 18px;
}

.form-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.form-heading h2,
.section-heading h2 {
  font-size: 18px;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #34413d;
  font-size: 13px;
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.production-panel,
.movements-panel {
  padding: 16px;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.production-list,
.movement-list {
  display: grid;
  gap: 8px;
}

.production-item,
.movement-item {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.production-item strong,
.movement-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.movement-meta {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #c7d0c9;
  border-radius: 8px;
}

.auth-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 22px;
}

.auth-card h1 {
  font-size: 24px;
}

.auth-card p {
  margin-top: 6px;
  margin-bottom: 18px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17201d;
  color: #ffffff;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 1120px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .app-shell.sidebar-collapsed .sidebar {
    align-items: center;
    padding: 14px 16px;
  }

  .app-shell.sidebar-collapsed .brand {
    flex-direction: row;
    justify-content: flex-start;
  }

  .app-shell.sidebar-collapsed .brand-copy {
    display: block;
  }

  .side-nav {
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .sidebar-options {
    width: 100%;
    flex: none;
  }

  .sync-box {
    margin-top: 0;
    margin-left: auto;
  }

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

  .form-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 14px;
  }

  .topbar,
  .sidebar {
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions > button {
    flex: 1;
  }

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

  .panel-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .kpi-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 14px;
  }

  .side-nav {
    width: 100%;
  }

  .sync-box {
    width: 100%;
    margin-left: 0;
  }
}
