@import url("./shared/ui.css");

:root{
  color-scheme: light;
}
textarea { min-height: 100px; resize: vertical; }
.project-list {
  margin-top: 16px;
}

.access-item {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}
.access-actions { justify-content: flex-end; }
.access-actions select { min-width: 140px; }
@media (max-width: 760px) {
  .access-item { align-items: stretch; flex-direction: column; }
  .access-actions { justify-content: flex-start; }
}

.auth-note { font-size: 13px; line-height: 1.4; }
#otpCodeInput { letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }


/* ============================================================
   HOME PÚBLICA — SIGN LAB
   Mantém intactos os fluxos de autenticação; altera apenas
   hierarquia, proporções e linguagem visual da entrada.
   ============================================================ */
body:not(.logged-in):not(.project-home){
  --bg:#0b0c10;
  --panel:#111319;
  --panel-2:#0f1116;
  --border:#232633;
  --border-strong:#303442;
  --text:#e9ecf1;
  --muted:#9da5b4;
  --accent:#4c8dff;
  --accent-contrast:#ffffff;
  --shadow:none;
  background:var(--bg);
  color:var(--text);
}
body:not(.logged-in):not(.project-home) .container{
  max-width:1240px;
  min-height:100vh;
  padding:22px 26px 48px;
}
body:not(.logged-in):not(.project-home) .topbar{
  min-height:54px;
  margin-bottom:0;
  padding-bottom:14px;
  border-bottom:1px solid var(--border);
}
body:not(.logged-in):not(.project-home) .brand{
  font-size:18px;
  font-weight:600;
  letter-spacing:.01em;
}
body:not(.logged-in):not(.project-home) #sessionPill{ display:none; }
.public-login{
  display:grid;
  grid-template-columns:minmax(0,1.2fr) minmax(360px,460px);
  column-gap:72px;
  row-gap:18px;
  align-items:center;
  min-height:calc(100vh - 110px);
  padding:54px 0 72px;
}
.login-intro{ align-self:center; }
.login-intro h1{
  max-width:650px;
  margin:0;
  color:var(--text);
  font-size:clamp(38px,5vw,68px);
  line-height:1.02;
  letter-spacing:-.01em;
  font-weight:500;
}
body:not(.logged-in):not(.project-home) .auth-card{
  align-self:center;
  background:transparent;
  border:0;
  border-radius:0;
  padding:0;
  box-shadow:none;
}
body:not(.logged-in):not(.project-home) .auth-card h2{
  margin:0 0 8px;
  color:var(--text);
  font-size:20px;
  font-weight:500;
}
body:not(.logged-in):not(.project-home) .auth-card .muted{ color:var(--muted); }
body:not(.logged-in):not(.project-home) .auth-card label{
  color:var(--muted);
  font-size:12px;
  font-weight:500;
}
body:not(.logged-in):not(.project-home) .auth-card input{
  border:1px solid var(--border);
  background:#10131b;
  color:var(--text);
  border-radius:10px;
}
body:not(.logged-in):not(.project-home) .auth-card button,
body:not(.logged-in):not(.project-home) .legacy-zip-button{
  min-height:40px;
  border:1px solid var(--border-strong);
  border-radius:10px;
  background:var(--panel);
  color:var(--text);
  font-weight:500;
}
body:not(.logged-in):not(.project-home) .auth-card button.primary{
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
}
.auth-primary-actions{ align-items:stretch; }
.auth-main-action{ flex:1 1 220px; }
.auth-secondary-action{ flex:0 0 auto; padding-left:12px; padding-right:12px; font-size:13px; }
.legacy-access{
  grid-column:2;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:14px;
  padding-top:18px;
  border-top:1px solid var(--border);
}
.legacy-zip-button{
  min-height:34px !important;
  padding:7px 10px !important;
  font-size:12px;
  white-space:nowrap;
}
@media (max-width:800px){
  .public-login{
    grid-template-columns:1fr;
    min-height:auto;
    padding:48px 0;
    row-gap:52px;
  }
  .login-intro h1{ font-size:clamp(36px,10vw,54px); }
  .legacy-access{ grid-column:1; }
}

/* ============================================================
   HOME DO SISTEMA / HOME DO PROJETO — UX V5
   Mantém a tela de login existente; o tema escuro é aplicado
   somente após autenticação e na home de projeto.
   ============================================================ */

