/* ==========================================================================
   Componentes
   ========================================================================== */

/* --- Painel de apoio (hairline, sem sombra) --------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: var(--s4);
}
.panel--quiet { background: transparent; border-style: dashed; }
.panel--sunken { background: var(--bg-sunken); border-color: transparent; }
.panel__head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); }
.panel__title { font-size: var(--fs-17); font-weight: 600; }
.panel__aside { margin-left: auto; flex: 0 0 auto; }

/* O único objeto elevado da tela */
.lift {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lift);
  box-shadow: var(--sh-lift);
}

.section { display: flex; flex-direction: column; gap: var(--s3); }
.section__head { display: flex; align-items: baseline; gap: var(--s3); }
.section__head h2 { flex: 1 1 auto; min-width: 0; }

/* --- Botões: retângulo de placa, não pílula --------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 38px; padding: 0 var(--s4);
  border-radius: var(--r-plate);
  font-family: var(--font-sign);
  font-size: var(--fs-15); font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
  text-decoration: none;
  transition: background var(--t1) var(--ease), border-color var(--t1) var(--ease),
              color var(--t1) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn--primary { background: var(--forest); color: var(--on-forest); }
.btn--primary:hover { background: var(--forest-2); color: var(--on-forest); }
.btn--brass { background: var(--brass); color: #fff; }
.btn--brass:hover { background: #92700F; color: #fff; }
.btn--ghost { border-color: var(--line-2); color: var(--text); }
.btn--ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn--quiet { color: var(--text-2); }
.btn--quiet:hover { background: var(--bg-sunken); color: var(--text); }
.btn--onforest { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.28); }
.btn--onforest:hover { background: rgba(255,255,255,.2); color: #fff; }
.btn--danger { color: var(--rust); border-color: rgba(154,58,43,.4); }
.btn--danger:hover { background: var(--rust-2); color: var(--rust); }
.btn--sm { min-height: 30px; padding: 0 var(--s3); font-size: var(--fs-13); }
.btn--block { width: 100%; }

.iconbtn {
  position: relative;
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--r-plate); color: var(--text-2);
  text-decoration: none;
  transition: background var(--t1) var(--ease), color var(--t1) var(--ease);
}
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn:hover { background: var(--bg-sunken); color: var(--text); }
.iconbtn--onforest { color: var(--forest-4); }
.iconbtn--onforest:hover { background: rgba(255,255,255,.12); color: #fff; }
.iconbtn__count {
  position: absolute; top: 1px; right: 0;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: var(--r-pill);
  background: var(--rust); color: #fff;
  font-family: var(--font-sign);
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}

/* --- Etiquetas -------------------------------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: var(--r-plate);
  background: var(--bg-sunken); color: var(--text-2);
  font-family: var(--font-sign); font-size: var(--fs-12); font-weight: 600;
  white-space: nowrap; text-decoration: none;
}
.tag svg { width: 13px; height: 13px; }
.tag--line { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); }
.tag--brass { background: var(--brass-4); color: #7A5C11; }
.tag--forest { background: var(--forest-5); color: var(--forest); }
.tag--rust { background: var(--rust-2); color: var(--rust); }
.tag--onforest { background: rgba(255,255,255,.14); color: #fff; }
.tag--dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.st-planejado  { background: var(--st-planejado-bg);  color: var(--st-planejado-fg); }
.st-reservado  { background: var(--st-reservado-bg);  color: var(--st-reservado-fg); }
.st-confirmado { background: var(--st-confirmado-bg); color: var(--st-confirmado-fg); }
.st-concluido  { background: var(--st-concluido-bg);  color: var(--st-concluido-fg); }
.st-cancelado  { background: var(--st-cancelado-bg);  color: var(--st-cancelado-fg); }

/* --- Filtros ---------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 32px; padding: 0 11px;
  border-radius: var(--r-plate);
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--line);
  font-family: var(--font-sign); font-size: var(--fs-13); font-weight: 600;
  white-space: nowrap; text-decoration: none;
  transition: border-color var(--t1) var(--ease), background var(--t1) var(--ease),
              color var(--t1) var(--ease);
}
.chip svg { width: 15px; height: 15px; opacity: .75; }
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--forest); border-color: var(--forest); color: var(--on-forest);
}
.chip[aria-pressed="true"] svg { opacity: 1; }
.chip__count { font-variant-numeric: tabular-nums; opacity: .7; }

.chiprow {
  display: flex; gap: var(--s2); overflow-x: auto;
  padding-bottom: var(--s1);
  scrollbar-width: none; -ms-overflow-style: none;
}
.chiprow::-webkit-scrollbar { display: none; }
.chiprow > * { flex: 0 0 auto; }
.chiprow--wrap { flex-wrap: wrap; overflow: visible; }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: var(--r-plate);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg__btn {
  padding: 5px 12px; border-radius: 2px; white-space: nowrap;
  font-size: var(--fs-13); font-weight: 600; color: var(--text-2);
}
.seg__btn[aria-pressed="true"] { background: var(--surface); color: var(--forest); }

/* --- Grade de dados: hairline, sem sombra, número tabular ------------- */
.data-grid {
  display: grid; gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  overflow: hidden;
}
.data-cell {
  background: var(--surface);
  padding: var(--s3) var(--s4);
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0; text-decoration: none; color: inherit;
}
.data-cell__value {
  font-family: var(--font-sign); font-size: var(--fs-26); font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.05; letter-spacing: -0.01em; color: var(--text);
}
.data-cell__value--sm { font-size: var(--fs-20); }
.data-cell__label { font-family: var(--font-text); font-size: var(--fs-13); color: var(--text-2); }
.data-cell__note { font-family: var(--font-text); font-size: var(--fs-12); color: var(--text-3); }
.data-cell--brass .data-cell__value { color: var(--brass); }
.data-cell--rust .data-cell__value { color: var(--rust); }

