/* Gestão: app independente, com a mesma linguagem visual da app de parceiros. */
:root {
  --v27-ink: #191a1a;
  --v27-muted: #717472;
  --v27-paper: #f4f4f1;
  --v27-line: #e4e5e1;
  --v27-card: #fff;
  --v27-gold: #c9ad71;
  --v27-danger: #b42318;
  --v27-shadow: 0 16px 42px rgba(20, 22, 20, .055);
}

html { scroll-behavior: smooth; scroll-padding-top: 24px; background: var(--v27-paper); }
body.admin-app { min-height: 100vh; margin: 0; background: var(--v27-paper); color: var(--v27-ink); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body.admin-app * { box-sizing: border-box; }
body.admin-app button, body.admin-app input, body.admin-app select, body.admin-app textarea { font: inherit; }
body.admin-app button { cursor: pointer; }
body.admin-app h1, body.admin-app h2, body.admin-app h3 { font-family: inherit; color: var(--v27-ink); letter-spacing: -.025em; }
body.admin-app h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.08; font-weight: 650; }
body.admin-app h2 { font-size: clamp(22px, 2.5vw, 28px); font-weight: 620; }
body.admin-app h3 { font-size: 18px; font-weight: 620; }
body.admin-app .hidden { display: none !important; }

#auth.auth-card { width: min(560px, calc(100% - 28px)); margin: clamp(24px, 8vh, 80px) auto; border: 1px solid var(--v27-line); border-radius: 20px; background: var(--v27-card); box-shadow: var(--v27-shadow); padding: clamp(24px, 5vw, 38px); }
.auth-card .brandlockup { margin-bottom: 24px; }
.auth-card .brandlockup img:first-child { width: 44px; height: 54px; object-fit: contain; }
.auth-card .brandlockup img:nth-child(2) { width: 56px; height: 48px; object-fit: contain; }
.auth-card .brandtitle strong { font: 600 17px/1.2 Inter, Arial, sans-serif; }
.auth-card .brandtitle small { letter-spacing: .1em; }
.auth-card #auth-title { margin: 0 0 8px; }
.auth-card #auth-message { margin: 0 0 20px; font-size: 13px; line-height: 1.5; }
.auth-login { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; width: 100%; min-width: 0; }
.auth-login > * { min-width: 0; }
.auth-login .field { display: block; width: 100%; min-width: 0; margin: 0; color: #3d403e; font-size: 12px; font-weight: 650; }
.auth-login .field input { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 48px; margin-top: 7px; border: 1px solid #d6d8d4; border-radius: 11px; background: #fff; color: var(--v27-ink); padding: 12px 14px; }
.auth-login .field input:focus { border-color: var(--v27-gold); outline: 3px solid #c9ad7128; }
.auth-login .button { width: 100%; min-width: 0; max-width: 100%; min-height: 48px; border: 1px solid #202121; border-radius: 12px; background: #202121; color: #fff; font-size: 13px; font-weight: 650; }
.auth-login .button:disabled { cursor: wait; opacity: .65; }
.auth-login-message { min-height: 0; color: #a33128; font-size: 12px; line-height: 1.45; }
.auth-login-message:empty { display: none; }
.auth-google { width: 100%; min-width: 0; margin-top: 6px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; color: var(--v27-muted); font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--v27-line); }
.auth-google-button { display: flex; justify-content: center; width: 100%; max-width: 100%; min-height: 44px; overflow: hidden; }
.auth-google-button > div, .auth-google-button iframe { max-width: 100% !important; }

#app:not(.hidden) { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: 100vh; }
.admin-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 15px; display: flex; flex-direction: column; color: #fff; background: linear-gradient(180deg, #202121 0%, #171818 100%); border-right: 1px solid #ffffff12; }
.side-brand { display: flex; align-items: center; gap: 11px; padding: 7px 8px 20px; margin: 0 0 12px; border-bottom: 1px solid #ffffff20; }
.side-brand img:first-child { width: 44px; height: 48px; object-fit: contain; background: transparent; padding: 0; }
.side-brand img:nth-child(2) { width: 61px; height: 28px; object-fit: contain; background: transparent; padding: 0; }
.side-brand span { color: #f5f5f3; font: 550 13px/1.3 Inter, Arial, sans-serif; }
.admin-nav { display: grid; gap: 5px; margin-top: 6px; }
.admin-nav a { position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 11px; border: 1px solid transparent; border-radius: 11px; color: #c2c5c2; text-decoration: none; font-size: 13px; transition: background .18s ease, color .18s ease; }
.admin-nav a:hover, .admin-nav a:focus-visible { color: #fff; background: #ffffff0d; outline: none; }
.admin-nav a.is-current { color: #fff; background: #ffffff12; border-color: #ffffff12; box-shadow: inset 3px 0 var(--v27-gold); }
.admin-nav-icon { width: 20px; height: 20px; flex: 0 0 20px; }
.admin-nav-icon svg { display: block; width: 100%; height: 100%; }
.nav-badge { margin-left: auto; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 20px; background: var(--v27-danger); color: #fff; text-align: center; font: 700 11px/21px Arial, sans-serif; }
.nav-badge[hidden] { display: none !important; }
.side-account { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid #ffffff20; }
.side-account strong { display: block; color: #fff; font-size: 13px; }
.side-account small { display: block; margin-top: 3px; color: #c4c5c4; font-size: 11px; overflow-wrap: anywhere; }
.side-account button { margin-top: 11px; padding: 0; border: 0; background: none; color: #dedfdd; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }

.admin-main { width: 100%; max-width: 1500px; min-width: 0; margin: 0 auto; padding: 24px clamp(20px, 3.4vw, 50px) 58px; }
.topline { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topline .brandlockup { display: none; align-items: center; gap: 9px; }
.topline .brandlockup img:first-child { width: 39px; height: 48px; object-fit: contain; }
.topline .brandlockup img:nth-child(2) { width: 52px; height: 29px; object-fit: contain; }
.brandtitle { margin-left: 4px; padding-left: 12px; border-left: 1px solid #d8d9d5; }
.brandtitle strong { display: block; font: 600 16px/1.25 Inter, Arial, sans-serif; }
.brandtitle small { display: block; margin-top: 2px; color: var(--v27-muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.admin-main .button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border: 1px solid #1d1e20; border-radius: 11px; background: #1d1e20; color: #fff; font-size: 12px; font-weight: 650; letter-spacing: 0; text-decoration: none; }
.admin-main .button.secondary { background: #fff; color: var(--v27-ink); border-color: var(--v27-line); }
.admin-main .button:focus-visible, .admin-main a:focus-visible, .admin-sidebar a:focus-visible { outline: 3px solid #c9ad7180; outline-offset: 2px; }
.admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 0 0 18px; }
.admin-heading h1 { margin: 7px 0 8px; }
.admin-heading .muted, .overview p { max-width: 660px; margin: 0; color: var(--v27-muted); font-size: 14px; line-height: 1.55; }
.overview { margin: 0 0 22px; padding: clamp(22px, 3vw, 32px); border: 1px solid var(--v27-line); border-radius: 22px; background: linear-gradient(135deg, #fff 0%, #f8f7f2 100%); box-shadow: var(--v27-shadow); }
.overview .muted:first-child { color: #9b8353; font-size: 11px; font-weight: 720; letter-spacing: .16em; text-transform: uppercase; }
.queue-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 22px 0 18px; overflow: hidden; border: 1px solid var(--v27-line); border-radius: 18px; background: #fff; }
.summary-card { min-width: 0; padding: 15px 17px; border-right: 1px solid var(--v27-line); border-bottom: 0; background: transparent; }
.summary-card:last-child { border-right: 0; }
.summary-card small { display: block; color: var(--v27-muted); font-size: 11px; line-height: 1.35; }
.summary-card strong { display: block; margin-top: 8px; font: 650 30px/1 Inter, Arial, sans-serif; }
.overview-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.overview-actions .button { min-height: 78px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; padding: 13px 15px; text-align: left; }
.overview-actions .button strong { font-size: 13px; }
.overview-actions .button small { color: inherit; font-size: 11px; font-weight: 450; line-height: 1.4; opacity: .78; }
.admin-main .card { margin: 16px 0; padding: clamp(18px, 2.5vw, 26px); scroll-margin-top: 16px; border: 1px solid var(--v27-line); border-radius: 20px; background: #fff; box-shadow: var(--v27-shadow); }
.admin-main .card > h2 { margin: 0 0 6px; }
.section-intro { margin: 0 0 17px; color: var(--v27-muted); font-size: 13px; line-height: 1.5; }
.toolbar { gap: 10px; }
.field label { color: #3d403e; }
.field input, .field select, .field textarea { min-height: 44px; border: 1px solid #d6d8d4; border-radius: 10px; background: #fff; color: var(--v27-ink); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--v27-gold); outline: 3px solid #c9ad7128; }
.row { gap: 13px; border-top-color: var(--v27-line); }
.detail { border-radius: 14px; background: #f7f7f4; }
.admin-notice { border: 1px solid var(--v27-line); border-radius: 14px; background: #fcfcfa; }
.admin-notice.unread { border-left: 3px solid var(--v27-danger); }
.admin-notice h3 { font-family: inherit; font-weight: 620; }
.admin-notice p { line-height: 1.5; }
.portal-footer { gap: 14px; margin-top: 46px; padding: 28px 0 8px; border-top: 1px solid var(--v27-line); }
.portal-footer .portal-avatar { width: 62px; height: 62px; flex: 0 0 62px; overflow: hidden; border-radius: 50%; background: #dedfdc; }
.portal-footer .portal-avatar img { width: 100% !important; height: 100% !important; object-fit: cover !important; object-position: center 17% !important; }
.portal-footer strong { font: 600 15px/1.3 Inter, Arial, sans-serif; }
.portal-footer small, .portal-footer span { font-size: 11px; }
.admin-mobilebar, .admin-more-panel { display: none; }

@media (max-width: 980px) and (min-width: 721px) {
  #app:not(.hidden) { grid-template-columns: 220px minmax(0, 1fr); }
  .admin-sidebar { padding-inline: 11px; }
  .admin-main { padding-inline: 18px; }
  .queue-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card:nth-child(2) { border-right: 0; }
  .summary-card:nth-child(-n+2) { border-bottom: 1px solid var(--v27-line); }
  .overview-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  #app:not(.hidden) { display: block; min-height: 100vh; }
  .admin-sidebar { display: none; }
  .admin-main { max-width: none; padding: 0 14px calc(112px + env(safe-area-inset-bottom)); }
  .topline { position: sticky; z-index: 8; top: 0; min-height: 76px; margin: 0 -14px 14px; padding: 8px 16px; border-bottom: 1px solid #e8e9e5; background: rgba(250, 250, 247, .96); backdrop-filter: blur(14px); }
  .topline .brandlockup { display: flex; }
  .topline .brandlockup img:first-child { width: 35px; height: 44px; }
  .topline .brandlockup img:nth-child(2) { width: 48px; height: 27px; }
  .brandtitle { padding-left: 10px; }
  .brandtitle strong { font-size: 14px; }
  .brandtitle small { font-size: 8px; }
  #adminLogoutTop { min-height: 38px; padding: 8px 11px; font-size: 11px; white-space: nowrap; }
  .overview { margin: 0 -2px 17px; padding: 20px 16px 16px; border-radius: 22px; }
  .admin-heading { display: block; margin-bottom: 16px; }
  .admin-heading h1 { margin: 6px 0 8px; font-size: 33px; }
  .admin-heading .muted, .overview p { font-size: 13px; }
  .queue-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 17px 0 14px; border-radius: 17px; }
  .summary-card { min-height: 88px; padding: 13px 14px; }
  .summary-card:nth-child(2) { border-right: 0; }
  .summary-card:nth-child(-n+2) { border-bottom: 1px solid var(--v27-line); }
  .summary-card strong { margin-top: 7px; font-size: 28px; }
  .overview-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 13px; }
  .overview-actions .button { min-height: 68px; padding: 11px 12px; border-radius: 14px; }
  .overview-actions .button strong { font-size: 12px; line-height: 1.35; }
  .overview-actions .button small { font-size: 10px; }
  .admin-main .card { margin: 13px 0; padding: 19px 16px; border-radius: 19px; }
  .admin-main .card > h2 { font-size: 23px; }
  .section-intro { margin-bottom: 14px; font-size: 12px; }
  .toolbar { grid-template-columns: minmax(0, 1fr); }
  .toolbar .search { grid-column: auto; }
  .toolbar > .button { margin-bottom: 10px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 15px 0; }
  .row > div:first-child { grid-column: auto; }
  .detail { grid-template-columns: minmax(0, 1fr); padding: 13px; }
  .detail .full { grid-column: auto; }
  .queue-summary { margin-bottom: 14px; }
  .admin-notice { grid-template-columns: minmax(0, 1fr); padding: 13px; }
  .portal-footer { grid-template-columns: 54px minmax(0, 1fr); gap: 10px; margin-top: 32px; padding: 24px 0 8px; }
  .portal-footer .portal-avatar { width: 54px; height: 54px; grid-row: span 2; }
  .admin-mobilebar { position: fixed; z-index: 20; left: 12px; right: 12px; bottom: max(9px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding: 6px 7px; border: 1px solid #ffffff17; border-radius: 23px; background: #202121; box-shadow: 0 12px 36px #10111140; }
  .admin-mobilebar a, .admin-mobilebar button { position: relative; min-width: 0; min-height: 57px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; border-radius: 16px; background: transparent; color: #d1d3d0; text-decoration: none; font-size: 9px; line-height: 1.15; }
  .admin-mobilebar .nav-icon { width: 20px; height: 20px; display: block; }
  .admin-mobilebar .nav-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .admin-mobilebar a.is-current, .admin-mobilebar button.is-current { background: #ffffff13; color: var(--v27-gold); }
  .admin-mobilebar .app-badge { position: absolute; top: 3px; right: calc(50% - 21px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 12px; background: var(--v27-danger); color: #fff; font: 700 9px/17px Arial, sans-serif; }
  .admin-mobilebar .app-badge[hidden] { display: none !important; }
  .admin-more-panel { position: fixed; z-index: 19; right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); width: min(320px, calc(100vw - 28px)); display: block; padding: 12px; border: 1px solid #e5e6e2; border-radius: 18px; background: #fff; box-shadow: 0 16px 48px #15161624; }
  .admin-more-panel[hidden] { display: none !important; }
  .admin-more-title { padding: 5px 9px 10px; color: var(--v27-muted); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
  .admin-more-items { display: grid; gap: 3px; }
  .admin-more-items a, .admin-more-items button { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--v27-ink); text-align: left; text-decoration: none; font-size: 13px; }
  .admin-more-items a:hover, .admin-more-items button:hover { background: #f4f4f1; }
  .admin-more-items .app-badge { position: static; display: inline-block; min-width: 20px; height: 20px; margin-left: auto; padding: 0 5px; border-radius: 12px; background: var(--v27-danger); color: #fff; text-align: center; font: 700 10px/20px Arial, sans-serif; }
  .admin-more-items .app-badge[hidden] { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Gestão v4: partilha a linguagem visual da área de parceiros. */
.topline-actions { display: flex; align-items: center; gap: 9px; }
.admin-install-button[hidden] { display: none !important; }
.admin-install-button:not([hidden]) { min-height: 42px; }
.overview { margin: 3px 0 30px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.admin-heading { margin-bottom: 20px; }
.admin-heading > div > .muted { color: #9b8353; font-size: 10px; font-weight: 720; letter-spacing: .16em; text-transform: uppercase; }
.admin-heading h1 { margin: 7px 0 8px; font-size: clamp(34px, 4vw, 48px); }
.admin-heading .muted, .overview p { max-width: 660px; line-height: 1.55; }
.queue-summary { margin: 0 0 17px; border: 1px solid var(--v27-line); border-radius: 17px; background: var(--v27-card); box-shadow: var(--v27-shadow); }
.summary-card { min-height: 110px; display: flex; flex-direction: column; justify-content: center; gap: 11px; padding: 18px 19px; border-right: 1px solid var(--v27-line); }
.summary-card small { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.summary-card small::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--v27-gold); }
.summary-card strong { margin: 0; font-size: 32px; letter-spacing: -.04em; }
.overview-actions { gap: 10px; margin-top: 0; }
.overview-actions .button { position: relative; min-height: 82px; padding: 15px 38px 14px 16px; border: 1px solid var(--v27-line); border-radius: 16px; background: #fff; color: var(--v27-ink); box-shadow: 0 8px 25px rgba(20, 22, 20, .035); transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.overview-actions .button::after { content: "↗"; position: absolute; top: 13px; right: 15px; color: #9b8353; font-size: 15px; }
.overview-actions .button:hover { transform: translateY(-2px); border-color: #d1c19d; box-shadow: 0 12px 28px rgba(20, 22, 20, .075); }
.overview-actions .button strong { font-size: 13px; line-height: 1.35; }
.overview-actions .button small { color: var(--v27-muted); font-size: 11px; line-height: 1.4; opacity: 1; }
.admin-main .card { margin: 17px 0; border-radius: 18px; }
.admin-main .card > h2 { font-size: 22px; line-height: 1.25; }
.section-intro { max-width: 720px; }

@media (max-width: 720px) {
  .topline { gap: 8px; }
  .topline .brandlockup { min-width: 0; gap: 7px; }
  .topline .brandlockup img:first-child { width: 31px; height: 42px; }
  .topline .brandlockup img:nth-child(2) { width: 42px; height: 25px; }
  .topline .brandtitle { min-width: 0; margin-left: 1px; padding-left: 8px; }
  .topline .brandtitle strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .topline .brandtitle small { font-size: 7px; }
  .topline-actions { flex: 0 0 auto; }
  #adminLogoutTop { display: none; }
  .admin-install-button:not([hidden]) { min-height: 38px; padding: 8px 10px; font-size: 10px; }
  .overview { margin: 5px 0 24px; padding: 0; }
  .admin-heading { margin-bottom: 16px; }
  .admin-heading h1 { font-size: clamp(31px, 8vw, 39px); }
  .queue-summary { margin-bottom: 13px; border-radius: 15px; }
  .summary-card { min-height: 89px; gap: 8px; padding: 13px 14px; }
  .summary-card strong { font-size: 29px; }
  .overview-actions { gap: 8px; }
  .overview-actions .button { min-height: 75px; padding: 12px 28px 11px 12px; border-radius: 14px; }
  .overview-actions .button::after { top: 10px; right: 11px; }
  .overview-actions .button strong { font-size: 11px; }
  .overview-actions .button small { font-size: 9px; }
  .admin-main .card { margin: 14px 0; }
}

/* V30 · pipeline dentro do detalhe de cada referência. */
.admin-app .detail .reference-pipeline.full { grid-column: 1 / -1; margin: 0 0 18px; }
.admin-app .reference-pipeline { border-color: #e4e2dc; background: #fff; }
.admin-app .reference-pipeline-step.is-current .reference-pipeline-marker { background: #f6f1e5; }
.admin-app .logout-message { color: #9d3d35; }
.admin-app .side-account .logout-message { color: #ffc6bf; }