body.logged-in,
body.project-home{
  --bg:#0b0c10;
  --panel:#111319;
  --panel-2:#0f1116;
  --border:#232633;
  --border-strong:#303442;
  --text:#e9ecf1;
  --muted:#9da5b4;
  --accent:#4c8dff;
  --accent-contrast:#ffffff;
  --danger:#ff5c5c;
  --shadow:none;
  background:var(--bg);
  color:var(--text);
  font-weight:400;
}

body.logged-in .container,
body.project-home .container{
  max-width:1240px;
  padding:22px 26px 48px;
}

body.logged-in .topbar,
body.project-home .topbar{
  min-height:54px;
  margin-bottom:34px;
  padding-bottom:14px;
  border-bottom:1px solid var(--border);
}

body.logged-in .brand,
body.project-home .brand{
  font-size:18px;
  font-weight:600;
  letter-spacing:.01em;
}

.brand-link{
  text-decoration:none;
}

body.logged-in h1,
body.project-home h1,
body.logged-in h2,
body.project-home h2,
body.logged-in h3,
body.project-home h3{
  font-weight:500;
  letter-spacing:-.01em;
}

body.logged-in h1,
body.project-home h1{
  margin:0;
  font-size:30px;
}

body.logged-in h2,
body.project-home h2{
  margin:0;
  font-size:20px;
}

body.logged-in h3,
body.project-home h3{
  margin:0 0 10px;
  font-size:14px;
}

body.logged-in .muted,
body.project-home .muted{
  color:var(--muted);
  font-weight:400;
}

body.logged-in button,
body.logged-in .btn,
body.project-home button,
body.project-home .btn{
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  border-radius:10px;
  min-height:36px;
  padding:8px 12px;
  font-weight:500;
}

body.logged-in button.primary,
body.logged-in .btn.primary,
body.project-home button.primary,
body.project-home .btn.primary{
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
}

body.logged-in input,
body.logged-in textarea,
body.logged-in select,
body.project-home input,
body.project-home textarea,
body.project-home select{
  border:1px solid var(--border);
  background:#10131b;
  color:var(--text);
  border-radius:10px;
  font-weight:400;
}

body.logged-in label,
body.project-home label{
  color:var(--muted);
  font-size:12px;
  font-weight:500;
}

.account-actions{
  display:flex;
  align-items:center;
  gap:10px;
}

.compact-create{
  white-space:nowrap;
}

.profile-menu-wrap{
  position:relative;
}

.profile-avatar{
  width:38px;
  height:38px;
  min-height:38px !important;
  padding:0 !important;
  border-radius:999px !important;
  font-size:14px;
  font-weight:600 !important;
  text-transform:uppercase;
}

.profile-menu{
  position:absolute;
  right:0;
  top:46px;
  z-index:30;
  width:240px;
  padding:8px;
  background:#111319;
  border:1px solid #2a2e3a;
  border-radius:14px;
  box-shadow:0 18px 50px rgba(0,0,0,.38);
}

.profile-menu__identity{
  display:flex;
  flex-direction:column;
  gap:3px;
  padding:10px 10px 12px;
  border-bottom:1px solid var(--border);
  margin-bottom:6px;
}

.profile-menu__identity strong{
  font-size:14px;
  font-weight:500;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.profile-menu__identity .muted{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:11px;
}

.profile-menu__item{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  min-height:36px;
  padding:8px 10px;
  border:0 !important;
  background:transparent !important;
  color:var(--text) !important;
  text-decoration:none;
  border-radius:8px !important;
  font-size:13px;
  font-weight:400 !important;
}

.profile-menu__item:hover{
  background:rgba(255,255,255,.05) !important;
}

.profile-menu__danger{
  color:#ff8d8d !important;
}

body.logged-in .login-only{
  display:none !important;
}

.home-section,
.project-section{
  margin-top:34px;
}

.section-heading{
  margin-bottom:18px;
}

.section-heading--row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
}

.section-heading p{
  margin:6px 0 0;
}

body.logged-in .project-list{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}

body.logged-in .project-item,
body.project-home .item{
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  box-shadow:none;
}

.project-card-shell{
  position:relative;
}

.project-card-shell .project-card-link{
  height:100%;
  padding-right:54px;
}

body.logged-in .project-delete-btn{
  position:absolute;
  right:14px;
  bottom:12px;
  width:auto;
  min-height:0;
  padding:2px 0;
  border:0;
  background:transparent;
  color:var(--muted);
  font-size:10px;
  font-weight:400;
  text-decoration:none;
  cursor:pointer;
}

