/* ==========================================================================
   Gestão Náutica — estilos do app sobre os tokens (tokens.css). Mobile-first.
   Seções: 1 base · 2 shell (topbar/tabbar/main) · 3 mensagens · 4 cards e badges
   5 componente de prazo (.due-item) · 6 planos de manutenção · 7 tabelas e formulários
   8 Início · 9 calendário · 10 login · 11 diálogos e estados vazios · 12 mobile
   ========================================================================== */

/* 1 ── base ------------------------------------------------------------- */
html { color-scheme: light dark; }
body { font-family: var(--font); color: var(--text); background: var(--bg); }
h2 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: .75rem; }
h3 { font-size: 1.1rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
h3 small { font-weight: 400; font-size: .85rem; margin-left: .5rem; }
h4 { font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); margin-bottom: .35rem; }
h4 a { color: inherit; text-decoration: none; }
a { color: var(--sea-700); }
small, .muted small { font-size: .85rem; }
.num, .big { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.neg { color: var(--due); } .pos { color: var(--ok); } .muted { color: var(--text-2); }
a:focus-visible, button:focus-visible, [role=button]:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--sea-500); outline-offset: 2px; }

/* 2 ── shell: cabeçalho casco, nav, barra inferior ---------------------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--topbar); border-bottom: 3px solid #fff; box-shadow: 0 1px 0 var(--hull-300); }
.topbar .inner { max-width: 1080px; margin: auto; height: 56px; display: flex; align-items: center; gap: 1rem; padding: 0 16px; }
.topbar .brand { color: var(--topbar-text); display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.topbar .brand svg { height: 22px; width: auto; display: block; }
.topbar .brand .boat-name { font-weight: 600; font-size: .95rem; opacity: .95; }
.topbar nav.desktop { display: none; margin-left: auto; gap: .25rem; }
.topbar nav.desktop a { color: var(--topbar-text); text-decoration: none; padding: .5rem .8rem; border-radius: 8px; font-weight: 500; font-size: .95rem; }
.topbar nav.desktop a[aria-current], .topbar nav.desktop a:hover { background: rgba(255,255,255,.18); }
.topbar .user { margin-left: auto; }
.topbar details.dropdown summary { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.4); color: var(--topbar-text); height: 40px; padding: 0 .9rem; display: inline-flex; align-items: center; border-radius: 999px; }
.topbar details.dropdown ul { min-width: 240px; }
.topbar details.dropdown li small { display: block; padding: .4rem 1rem; color: var(--text-2); }
.topbar details.dropdown form { margin: 0; }
.topbar details.dropdown button { margin: 0; width: 100%; border: 0; text-align: left; background: transparent; color: var(--text); padding: .5rem 1rem; }

.tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--text-2); text-decoration: none; min-height: var(--tap); }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current] { color: var(--sea-700); font-weight: 700; }

main.container { padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); max-width: 1080px; }
@media (min-width: 768px) {
  .tabbar { display: none; }
  .topbar nav.desktop { display: flex; }
  main.container { padding: 24px 24px 40px; }
}

/* 3 ── mensagens (toast sólido, legível ao sol) ------------------------- */
.msg { padding: .75rem 1rem; margin-bottom: 1rem; border-radius: 10px; color: #fff; background: var(--msg-neutral); font-weight: 500; }
.msg.success { background: var(--msg-ok); } .msg.error { background: var(--msg-due); } .msg.info { background: var(--msg-info); }

/* 4 ── cards de resumo, ações, badges ----------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.cards article { margin: 0; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.cards .big { display: block; font-size: 1.9rem; font-weight: 700; line-height: 1.1; margin: .15rem 0 .35rem; }
.cards .big.sm, .big.sm { font-size: 1.3rem; }
.cards article.hero { grid-column: 1 / -1; border-left: 5px solid var(--sea-700); }
.cards article small { display: block; line-height: 1.4; }
.cards article.health-vermelho { border-left: 5px solid var(--due); } .cards article.health-amarelo, .cards article.health-parcial { border-left: 5px solid var(--warn); }
.cards article.health-verde { border-left: 5px solid var(--ok); } .cards article.health-cinza { border-left: 5px solid var(--hull-500); }
.alert-card { border-left: 5px solid var(--due); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; margin: 0; }
.actions button, .actions [role=button] { margin: 0; }
.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; vertical-align: middle; }
a.badge { text-decoration: none; }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn); }
.badge.due { color: var(--due); background: var(--due-bg); border-color: var(--due); }
.badge.credit { color: var(--credit); background: var(--credit-bg); border-color: var(--credit); }
.badge.nodata { color: var(--nodata); background: var(--nodata-bg); border-color: var(--line); }
.badge.charter { color: var(--teak-700); background: var(--teak-100); border-color: var(--teak-700); }
.recur { display: inline-block; white-space: nowrap; font-size: .78rem; font-weight: 500; color: var(--sea-700); background: var(--sea-100); border-radius: 999px; padding: 1px 8px; }
a.danger-link, button.danger-link { color: var(--due); background: transparent; border: 0; padding: .5rem .25rem; font-weight: 500; text-decoration: underline; min-height: 0; }

/* 5 ── componente único de prazo: vencimentos, contas, reservas, rodízio - */
.due-list { margin-bottom: 1rem; }
.due-item { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--hull-300); border-radius: var(--r); padding: .7rem 1rem; margin-bottom: .5rem; }
.due-item.due { border-left-color: var(--due); } .due-item.warn { border-left-color: var(--warn); } .due-item.ok { border-left-color: var(--ok); }
.due-item.nodata { border-left-color: var(--hull-300); } .due-item.charter { border-left-color: var(--teak-700); }
.due-item .name { grid-column: 1; grid-row: 1; font-weight: 600; } .due-item .name a { color: var(--text); text-decoration: none; }
.due-item .when { grid-column: 1; grid-row: 2; color: var(--text-2); font-size: .9rem; line-height: 1.5; }
.due-item .go { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: .35rem; align-items: center; justify-self: end; }
.due-item .go form { margin: 0; display: inline; }
.due-item .go button, .due-item .go [role=button] { margin: 0; min-height: 44px; padding: 0 .9rem; }
.due-item .amount { grid-column: 2; grid-row: 1; font-weight: 700; font-size: 1.05rem; justify-self: end; }
.due-item.expense .go { grid-row: 2; }