/* --- Progresso -------------------------------------------------------- */
.bar { height: 3px; background: var(--mist-2); overflow: hidden; }
.bar__fill { height: 100%; background: var(--forest-2); transition: width var(--t3) var(--ease); }
.bar--brass .bar__fill { background: var(--brass); }
.bar--rust .bar__fill { background: var(--rust); }
.bar--onforest { background: rgba(255,255,255,.22); }
.bar--onforest .bar__fill { background: var(--brass-2); }

.ring { width: 38px; height: 38px; flex: 0 0 auto; position: relative; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring__track { stroke: var(--mist-2); }
.ring__fill { stroke: var(--forest-2); transition: stroke-dashoffset var(--t3) var(--ease); }
.ring__label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-sign);
  font-size: var(--fs-12); font-weight: 700; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* ======================================================================
   O TRILHO — elemento central do produto
   ====================================================================== */
.tl { display: flex; flex-direction: column; }

.tl-row {
  display: grid;
  grid-template-columns: 44px 26px minmax(0, 1fr);
  align-items: stretch;
}
@media (min-width: 768px) { .tl-row { grid-template-columns: 50px 28px minmax(0, 1fr); } }

.tl-row__time {
  font-family: var(--font-sign); font-size: var(--fs-15); font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right; padding: 14px var(--s2) 0 0;
  color: var(--text);
}
.tl-row__time span { display: block; font-size: var(--fs-12); font-weight: 400; color: var(--text-4); }
.tl-row--leg .tl-row__time {
  font-size: var(--fs-13); font-weight: 400; color: var(--text-3); padding-top: 9px;
}

/* Trilho: duas linhas paralelas, contínuas ao longo do dia */
.tl-rail { position: relative; }
.tl-rail::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 9px; width: 5px;
  background: linear-gradient(90deg,
    var(--rail) 0 1px, transparent 1px 4px, var(--rail) 4px 5px);
}
.tl-row:first-child .tl-rail::before { top: 19px; }
.tl-row:last-child .tl-rail::before { bottom: calc(100% - 19px); }