body.logged-in .project-delete-btn:hover{
  color:#ff8d8d;
  background:transparent;
}

body.logged-in .project-delete-btn:disabled{
  opacity:.45;
  cursor:default;
}

.project-card-link{
  text-decoration:none;
  align-items:center !important;
  min-height:94px;
  transition:border-color .15s ease, background .15s ease;
}

.project-card-link:hover{
  border-color:#353a49;
  background:#14171e;
}

.project-card-link h3{
  margin:0 0 7px !important;
  font-size:17px !important;
  font-weight:500 !important;
}

.project-card-link p{
  font-size:12px;
}

.project-arrow,
.history-item__arrow{
  color:var(--muted);
  font-size:16px;
}

.empty-state{
  border:1px dashed var(--border);
  border-radius:12px;
  padding:18px;
  color:var(--muted);
  font-size:13px;
}

.empty-state--small{
  padding:12px 14px;
}

.system-status{
  margin-top:16px;
}

body.logged-in .system-status{
  display:none !important;
}

.project-topbar{
  flex-wrap:nowrap;
}

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

.project-loading .status{
  background:transparent;
  border-color:var(--border);
  color:var(--muted);
}

.project-hero{
  padding:8px 0 28px;
  border-bottom:1px solid var(--border);
}

.project-title-row{
  display:flex;
  align-items:baseline;
  gap:12px;
  flex-wrap:wrap;
}

.project-title-row h1{
  font-size:34px !important;
  font-weight:400 !important;
}

.current-version{
  color:var(--muted);
  font-size:11px;
  font-weight:400;
}

.module-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  margin-top:22px;
}

.module-actions .btn{
  min-width:104px;
}

.module-actions button:disabled{
  opacity:.72;
  cursor:default;
}

.project-section{
  padding:28px 0;
  border-bottom:1px solid var(--border);
}

.history-grid,
.permissions-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:26px;
}

.history-list{
  gap:8px;
}

.history-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--panel);
}

.history-item__main{
  min-width:0;
}

.history-item__open{
  flex:1 1 auto;
  display:block;
  padding:0;
  border:0;
  background:transparent;
  color:inherit;
  text-align:left;
  font:inherit;
  cursor:pointer;
}

.history-item__open:hover .history-item__title,
.history-item__open:focus-visible .history-item__title{
  text-decoration:underline;
  text-underline-offset:3px;
}

.history-item__open:focus-visible{
  outline:2px solid currentColor;
  outline-offset:5px;
  border-radius:4px;
}

.history-item__title{
  margin-bottom:4px;
  font-size:13px;
  font-weight:500;
}

.history-item__title span{
  color:#fff;
}

.history-item .muted{
  font-size:11px;
}

.section-status{
  margin-top:12px;
  font-size:11px !important;
}

.invite-form{
  display:grid;
  grid-template-columns:minmax(220px,1.4fr) minmax(180px,.8fr) auto;
  gap:12px;
  align-items:end;
  padding:16px;
  margin-bottom:18px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--panel-2);
}

.invite-form .row{
  flex-wrap:nowrap;
}

.access-item{
  align-items:center !important;
  padding:12px 14px !important;
}

.access-person{
  min-width:0;
  flex:1;
}

.access-person .title{
  margin:0 0 3px !important;
  font-size:13px !important;
  font-weight:500;
}

body.project-home .item .meta{
  color:var(--muted);
  font-size:11px;
}

.access-actions select{
  width:auto;
  min-width:128px;
  padding:8px 10px;
}

body.project-home button.danger{
  border-color:#5a2a2f;
  color:#ff8989;
  background:transparent;
}

@media (max-width:860px){
  body.logged-in .project-list,
  .history-grid,
  .permissions-grid,
  .invite-form{
    grid-template-columns:1fr;
  }
  .section-heading--row{
    align-items:stretch;
  }
  .section-heading--row > button{
    align-self:flex-start;
  }
}

.history-primary-actions{
  justify-content:flex-end;
}
.history-item__actions{
  flex:0 0 auto;
  align-items:center;
}
.history-csv-btn{
  min-width:auto;
  padding:7px 10px;
  font-size:11px;
}
.history-delete-btn{
  min-width:auto;
  padding:7px 10px;
  font-size:11px;
}