/* 6 ── planos de manutenção agrupados + chips --------------------------- */
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .35rem; margin-bottom: .75rem; -webkit-overflow-scrolling: touch; }
.chips a { flex: 0 0 auto; min-height: 40px; padding: 0 .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; display: inline-flex; align-items: center; font-weight: 500; font-size: .9rem; }
.chips a[aria-current] { background: var(--chip-active); color: var(--chip-active-text); border-color: var(--chip-active); }
.plan-group { margin-bottom: 1.25rem; }
.plan-group summary, .plan-group h4 { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; cursor: pointer; }
.plan-group summary::after { display: none; }
.plan-group summary h4 { margin: 0; flex: 1; }
.plan { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--hull-500); border-radius: var(--r); padding: .7rem 1rem; margin-bottom: .5rem; }
.plan.due { border-left-color: var(--due); } .plan.warn { border-left-color: var(--warn); } .plan.ok { border-left-color: var(--ok); } .plan.nodata { border-left-color: var(--hull-300); }
.plan .name { grid-column: 1; grid-row: 1; font-weight: 600; } .plan .name a { color: var(--text); text-decoration: none; }
.plan .meta { grid-column: 1; grid-row: 2; color: var(--text-2); font-size: .9rem; line-height: 1.5; }
.plan .go { grid-column: 2; grid-row: 1 / span 2; justify-self: end; margin: 0; min-height: 44px; padding: 0 1rem; width: auto; }
.plan details { display: inline; } .plan details summary { display: inline; cursor: pointer; } .plan details summary::after { display: none; }

