/* ROOT-01 */
:root {
  --codam-app: #f7f9fb;
  --codam-berry: #eef3f7;
  --codam-surface: #ffffff;
  --codam-blue: #00486b;
  --codam-blue-soft: #e0f2f7;
  --codam-text: #101828;
  --codam-muted: #667085;
  --codam-border: #cdd5df;
  --codam-divider: #d5dce5;
  --ml: #ffe600;
  --shopee: #ee4d2d;
  --radius-panel: 8px;
  --radius-control: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--codam-app);
  color: var(--codam-text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.875rem;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* TYPE-01 */
h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 1.5rem, 1.65rem);
  font-weight: 800;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  font-weight: 750;
}

p {
  color: var(--codam-muted);
  font-size: 0.875rem;
}

/* LAY-01, MENU-01 */
.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--codam-berry);
  border-right: 1px solid var(--codam-border);
  color: #344054;
  min-height: 100vh;
  padding: 14px 12px;
  position: sticky;
  top: 0;
}

.sidebar.is-collapsed {
  width: 86px;
}

.sidebar.is-collapsed .nav-title,
.sidebar.is-collapsed .nav-item span:not(.nav-icon),
.sidebar.is-collapsed .nav-sub,
.sidebar.is-collapsed .marketplace-tree,
.sidebar.is-collapsed .codam-logo small {
  display: none;
}