/* Dormentes: só no trecho em movimento */
.tl-row--leg .tl-rail::after {
  content: ""; position: absolute; top: 3px; bottom: 3px; left: 5px; width: 13px;
  background: repeating-linear-gradient(180deg, var(--wood-3) 0 2px, transparent 2px 8px);
}

/* Estação */
.station {
  position: absolute; left: 5px; top: 14px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--forest-2), 0 0 0 5px var(--bg);
  z-index: 1;
}
.station--done { background: var(--forest-2); }
.station--brass { box-shadow: 0 0 0 2px var(--brass), 0 0 0 5px var(--bg); }
.station--off { box-shadow: 0 0 0 2px var(--ink-4), 0 0 0 5px var(--bg); }

.tl-row__body { min-width: 0; padding: var(--s2) 0 var(--s2) var(--s2); }
.tl-row--leg .tl-row__body { padding-top: 4px; padding-bottom: 4px; }

/* --- Trecho (deslocamento) -------------------------------------------- */
.leg {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2);
  font-family: var(--font-sign); font-size: var(--fs-13);
  color: var(--wood); font-weight: 600;
  padding: 3px 0;
}
.leg svg { width: 16px; height: 16px; flex: 0 0 auto; }
.leg__num { font-variant-numeric: tabular-nums; }
.leg__label { font-weight: 400; color: var(--wood-2); }
.leg__aprox {
  font-family: var(--font-text); font-style: italic; font-weight: 400;
  font-size: var(--fs-12); color: var(--text-3);
}
.leg--tight { color: var(--rust); }

/* --- Placa de estação (atividade) ------------------------------------- */
.plate {
  display: flex; align-items: flex-start; gap: var(--s3);
  width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-2);
  border-radius: var(--r-plate);
  padding: var(--s3);
  text-decoration: none; color: inherit;
  transition: border-color var(--t1) var(--ease), background var(--t1) var(--ease);
}
.plate:hover { border-color: var(--line-2); background: #fff; }
.plate--highlight { border-left-color: var(--brass); }
.plate--next { border-left-color: var(--forest-2); border-color: var(--forest-4); }
.plate--done { background: transparent; border-left-color: var(--forest-3); }
.plate--done .plate__name { color: var(--text-2); }
.plate--off { background: transparent; border-left-color: var(--ink-4); opacity: .72; }
.plate--off .plate__name { text-decoration: line-through; text-decoration-color: var(--rust); }

.plate__glyph {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: grid; place-items: center;
  color: var(--forest); background: var(--forest-5);
  border-radius: var(--r-plate);
}
.plate__glyph svg { width: 18px; height: 18px; }
.plate--highlight .plate__glyph { background: var(--brass-4); color: var(--brass); }
.plate--off .plate__glyph { background: var(--bg-sunken); color: var(--text-3); }

.plate__main { min-width: 0; flex: 1 1 auto; }
.plate__name {
  display: block;
  font-family: var(--font-sign); font-size: var(--fs-17); font-weight: 600; line-height: 1.2;
}
.plate__sub {
  display: block; margin-top: 2px;
  font-family: var(--font-text); font-size: var(--fs-13); color: var(--text-2);
}
.plate__tags { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s2); }
.plate__aside {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--s2);
  padding-top: 3px; color: var(--text-3);
}
.plate__dur {
  font-family: var(--font-sign); font-size: var(--fs-13); font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--text-2);
}
.plate__aside svg { width: 16px; height: 16px; }