/* 7 ── tabelas e formulários ------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { font-size: .95rem; }
table td, table th { vertical-align: middle; padding: .6rem .5rem; }
table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); }
.table-cards td { background: transparent; }
label { font-weight: 500; }
input, select, textarea { min-height: var(--tap); }
button, [role=button] { min-height: var(--tap); font-weight: 600; }
button.outline, [role=button].outline { font-weight: 500; }
form .actions { margin-top: .5rem; }
.inline-form { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.inline-form label, .inline-form input, .inline-form select { margin: 0; }
form.sections { max-width: 720px; }
fieldset.section { border: 1px solid var(--line); border-radius: var(--r); padding: .5rem 1rem 1rem; margin: 0 0 .75rem; background: var(--surface); }
fieldset.section legend { display: block; width: 100%; font-weight: 700; padding: 0 .4rem; font-size: 1rem; margin-bottom: .5rem; }
label.check { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); margin: 0; font-weight: 400; }
label.check span { flex: 1 1 auto; }
label.check input { margin: 0; width: 22px; height: 22px; min-height: 0; flex: 0 0 22px; box-sizing: border-box; }
label.check input[type=checkbox] { border-radius: 5px; }
.checklist { display: grid; gap: .1rem; }
label.file { display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); padding: 0 1rem; border: 1px dashed var(--hull-300); border-radius: var(--r); cursor: pointer; font-weight: 500; }
label.file input { display: none; }
.month-nav { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.month-nav h2 { margin: 0; } .month-nav [role=button] { min-height: 40px; padding: 0 .9rem; }
.qr img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.qr textarea { font-size: .7rem; }
details summary small { color: var(--sea-700); }
.stepper { display: flex; gap: .25rem; list-style: none; padding: 0; margin: .5rem 0 1rem; overflow-x: auto; mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); }
.stepper li { flex: 1 0 auto; padding: .4rem .7rem; border-radius: 999px; background: var(--hull-50); color: var(--text-2); font-size: .85rem; font-weight: 500; border: 1px solid var(--line); white-space: nowrap; }
.stepper li.current { background: var(--teak-100); color: var(--teak-700); border-color: var(--teak-700); font-weight: 700; }

/* 8 ── Início ----------------------------------------------------------- */
.home-hero { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: .25rem 0 1rem; flex-wrap: wrap; }
.home-hero h2 { margin: 0; } .home-hero .date { color: var(--text-2); }
.big-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.big-actions a { min-height: 96px; display: flex; flex-direction: column; justify-content: flex-end; gap: .35rem; padding: 1rem; border-radius: var(--r); text-decoration: none; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--line); }
.big-actions a svg { width: 28px; height: 28px; color: var(--sea-700); }
.big-actions a small { font-weight: 400; opacity: .8; }
.big-actions a.primary { background: var(--sea-700); color: var(--pico-primary-inverse); border-color: var(--sea-700); }
.big-actions a.primary svg { color: var(--pico-primary-inverse); }
.big-actions a.charter { background: var(--teak-100); border-color: var(--teak-700); } .big-actions a.charter svg { color: var(--teak-700); }
@media (min-width: 768px) { .big-actions { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }
.menu-list { list-style: none; padding: 0; margin: 0 0 1rem; } .menu-list li { list-style: none; margin: 0; padding: 0; }
.menu-list li a { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); padding: .6rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: .4rem; text-decoration: none; color: var(--text); font-weight: 500; }
.menu-list li a::after { content: "›"; color: var(--text-2); }