.sidebar-top {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.codam-logo {
  display: grid;
  gap: 2px;
  line-height: 1;
}

.codam-logo span {
  color: var(--codam-blue);
  font-size: 1.18rem;
  font-weight: 900;
}

.codam-logo small {
  color: var(--codam-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.nav-group {
  border-top: 1px solid rgba(213, 220, 229, 0.8);
  padding: 10px 0;
}

.nav-group:first-child {
  border-top: 0;
}

.nav-group.separate {
  margin-top: 8px;
}

.nav-title {
  color: var(--codam-muted);
  font-size: 0.72rem;
  font-weight: 800;
  margin: 0 8px 6px;
  text-transform: uppercase;
}

.nav-item,
.nav-sub,
.marketplace-node button,
.nav-sub-parent {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
  color: #344054;
  display: flex;
  gap: 8px;
  min-height: 34px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.nav-item:hover,
.nav-sub:hover,
.marketplace-node button:hover {
  background: #ffffff;
}

.nav-item.active,
.marketplace-node button.active {
  background: var(--codam-blue);
  color: white;
  font-weight: 800;
}

.nav-icon {
  align-items: center;
  background: white;
  border: 1px solid var(--codam-border);
  border-radius: 6px;
  display: inline-flex;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.nav-caret,
.nav-sub-parent span {
  margin-left: auto;
}

.nav-sub {
  font-size: 0.82rem;
  padding-left: 42px;
}

.nav-sub-parent {
  color: var(--codam-blue);
  font-weight: 800;
}

.marketplace-tree {
  display: grid;
  gap: 8px;
  margin: 4px 0 0 30px;
}

.marketplace-node {
  border-left: 3px solid var(--codam-divider);
  display: grid;
  gap: 2px;
  padding-left: 8px;
}

.marketplace-node.active {
  border-left-color: var(--codam-blue);
}

.marketplace-node-title {
  align-items: center;
  color: var(--codam-text);
  display: flex;
  font-size: 0.78rem;
  font-weight: 850;
  gap: 6px;
  min-height: 24px;
}

.market-dot {
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.market-dot.ml {
  background: var(--ml);
  border: 1px solid #d9c900;
}

.market-dot.shopee {
  background: var(--shopee);
}

.marketplace-node button {
  font-size: 0.78rem;
  min-height: 30px;
  padding: 6px 8px;
}

.main {
  min-width: 0;
}

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

/* HEAD-01 */
.topbar {
  align-items: center;
  background: var(--codam-surface);
  border-bottom: 1px solid var(--codam-border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px 18px;
}

.topbar-actions {
  align-items: end;
  display: flex;
  gap: 8px;
}

.global-search {
  display: grid;
  gap: 4px;
}

.global-search span,
.filter-field span {
  color: var(--codam-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

input,
select {
  background: white;
  border: 1px solid var(--codam-border);
  border-radius: var(--radius-control);
  color: var(--codam-text);
  height: 38px;
  min-width: 0;
  padding: 0 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--codam-blue);
  outline-offset: 1px;
}

/* BTN-01, BTN-02, BTN-03 */
.button,
.button-compact,
.icon-button,
.tab-button {
  border-radius: var(--radius-control);
  font-weight: 750;
}

.button {
  background: white;
  border: 1px solid var(--codam-border);
  color: #344054;
  height: 38px;
  padding: 0 12px;
}

.button:disabled {
  background: #f2f4f7;
  color: #98a2b3;
  cursor: not-allowed;
}

.button.primary {
  background: var(--codam-blue);
  border-color: var(--codam-blue);
  color: white;
}

.button-compact {
  background: var(--codam-blue);
  border: 1px solid var(--codam-blue);
  color: white;
  font-size: 0.78rem;
  height: 30px;
  padding: 0 10px;
}

.icon-button {
  align-items: center;
  background: white;
  border: 1px solid var(--codam-border);
  color: var(--codam-blue);
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

/* CTX-01, BREAD-01, DATA-01 */
.context-bar {
  align-items: center;
  background: var(--codam-surface);
  border: 1px solid var(--codam-border);
  border-radius: var(--radius-panel);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 42px;
  padding: 8px 12px;
}

.breadcrumb-demo {
  align-items: center;
  color: var(--codam-muted);
  display: flex;
  flex-wrap: nowrap;
  font-size: 0.78rem;
  font-weight: 700;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
}

.breadcrumb-home {
  color: var(--codam-blue);
}

.data-reference {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.data-source-pill {
  background: var(--codam-blue-soft);
  border-radius: 999px;
  color: #008b92;
  font-size: 0.72rem;
  font-weight: 850;
  padding: 3px 8px;
}

.data-updated,
.data-alert {
  color: var(--codam-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.data-alert {
  color: #a15c00;
}

/* KPI-01 */
.codam-kpi-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.kpi-card {
  align-items: center;
  background: var(--codam-surface);
  border: 1px solid var(--codam-border);
  border-radius: var(--radius-panel);
  display: flex;
  gap: 10px;
  min-height: 78px;
  padding: 12px;
}

.kpi-icon {
  align-items: center;
  background: var(--codam-blue-soft);
  border-radius: 8px;
  color: var(--codam-blue);
  display: flex;
  flex: 0 0 36px;
  font-size: 1.4rem;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.kpi-card strong {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.kpi-card span,
.kpi-card small {
  color: var(--codam-muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 750;
}

.kpi-card small {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 2px;
}

/* FLT-01, CHIP-01 */
.search-row {
  align-items: end;
  background: var(--codam-surface);
  border: 1px solid var(--codam-border);
  border-radius: var(--radius-panel);
  display: grid;
  gap: 10px;
  grid-template-columns: 150px 160px 210px minmax(220px, 1fr) auto;
  padding: 10px;
}

.filter-field {
  display: grid;
  gap: 4px;
}

.filter-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.chip-compact {
  align-items: center;
  background: white;
  border: 1px solid var(--codam-border);
  border-radius: 999px;
  color: #344054;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 800;
  gap: 4px;
  min-height: 28px;
  padding: 4px 8px;
}

.chip-compact button {
  background: transparent;
  border: 0;
  color: var(--codam-muted);
  font-weight: 900;
  padding: 0;
}

/* TAG-01 */
.marketplace-badge,
.codam-status-badge,
.pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1;
  padding: 5px 8px;
  white-space: nowrap;
}

.marketplace-badge.ml {
  background: var(--ml);
  border: 1px solid #d9c900;
  color: #2b2600;
}

.marketplace-badge.shopee {
  background: var(--shopee);
  color: white;
}

.codam-status-badge {
  background: #f2f4f7;
  border: 1px solid var(--codam-border);
  color: #344054;
}

.codam-status-badge.xml {
  background: #fff8cc;
  border-color: #e7d95a;
}

.codam-status-badge.nfe {
  background: var(--codam-blue-soft);
  color: var(--codam-blue);
}

.codam-status-badge.futuro {
  background: #fff1ed;
  border-color: #ffb6a5;
  color: #9d341e;
}

.codam-status-badge.erro {
  background: #fee4e2;
  border-color: #fda29b;
  color: #b42318;
}

/* TAB-01 */
.table-shell {
  background: var(--codam-surface);
  border: 1px solid var(--codam-border);
  border-left: 4px solid var(--codam-blue);
  border-radius: var(--radius-panel);
  overflow: hidden;
}

.table-shell.ml {
  border-left-color: var(--ml);
}

.table-shell.shopee {
  border-left-color: var(--shopee);
}

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

.codam-table {
  border-collapse: collapse;
  min-width: 1060px;
  table-layout: fixed;
  width: 100%;
}

.codam-table th {
  background: #f8fafc;
  border-bottom: 1px solid var(--codam-divider);
  color: var(--codam-muted);
  font-size: 0.72rem;
  font-weight: 850;
  height: 36px;
  padding: 0 10px;
  text-align: left;
  text-transform: uppercase;
}

.codam-table td {
  border-bottom: 1px solid #e8edf2;
  color: #344054;
  font-size: 0.82rem;
  height: 45px;
  padding: 0 10px;
  vertical-align: middle;
}

.codam-table tr:last-child td {
  border-bottom: 0;
}

.codam-table th:first-child,
.codam-table td:first-child {
  width: 76px;
}

.num {
  text-align: right;
}

.ellipsis {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strong {
  color: var(--codam-text);
  font-weight: 750;
}

.market-row.ml {
  box-shadow: inset 3px 0 0 rgba(255, 230, 0, 0.9);
}

.market-row.shopee {
  box-shadow: inset 3px 0 0 rgba(238, 77, 45, 0.9);
}

.table-summary {
  background: #f8fafc;
  border-top: 1px solid var(--codam-divider);
  color: var(--codam-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 8px 10px;
}

/* SURF-01, LINE-01 */
.section {
  background: var(--codam-surface);
  border: 1px solid var(--codam-border);
  border-radius: var(--radius-panel);
  padding: 14px;
}

.section-header {
  align-items: center;
  border-bottom: 1px solid var(--codam-divider);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
}

.config-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(360px, 1fr) minmax(280px, 0.75fr);
}

.config-panel {
  border-left: 4px solid var(--codam-blue);
}

.config-panel.ml {
  border-left-color: var(--ml);
}

.config-panel.shopee {
  border-left-color: var(--shopee);
}

.dense-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.dense-list div {
  border-bottom: 1px solid #e8edf2;
  display: grid;
  gap: 10px;
  grid-template-columns: 150px minmax(0, 1fr);
  padding: 8px 0;
}

.dense-list dt {
  color: var(--codam-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.dense-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.button-row.vertical {
  display: grid;
}

.checklist,
.history-list {
  color: #344054;
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.guide-consult p {
  margin-bottom: 12px;
}

.guide-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.guide-grid span,
.pill {
  background: var(--codam-blue-soft);
  color: var(--codam-blue);
}

/* codam-drawer */
.codam-drawer {
  background: var(--codam-surface);
  border-left: 5px solid var(--codam-blue);
  box-shadow: 0 18px 42px rgba(16, 24, 40, 0.18);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
  max-width: 440px;
  position: fixed;
  right: 0;
  top: 0;
  width: min(440px, 92vw);
  z-index: 30;
}

.codam-drawer.ml {
  border-left-color: var(--ml);
}

.codam-drawer.shopee {
  border-left-color: var(--shopee);
}

.drawer-scrim {
  background: rgba(16, 24, 40, 0.16);
  border: 0;
  bottom: 0;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.drawer-head {
  align-items: start;
  border-bottom: 1px solid var(--codam-divider);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px;
}

.drawer-head strong,
.drawer-head span {
  display: block;
}

.drawer-head strong {
  font-size: 1rem;
}

.drawer-head > div > span {
  color: var(--codam-muted);
  font-size: 0.78rem;
  margin-top: 3px;
}

.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.task-tab-row {
  border-bottom: 1px solid var(--codam-divider);
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 10px;
}

.tab-button {
  background: white;
  border: 1px solid transparent;
  color: var(--codam-muted);
  flex: 0 0 auto;
  font-size: 0.78rem;
  height: 32px;
  padding: 0 9px;
}

.tab-button.active {
  background: var(--codam-blue-soft);
  border-color: var(--codam-border);
  color: var(--codam-blue);
}

.drawer-body {
  overflow: auto;
  padding: 14px;
}

.drawer-note {
  background: #f8fafc;
  border: 1px solid var(--codam-border);
  border-radius: var(--radius-panel);
  color: var(--codam-muted);
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 12px;
  padding: 10px;
}

.email-result-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.email-result {
  background: #f8fafc;
  border: 1px solid var(--codam-border);
  border-radius: var(--radius-panel);
  display: grid;
  gap: 5px;
  padding: 10px;
}

.email-result strong,
.email-result span,
.email-result small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-result span,
.email-result small {
  color: var(--codam-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.email-result-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 4px;
}

/* SCROLL-01 */
.codam-scrollbar {
  scrollbar-color: #b8c1cc #f1f5f9;
  scrollbar-width: thin;
}

.codam-scrollbar::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.codam-scrollbar::-webkit-scrollbar-track,
.drawer-body::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.codam-scrollbar::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb {
  background: #b8c1cc;
  border-radius: 999px;
}

.codam-scrollbar::-webkit-scrollbar-thumb:hover,
.drawer-body::-webkit-scrollbar-thumb:hover {
  background: #aab4c0;
}

@media (max-width: 1160px) {
  .shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .sidebar {
    width: 86px;
  }

  .sidebar .nav-title,
  .sidebar .nav-item span:not(.nav-icon),
  .sidebar .nav-sub,
  .sidebar .marketplace-tree,
  .sidebar .codam-logo small {
    display: none;
  }

  .codam-kpi-row {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .search-row,
  .config-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    display: block;
  }

  .sidebar {
    min-height: auto;
    position: static;
    width: auto;
  }

  .topbar,
  .context-bar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .content {
    padding: 12px;
  }

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