/* V45 — Estados do projeto */
.state-form{display:grid;grid-template-columns:minmax(240px,1fr) 92px minmax(150px,190px) auto;gap:12px;align-items:end;padding:16px;margin-bottom:14px;border:1px solid var(--border);border-radius:14px;background:var(--panel-2)}
.state-form__name{min-width:0}.state-form__actions{flex-wrap:nowrap}.state-color-input{width:100%;min-width:64px;height:38px;padding:4px!important;cursor:pointer}.state-list{display:flex;flex-direction:column;gap:8px}.state-item{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:11px 13px;border:1px solid var(--border);border-radius:12px;background:var(--panel)}.state-item--archived{opacity:.55}.state-item__identity{display:flex;align-items:center;gap:10px;min-width:0}.state-swatch{width:13px;height:13px;flex:0 0 13px;border-radius:999px;background:var(--state-color,#6f7785);box-shadow:0 0 0 1px rgba(255,255,255,.22)}.state-item__name{font-size:13px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.state-item__identity .muted{font-size:11px}.state-item__actions{flex:0 0 auto}.state-item__actions .btn{min-height:30px!important;padding:5px 9px!important;font-size:11px}.state-list__archived-title{margin:12px 2px 2px;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.06em}
@media (max-width:860px){.state-form{grid-template-columns:1fr 100px 1fr}.state-form__name{grid-column:1/-1}.state-form__actions{grid-column:1/-1}.state-item{align-items:flex-start;flex-direction:column}.state-item__actions{width:100%}}


/* V47 — publicação oficial por escopo congelado */
.release-dialog{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;padding:24px}.release-dialog.hidden{display:none}.release-dialog__backdrop{position:absolute;inset:0;background:rgba(0,0,0,.55)}.release-dialog__panel{position:relative;width:min(560px,100%);max-height:min(760px,calc(100vh - 48px));overflow:auto;padding:20px;border:1px solid var(--border);border-radius:16px;background:var(--panel);box-shadow:0 18px 60px rgba(0,0,0,.35)}.release-dialog__heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:18px}.release-dialog__heading h3{margin:0 0 4px;font-size:18px}.release-dialog__heading p{margin:0}.release-form{display:flex;flex-direction:column;gap:16px}.release-form__field{display:flex;flex-direction:column;gap:8px}.release-form__field>label:first-child{font-size:12px;font-weight:600}.release-scope-option{display:flex;align-items:flex-start;gap:10px;padding:11px 12px;border:1px solid var(--border);border-radius:12px;background:var(--panel-2);cursor:pointer}.release-scope-option input{margin-top:3px}.release-scope-option span{display:flex;flex-direction:column;gap:2px}.release-scope-option strong{font-size:13px}.release-scope-option small{font-size:11px;color:var(--muted);line-height:1.35}.release-form__hint{margin:0;font-size:11px}.release-form__actions{justify-content:flex-end;padding-top:4px}.release-form textarea{resize:vertical;min-height:76px}

.release-form select[multiple]{min-height:132px;padding:7px}.release-form select[multiple] option{padding:7px 8px}


/* V48 — distribuição de versões oficiais */
.release-distribution{margin-top:28px;padding-top:22px;border-top:1px solid var(--border)}
.release-distribution__heading{margin-bottom:14px}.release-distribution__heading h3{margin:0 0 4px;font-size:15px}.release-distribution__heading p{margin:0;max-width:680px}
.distribution-form{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin:12px 0 18px;padding:16px;border:1px solid var(--border);border-radius:14px;background:var(--panel-2)}
.distribution-form>div{display:flex;flex-direction:column;gap:7px}.distribution-form label{font-size:12px;font-weight:600}.distribution-detail{grid-column:1/-1}.distribution-form__actions{grid-column:1/-1;justify-content:flex-end}
.distribution-piece-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:6px;max-height:220px;overflow:auto;padding:8px;border:1px solid var(--border);border-radius:10px;background:var(--panel)}
.distribution-piece-option{display:flex;align-items:center;gap:7px;padding:6px 7px;border-radius:8px;font-size:12px;font-weight:400!important}.distribution-piece-option:hover{background:var(--panel-2)}
.release-recipient-item--revoked{opacity:.62}.release-recipient-item .meta{margin-top:3px}
@media (max-width:760px){.distribution-form{grid-template-columns:1fr}}

.access-basic-hint{grid-column:1/-1;margin:0;max-width:760px;font-size:12px;line-height:1.45}