/* 9 ── calendário ------------------------------------------------------- */
.cal { table-layout: fixed; }
.cal td { height: 72px; vertical-align: top; padding: .2rem; border: 1px solid var(--line); }
.cal td.out { opacity: .4; } .cal td.holiday { background: var(--sand); }
.cal .day { font-size: .8rem; font-weight: 600; }
.cal td.today .day { background: var(--sea-700); color: var(--pico-primary-inverse); border-radius: 50%; width: 1.6rem; height: 1.6rem; display: inline-flex; align-items: center; justify-content: center; }
.cal .hol { display: inline-block; font-size: .72rem; font-weight: 500; color: var(--teak-700); margin-left: .2rem; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.ev { display: block; font-size: .8rem; padding: .1rem .3rem; margin-top: .15rem; border-radius: 4px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.partner { background: var(--sea-100); color: var(--sea-700); } .ev.charter { background: var(--teak-100); color: var(--teak-700); }
.ev.maint { background: var(--hull-200); color: var(--text); } .ev.hol { background: var(--sand); color: var(--teak-700); }
span.ev { display: inline-block; }
@media (min-width: 768px) { .cal td { height: 92px; } }

/* 10 ── login e telas de acesso ---------------------------------------- */
body.login-page { background: var(--hull-900); }
.login-hero { position: fixed; inset: 0; background: url("img/sense-login-900.15a59a9fde49.jpg") 35% 35% / cover no-repeat; }
@media (min-width: 900px) { .login-hero { background-image: url("img/sense-login.790d6148879d.jpg"); } }
.login-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(35,38,42,.15) 0%, rgba(35,38,42,.55) 60%, rgba(35,38,42,.85) 100%); }
.login-wrap { position: relative; min-height: 100vh; display: flex; flex-direction: column; justify-content: flex-end; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.login-card { background: var(--login-card); border-radius: 16px; padding: 24px 20px; max-width: 420px; width: 100%; margin: 0 auto; }
.login-card .logo { color: var(--text); width: 150px; margin-bottom: .25rem; } .login-card .logo svg { width: 100%; height: auto; display: block; }
.login-card p.sub { color: var(--text-2); margin-bottom: 1.25rem; font-size: .95rem; }
.login-card button { width: 100%; }
.login-foot { color: rgba(255,255,255,.85); text-align: center; font-size: .85rem; margin-top: 1rem; }
@media (min-width: 768px) { .login-wrap { justify-content: center; } .login-card { margin: 0 8vw 0 auto; } .login-foot { text-align: right; padding-right: 8vw; } }

/* 11 ── diálogos e estados vazios -------------------------------------- */
dialog.confirm { border: 1px solid var(--line); border-radius: var(--r); padding: 1.25rem; max-width: 420px; width: calc(100% - 32px); background: var(--surface); color: var(--text); }
dialog.confirm::backdrop { background: rgba(35,38,42,.55); }
dialog.confirm h4 { margin-bottom: .5rem; } dialog.confirm textarea { margin-bottom: .75rem; } dialog.confirm .actions { justify-content: flex-end; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--text-2); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }
.empty svg { width: 120px; height: 48px; color: var(--hull-300); margin-bottom: .5rem; }
.empty p { margin: 0; }

/* 12 ── mobile ---------------------------------------------------------- */
@media (max-width: 639px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .6rem 1rem; margin-bottom: .6rem; }
  .table-cards td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .25rem 0; border: 0; text-align: right; }
  .table-cards td::before { content: attr(data-label); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); text-align: left; flex: 0 0 auto; }
  .table-cards td.primary { font-weight: 600; font-size: 1.05rem; justify-content: flex-start; text-align: left; }
  .table-cards td.primary::before, .table-cards td.row-actions::before, .table-cards td:empty::before { content: none; }
  .table-cards td:empty { display: none; }
  .table-cards td[colspan] { justify-content: flex-start; text-align: left; }
  .table-cards td.row-actions { justify-content: flex-end; padding-top: .5rem; flex-wrap: wrap; }
  .table-cards td.row-actions [role=button], .table-cards td.row-actions button { margin: 0; min-height: 44px; }
  .due-item { grid-template-columns: 1fr; }
  .due-item .amount { grid-column: 1; grid-row: 1; justify-self: start; } .due-item .name { grid-column: 1; grid-row: 2; } .due-item .when { grid-column: 1; grid-row: 3; }
  .due-item .go, .due-item.expense .go { grid-column: 1; grid-row: 4; justify-self: end; flex-wrap: wrap; justify-content: flex-end; }
  .due-item:not(.expense) .name { grid-row: 1; } .due-item:not(.expense) .when { grid-row: 2; } .due-item:not(.expense) .go { grid-row: 3; }
  .plan { grid-template-columns: 1fr; } .plan .go { grid-column: 1; grid-row: 3; justify-self: end; } .plan .name, .plan .meta { grid-column: 1 / -1; }
  .cal td { height: 56px; padding: .15rem; } .cal .hol { display: none; } .cal td.holiday .day::after { content: "•"; color: var(--teak-700); margin-left: .15rem; }
  .cal .ev { font-size: .68rem; padding: .05rem .2rem; }
  form.sections .actions { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); background: var(--bg); padding: .5rem 0; }
}
@media (min-width: 768px) { .checklist { grid-template-columns: 1fr 1fr; } }
details.section summary { cursor: pointer; list-style: none; } details.section summary::-webkit-details-marker { display: none; }
details.section summary::before { content: "▸ "; color: var(--sea-700); } details.section[open] summary::before { content: "▾ "; }

