:root {
  color-scheme: light;
  --bg: #f4f1e9;
  --surface: #fffdf8;
  --surface-strong: #efe7d8;
  --ink: #221f18;
  --muted: #70695d;
  --line: rgba(34, 31, 24, 0.13);
  --line-strong: rgba(142, 41, 29, 0.4);
  --brand: #8e291d;
  --brand-2: #d3a43a;
  --ok: #2f7d4f;
  --warn: #a66b00;
  --bad: #a33a2a;
  --radius: 8px;
  --shadow: 0 18px 70px rgba(55, 42, 24, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 241, 233, 0.94);
  backdrop-filter: blur(12px);
}

.brand,
.topbar-actions,
.asset-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff7e8;
  font-weight: 900;
}

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

.brand span,
.eyebrow,
.toolbar span,
.asset-meta,
.detail-muted {
  color: var(--muted);
}

.brand strong {
  line-height: 1.05;
}

.brand span {
  margin-top: 2px;
  font-size: 0.84rem;
  font-weight: 700;
}

.primary-button,
.ghost-button,
.status-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 850;
}

.primary-button {
  background: var(--brand);
  color: #fffaf0;
}

.ghost-button,
.status-button {
  background: rgba(255, 255, 255, 0.56);
  border-color: var(--line);
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
  gap: 14px;
  padding: 14px;
}

.library-panel,
.detail-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.library-panel {
  padding: 16px;
}

.detail-panel {
  position: sticky;
  top: 86px;
  align-self: start;
  overflow: hidden;
}

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1.02;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 8px;
  min-width: 410px;
}

.stat-card {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #faf4e9;
}

.stat-card span,
.stat-card strong {
  display: block;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.stat-card strong {
  margin-top: 6px;
  font-size: 1.5rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) repeat(3, minmax(150px, 190px));
  gap: 10px;
  margin-bottom: 10px;
}

.library-workbench {
  display: grid;
  grid-template-columns: minmax(240px, 290px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.tree-panel {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
}

.tree-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.96);
  backdrop-filter: blur(10px);
}

.tree-heading strong {
  display: block;
  font-size: 1rem;
}

.tree-list {
  display: grid;
  gap: 2px;
  padding: 8px;
}

.tree-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 8px 0 calc(8px + (var(--depth) * 15px));
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.tree-item:hover {
  background: rgba(34, 31, 24, 0.05);
}

.tree-item.active {
  border-color: rgba(142, 41, 29, 0.24);
  background: rgba(142, 41, 29, 0.09);
}

.tree-caret {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 850;
}

.tree-item b {
  min-width: 26px;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(34, 31, 24, 0.07);
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.folder-context {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #faf4e9;
}

.folder-context h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.folder-context span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.folder-context strong {
  white-space: nowrap;
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--brand);
  color: #fffaf0;
  font-size: 0.86rem;
}

.remote-panel {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.auth-box,
.upload-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fffaf0;
}

.auth-box strong,
.auth-box span {
  display: block;
}

.auth-box span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.auth-actions,
.upload-fields {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-actions input {
  width: min(300px, 45vw);
}

.hidden {
  display: none !important;
}

.upload-box.disabled {
  opacity: 0.58;
  pointer-events: none;
}

.drop-zone {
  min-height: 94px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px dashed rgba(142, 41, 29, 0.34);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(211, 164, 58, 0.1);
}

.drop-zone.dragging {
  border-color: var(--brand);
  background: rgba(142, 41, 29, 0.08);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone span {
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.drop-zone strong {
  font-size: 0.98rem;
}

.toolbar label {
  min-width: 0;
}

.toolbar span {
  display: block;
  margin: 0 0 5px;
  font-size: 0.76rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--line-strong);
  outline: 3px solid rgba(142, 41, 29, 0.15);
  outline-offset: 2px;
}

.result-line {
  min-height: 28px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.asset-card {
  display: grid;
  grid-template-rows: 150px auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  text-align: left;
  color: inherit;
}

.asset-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(142, 41, 29, 0.13);
}

.asset-card img,
.preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.missing-image {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 18px;
  background: var(--surface-strong);
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.asset-body {
  padding: 10px;
}

.asset-title {
  display: -webkit-box;
  overflow: hidden;
  min-height: 41px;
  margin: 0 0 6px;
  font-size: 0.98rem;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.asset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: rgba(34, 31, 24, 0.07);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.pill.status-aprovada {
  background: rgba(47, 125, 79, 0.13);
  color: var(--ok);
}

.pill.status-precisa_refazer,
.pill.status-sem_foto {
  background: rgba(166, 107, 0, 0.14);
  color: var(--warn);
}

.pill.status-rejeitada {
  background: rgba(163, 58, 42, 0.13);
  color: var(--bad);
}

.preview-box {
  height: 310px;
  background: var(--surface-strong);
}

.detail-content {
  padding: 14px;
}

.detail-content h2 {
  margin: 0 0 8px;
  font-size: 1.55rem;
  line-height: 1.12;
}

.detail-muted {
  margin-bottom: 12px;
  font-weight: 750;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.detail-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fffaf0;
}

.detail-box span,
.detail-box strong {
  display: block;
}

.detail-box span {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 850;
}

.detail-box strong {
  margin-top: 4px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.review-form {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.asset-actions {
  flex-wrap: wrap;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--muted);
  background: #fffaf0;
  font-weight: 800;
  text-align: center;
}

@media (max-width: 1050px) {
  .workspace,
  .hero-row,
  .library-workbench {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

  .tree-panel {
    position: static;
    max-height: none;
  }

  .tree-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(190px, max-content);
    overflow-x: auto;
  }

  .tree-item {
    padding-left: 8px;
  }

  .stats-grid {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .topbar,
  .topbar-actions,
  .auth-box,
  .upload-box,
  .auth-actions,
  .upload-fields {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-box,
  .upload-box {
    display: flex;
  }

  .auth-actions input {
    width: 100%;
  }

  .workspace {
    padding: 10px;
  }

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

  .folder-context {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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