/* V50 — versões oficiais recebidas */
.home-section-note { margin: 4px 0 0; }
.received-release-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  margin-bottom: 5px;
  opacity: .56;
}
.received-release-link { border-style: solid; }
.release-page { max-width: 980px; }
.release-back-link {
  display: inline-block;
  margin-bottom: 7px;
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  opacity: .68;
}
.release-back-link:hover { opacity: 1; }
.release-hero h1 { margin: 4px 0 8px; }
.release-notes {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line, #dedede);
  white-space: pre-wrap;
}
.release-section-heading { align-items: flex-end; }
.release-count-pill {
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line, #dedede);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.release-piece-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.release-piece-card {
  border: 1px solid var(--line, #dedede);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--panel, #fff);
}
.release-piece-code { font-weight: 700; }
.release-piece-name {
  margin-top: 5px;
  font-size: 13px;
  opacity: .68;
}

/* V51 — visualização congelada da release distribuída */
.release-page{max-width:1180px}
.release-visual-section{padding-bottom:30px}
.release-plants{display:flex;flex-direction:column;gap:18px}
.release-plant-card{border:1px solid var(--line,#dedede);border-radius:14px;background:var(--panel,#fff);overflow:hidden}
.release-plant-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 14px;border-bottom:1px solid var(--line,#dedede)}
.release-plant-heading>div{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}
.release-plant-heading strong{font-size:13px}.release-plant-heading span{font-size:11px;opacity:.58}
.release-map-shell{overflow:auto;background:rgba(127,127,127,.055);padding:16px}
.release-map-stage{position:relative;width:max-content;max-width:100%;margin:0 auto;line-height:0}
.release-map-image{display:block;max-width:100%;max-height:72vh;width:auto;height:auto;border-radius:4px;box-shadow:0 2px 14px rgba(0,0,0,.09)}
.release-map-markers{position:absolute;inset:0;pointer-events:none}
.release-map-marker{position:absolute;z-index:2;display:flex;align-items:center;gap:5px;transform:translate(-50%,-50%);padding:0;border:0;background:transparent;color:inherit;pointer-events:auto;cursor:pointer;white-space:nowrap}
.release-map-marker__pin{display:block;width:11px;height:11px;border:2px solid #fff;border-radius:999px;background:#222;box-shadow:0 1px 4px rgba(0,0,0,.35);transform:rotate(var(--piece-angle,0deg))}
.release-map-marker__label{display:block;padding:3px 6px;border:1px solid rgba(0,0,0,.18);border-radius:999px;background:rgba(255,255,255,.94);color:#161616;font-size:10px;font-weight:700;line-height:1.1;box-shadow:0 1px 4px rgba(0,0,0,.12)}
.release-map-marker:hover,.release-map-marker.is-active{z-index:8}
.release-map-marker:hover .release-map-marker__label,.release-map-marker.is-active .release-map-marker__label{outline:2px solid currentColor;outline-offset:2px}
.release-map-marker.is-active .release-map-marker__pin{transform:rotate(var(--piece-angle,0deg)) scale(1.35)}
.release-piece-list{grid-template-columns:repeat(auto-fill,minmax(220px,1fr))}
.release-piece-card{padding:0;overflow:hidden;transition:border-color .15s ease,box-shadow .15s ease}
.release-piece-card.is-active{border-color:currentColor;box-shadow:0 0 0 2px currentColor}
.release-piece-card__focus{display:block;width:100%;padding:0;border:0;background:transparent;color:inherit;text-align:left;cursor:pointer}
.release-piece-art{display:flex;align-items:center;justify-content:center;aspect-ratio:4/3;overflow:hidden;background:rgba(127,127,127,.07);border-bottom:1px solid var(--line,#dedede)}
.release-piece-art img{display:block;width:100%;height:100%;object-fit:contain}
.release-piece-art--empty span{font-size:11px;opacity:.5}
.release-piece-card__body{padding:13px 15px 15px}
.release-piece-card__focus:hover .release-piece-code{text-decoration:underline}
.release-plant-card--missing .empty-state{margin:14px}
@media (max-width:760px){.release-map-shell{padding:8px}.release-map-marker__label{font-size:9px}.release-piece-list{grid-template-columns:1fr 1fr}}
@media (max-width:520px){.release-piece-list{grid-template-columns:1fr}}

/* V51.1 — versão oficial recebida dentro da home para evitar dependência de rota estática nova */
.release-inline-top { margin: 4px 0 14px; }
#receivedReleaseView:not(.hidden) { display: block; }

/* V117 — controles de acesso da distribuição de emissões */
.release-recipient-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.release-recipient-access-mode { min-width:150px; }