/* botão de voltar (todas as telas, exceto Início): volta no histórico ou vai para o Início */
a.back { display: inline-flex; align-items: center; min-height: 40px; padding: 0 .6rem 0 .2rem; margin: -.25rem 0 .5rem -.2rem; color: var(--text-2); text-decoration: none; font-weight: 500; border-radius: 8px; }
a.back:hover { background: var(--surface); color: var(--sea-700); }

/* erros de formulário: caixa âmbar com borda, legível em claro e escuro */
ul.errorlist { list-style: none; padding: .55rem .8rem; margin: .25rem 0 .75rem; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); border-left-width: 5px; border-radius: 8px; font-weight: 600; }
ul.errorlist li { margin: 0; padding: 0; list-style: none; }
ul.errorlist.nonfield { font-size: 1rem; margin-bottom: 1rem; }
[aria-invalid=true], input:user-invalid, select:user-invalid { border-color: var(--warn) !important; box-shadow: 0 0 0 3px var(--warn-bg); }
/* hover nunca apaga ícones ou logo */
.topbar .brand:hover, .topbar .brand:focus { color: var(--topbar-text); }
.big-actions a:hover { border-color: var(--sea-700); }
.big-actions a:hover svg { color: var(--sea-700); }
.big-actions a.charter:hover { border-color: var(--teak-700); } .big-actions a.charter:hover svg { color: var(--teak-700); }
.big-actions a.primary:hover svg { color: var(--pico-primary-inverse); }
.tabbar a:hover { color: var(--sea-700); }
.menu-list li a:hover { border-color: var(--sea-700); color: var(--text); }
.plan .name a:hover, .due-item .name a:hover { color: var(--sea-700); text-decoration: underline; }
.due-item .roles { grid-column: 1 / -1; } .due-item .roles form { display: flex; gap: .5rem; flex-wrap: wrap; margin: .25rem 0 0; } .due-item .roles button { width: auto; margin: 0; font-size: .85rem; padding: .35rem .7rem; }
.damage-block + .damage-block { border-top: 1px dashed var(--line); padding-top: .75rem; margin-top: .5rem; }
.damage-block .block-title { margin: 0 0 .5rem; }
#mais-avaria, #mais-extra { width: auto; margin-top: .25rem; }
.bundle-items { grid-template-columns: 1fr; }
.extra-row { display: grid; grid-template-columns: 2fr 1fr; gap: .5rem; } @media (max-width: 600px) { .extra-row { grid-template-columns: 1fr; } }
td.plan-state form { margin: 0; } td.plan-state button { width: auto; margin: 0; font-size: .8rem; padding: .25rem .6rem; } a.badge.ok { text-decoration: none; }
details.findings { margin: .2rem 0 0; } details.findings summary { cursor: pointer; font-size: .85rem; color: var(--text-2); list-style: none; } details.findings summary::-webkit-details-marker { display: none; }
details.findings p { margin: .3rem 0 0; font-size: .9rem; white-space: pre-wrap; }
/* recorrências: mesmo cartão das contas, em tom neutro-azulado para não confundir com uma conta a pagar */
.due-item.recurring { border-left-color: var(--sea-500); background: color-mix(in srgb, var(--sea-100) 35%, var(--surface)); }
.due-item.recurring.inactive { opacity: .6; border-left-style: dashed; }
.due-item.paid { border-left-color: var(--hull-300); } .due-item.credit { border-left-color: var(--sea-700); }