/* --- Linha de lista genérica ------------------------------------------ */
.row-item {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; text-align: left;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-plate);
  text-decoration: none; color: inherit;
  transition: border-color var(--t1) var(--ease), background var(--t1) var(--ease);
}
.row-item:hover { border-color: var(--line-2); background: #fff; }
.row-item__glyph {
  width: 28px; height: 28px; flex: 0 0 auto;
  display: grid; place-items: center; color: var(--forest);
  background: var(--forest-5); border-radius: var(--r-plate);
}
.row-item__glyph svg { width: 17px; height: 17px; }
.row-item__title { display: block; font-weight: 600; font-size: var(--fs-15); line-height: 1.25; }
.row-item__sub { display: block; font-family: var(--font-text); font-size: var(--fs-13); color: var(--text-2); }
.row-item__aside { margin-left: auto; flex: 0 0 auto; text-align: right; }

/* Lista corrida: hairline entre linhas, sem cartão por item */
.ruled { display: flex; flex-direction: column; }
.ruled > * + * { border-top: 1px solid var(--line); }
.ruled--boxed {
  border: 1px solid var(--line); border-radius: var(--r-panel);
  overflow: hidden; background: var(--surface);
}
.ruled--boxed .row-item, .ruled--boxed .check { border: 0; border-radius: 0; }

/* --- Lista de definição ----------------------------------------------- */
.dl { display: grid; grid-template-columns: minmax(88px, auto) minmax(0, 1fr); gap: var(--s2) var(--s4); }
.dl dt { font-family: var(--font-text); font-size: var(--fs-13); color: var(--text-3); }
.dl dd { margin: 0; font-size: var(--fs-15); }

/* --- Formulário ------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field__label { font-family: var(--font-text); font-size: var(--fs-13); color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px var(--s3);
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-plate);
  font-family: var(--font-sign); font-size: var(--fs-15); color: var(--text);
  transition: border-color var(--t1) var(--ease), box-shadow var(--t1) var(--ease);
}
.input::placeholder, .textarea::placeholder {
  color: var(--text-4); font-family: var(--font-text); font-style: italic;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--rail); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--forest-2); box-shadow: 0 0 0 3px var(--forest-5);
}
.textarea { min-height: 72px; resize: vertical; font-family: var(--font-text); line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22%2366766B%22 stroke-width=%222%22 stroke-linecap=%22round%22%3E%3Cpath d=%22M6 9l6 6 6-6%22/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}

.check {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: 9px var(--s3); width: 100%; text-align: left;
  background: transparent; border: 0;
  transition: background var(--t1) var(--ease);
}
.check:hover { background: var(--bg-sunken); }
.check__box {
  width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px;
  border: 1px solid var(--line-2); border-radius: 2px;
  background: var(--surface);
  display: grid; place-items: center; color: transparent;
  transition: background var(--t1) var(--ease), border-color var(--t1) var(--ease);
}
.check__box svg { width: 12px; height: 12px; }
.check[aria-pressed="true"] .check__box { background: var(--forest-2); border-color: var(--forest-2); color: #fff; }
.check[aria-pressed="true"] .check__text { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--forest-4); }
.check__text { font-family: var(--font-text); font-size: var(--fs-15); line-height: 1.45; }

.switch {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; text-align: left; padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-plate);
  background: var(--surface);
}
.switch__track {
  width: 38px; height: 22px; flex: 0 0 auto; border-radius: var(--r-pill);
  background: var(--mist-2); position: relative;
  transition: background var(--t2) var(--ease);
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(22,38,29,.2);
  transition: transform var(--t2) var(--ease);
}
.switch[aria-pressed="true"] .switch__track { background: var(--forest-2); }
.switch[aria-pressed="true"] .switch__track::after { transform: translateX(16px); }

/* --- Aviso ------------------------------------------------------------ */
.notice {
  display: flex; gap: var(--s3);
  padding: var(--s3);
  border-radius: var(--r-plate);
  border-left: 3px solid var(--brass);
  background: var(--brass-4);
}
.notice__body { min-width: 0; }
.notice__title { font-family: var(--font-sign); font-size: var(--fs-15); font-weight: 600; }
.notice__text { font-family: var(--font-text); font-size: var(--fs-13); color: var(--text-2); margin-top: 1px; }
.notice > svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; color: var(--brass); }
.notice--rust { background: var(--rust-2); border-left-color: var(--rust); }
.notice--rust > svg { color: var(--rust); }
.notice--info { background: #E7EFF3; border-left-color: #2F6F8F; }
.notice--info > svg { color: #2F6F8F; }
.notice--ok { background: var(--forest-5); border-left-color: var(--forest-2); }
.notice--ok > svg { color: var(--forest-2); }
.notice__link { display: inline-block; margin-top: 5px; font-size: var(--fs-13); font-weight: 600; }

/* --- Folha (mobile) / diálogo (tablet+) ------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(22, 38, 29, .46);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-height: 92dvh;
  background: var(--bg); color: var(--text);
  border-radius: var(--r-lift) var(--r-lift) 0 0;
  box-shadow: var(--sh-over);
  display: flex; flex-direction: column; overflow: hidden;
  animation: sheet-in var(--t3) var(--ease);
}
/* Só transform: se o navegador suspender animações, a folha segue visível */
@keyframes sheet-in { from { transform: translateY(12px); } to { transform: none; } }

.sheet__grab { padding: 8px 0 2px; display: grid; place-items: center; flex: 0 0 auto; }
.sheet__grab i { width: 34px; height: 3px; border-radius: 2px; background: var(--line-2); display: block; }
.sheet__head {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sheet__body { overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.sheet__foot {
  flex: 0 0 auto; display: flex; gap: var(--s2);
  padding: var(--s3) var(--s4) calc(var(--s4) + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet__foot .btn { flex: 1 1 auto; }

@media (min-width: 768px) {
  .sheet-backdrop { align-items: center; padding: var(--s5); }
  .sheet { max-width: 600px; border-radius: var(--r-lift); max-height: 86dvh; }
  .sheet__grab { display: none; }
  .sheet__foot { padding-bottom: var(--s4); }
  .sheet__foot .btn { flex: 0 1 auto; }
  .sheet__foot .btn--primary { flex: 1 1 auto; }
}

/* --- Aviso de ação --------------------------------------------------- */
.toast-root {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottomnav-h) + var(--safe-b) + 12px);
  z-index: 300; display: flex; flex-direction: column; gap: var(--s2);
  width: min(420px, calc(100vw - 24px)); pointer-events: none;
}
@media (min-width: 768px) { .toast-root { bottom: 18px; left: auto; right: 18px; transform: none; } }
.toast {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s4); border-radius: var(--r-plate);
  background: var(--ink); color: var(--on-forest);
  box-shadow: var(--sh-lift);
  font-size: var(--fs-15);
  animation: toast-in var(--t3) var(--ease);
}
.toast svg { width: 17px; height: 17px; color: var(--brass-2); flex: 0 0 auto; }
@keyframes toast-in { from { transform: translateY(8px); } to { transform: none; } }
.toast--out { animation: toast-out var(--t2) var(--ease) both; }
@keyframes toast-out { to { transform: translateY(6px); opacity: 0; } }

/* --- Vazio: convite, não lamento ------------------------------------- */
.empty { display: grid; place-items: center; gap: var(--s2); padding: var(--s7) var(--s4); text-align: center; }
.empty svg { width: 26px; height: 26px; color: var(--rail); }
.empty__text { font-family: var(--font-text); font-size: var(--fs-15); color: var(--text-2); max-width: 44ch; }

/* --- Carregando ------------------------------------------------------- */
.skel {
  background: linear-gradient(100deg, var(--mist-2) 30%, var(--mist) 50%, var(--mist-2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -20% 0; } }

/* --- Pilula de sincronizacao ------------------------------------------ */
.syncpill { min-height: 28px; cursor: pointer; }
@media (max-width: 479px) { .syncpill__text { display: none; } }
