/* ===== Estrutura comum (sidebar + topbar + conteúdo), mesma linguagem visual do Portal Ribal ===== */
html:not([data-auth="ok"]) body:has(.shell) { visibility: hidden; } /* evita piscar conteúdo antes de validar a sessão */

.shell { min-height: 100vh; }

/* --- sidebar --- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: 262px; display: flex; flex-direction: column;
  padding: 40px 22px 56px;
  background: var(--sidebar); border-right: 1px solid var(--sidebar-edge);
  overflow-y: auto;
}
:root:not([data-theme="light"]) .sidebar { background: linear-gradient(180deg, #17181a 0%, #121215 100%); }
.sidebar__brand { display: block; padding: 0 14px; margin-bottom: 52px; }
.logo { width: 150px; height: auto; }
.logo--light { display: none; }
:root[data-theme="light"] .logo--dark { display: none; }
:root[data-theme="light"] .logo--light { display: block; }

.nav { display: grid; gap: 10px; }
.nav a, .nav .nav__item {
  position: relative; display: flex; align-items: center; gap: 16px;
  min-height: 48px; padding: 6px 12px 6px 22px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 15.5px; font-weight: 500;
  transition: background .2s;
}
.nav .icon { font-size: 26px; color: var(--icon); stroke-width: 1.4; }
.nav a:hover { background: color-mix(in srgb, var(--nav-active) 55%, transparent); }
.nav a[aria-current="page"] { background: var(--nav-active); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent); border-radius: 6px 0 0 6px;
}
.nav .nav__item[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.sidebar__motto {
  margin-top: auto; padding-top: 40px; padding-left: 22px;
  font-size: 12px; letter-spacing: .36em;
}
.sidebar__motto::before { content: ""; display: block; width: 40px; height: 1px; margin-bottom: 24px; background: var(--muted); opacity: .7; }
.sidebar__motto::after { content: ""; display: block; width: 40px; height: 2px; margin-top: 16px; background: var(--accent); }

/* --- área principal --- */
.main { margin-left: 262px; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  height: 60px; padding: 0 34px 0 38px;
  background: var(--topbar); border-bottom: 1px solid var(--line);
}
.topbar__label { font-size: 12px; font-weight: 500; letter-spacing: .42em; text-transform: uppercase; color: var(--soft); }
.topbar .user { margin-left: auto; }
.burger {
  display: none; place-items: center; width: 40px; height: 40px; margin-left: -8px;
  border: 0; border-radius: 8px; background: transparent; color: var(--icon); font-size: 24px;
}

.user { position: relative; }
.user__btn {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 6px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; font-weight: 600;
}
.user__btn:hover { background: var(--nav-active); }
.user__avatar { font-size: 34px; stroke-width: 1.3; color: var(--icon); }
.user__chevron { font-size: 18px; color: var(--icon); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; z-index: 20; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.menu[hidden] { display: none; }
.menu__item {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 12px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 14px; text-align: left;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--nav-active); }
.menu__item .icon { font-size: 18px; color: var(--icon); }
.menu .icon-moon { display: none; }
:root[data-theme="light"] .menu .icon-sun { display: none; }
:root[data-theme="light"] .menu .icon-moon { display: block; }

/* --- páginas --- */
#conteudo { outline: 0; }
.page { max-width: 1180px; padding: 38px 41px 72px 43px; }
.page--wide { max-width: 1560px; }
.page__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.page__title { font-size: clamp(32px, 3.1vw, 50px); font-weight: 700; line-height: 1.1; letter-spacing: -.025em; }
.page__sub { margin-top: 6px; font-size: clamp(16px, 1.3vw, 21px); font-weight: 300; line-height: 1.35; color: var(--muted); }
.eyebrow { margin-bottom: 10px; font-size: 12.5px; font-weight: 500; letter-spacing: .3em; text-transform: uppercase; color: var(--accent); }

.section { margin-top: 34px; }
.section__title { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; font-size: 21px; font-weight: 600; line-height: 1.3; letter-spacing: -.005em; }
.section__title .icon { font-size: 26px; color: var(--accent); stroke-width: 1.5; }
.card { padding: 24px 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

/* --- botões --- */
.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 22px;
  border: 1.5px solid transparent; border-radius: 8px; font-size: 14.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .2s, border-color .2s, opacity .2s;
}
.btn-primary { background: var(--accent); color: #0b0b0c; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn-primary .icon { font-size: 17px; stroke-width: 2.2; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-ghost .icon, .btn-danger .icon { font-size: 17px; stroke-width: 1.8; }
.btn-danger { background: transparent; border-color: color-mix(in srgb, #e5484d 55%, transparent); color: #e5484d; }
.btn-primary:disabled, .btn-ghost:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary[aria-busy="true"] { opacity: .7; cursor: progress; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }

/* --- campos --- */
.field { display: grid; gap: 8px; }
.field label, .field__label { font-size: 14.5px; font-weight: 600; }
.field__hint { font-size: 13px; font-weight: 400; color: var(--muted); }
.field__error { font-size: 13px; font-weight: 500; color: #ff8a8e; }
.field__error[hidden] { display: none; }
:root[data-theme="light"] .field__error { color: #a3161b; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"], .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--field-border); border-radius: 8px;
  background: var(--field); color: var(--text); font-size: 15px;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; font-family: inherit; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--accent); }
.field input:disabled, .field textarea:disabled { opacity: .55; }
.field.is-invalid input, .field.is-invalid textarea, .field.is-invalid select { border-color: #e5484d; }
.req { color: var(--accent); }

.fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.fieldset legend { padding: 0; margin-bottom: 10px; font-size: 14.5px; font-weight: 600; }
.radios { display: flex; flex-wrap: wrap; gap: 10px; }
.radios--stack { flex-direction: column; align-items: stretch; }
.radio { position: relative; display: inline-flex; }
.radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.radio span {
  display: inline-flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 16px; border: 1px solid var(--field-border);
  border-radius: 8px; background: var(--field); color: var(--soft); font-size: 14.5px; font-weight: 500; cursor: pointer; width: 100%;
  transition: border-color .2s, color .2s;
}
.radio span::before { content: ""; flex: none; width: 16px; height: 16px; border: 1.5px solid var(--field-border); border-radius: 50%; }
.radio span:hover { border-color: var(--accent); }
.radio input:checked + span { border-color: var(--accent); color: var(--text); }
.radio input:checked + span::before { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 4px, transparent 5px); }
.radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--soft); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.form__msg { margin: 0; padding: 11px 14px; border: 1px solid color-mix(in srgb, #e5484d 45%, transparent); border-radius: 8px; background: color-mix(in srgb, #e5484d 10%, transparent); font-size: 14px; color: #ff8a8e; }
.form__msg[hidden] { display: none; }
.form__msg[data-tone="info"] { color: var(--soft); background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
:root[data-theme="light"] .form__msg { color: #a3161b; }
:root[data-theme="light"] .form__msg[data-tone="info"] { color: var(--soft); }
.form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.empty { margin-top: 22px; padding: 36px 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.noscript { position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 16px; text-align: center; font-size: 13px; background: var(--surface); color: var(--muted); }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .55); }
.scrim[hidden] { display: none; }

/* --- telas médias e mobile: sidebar vira drawer --- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .28s ease, visibility 0s .28s; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: none; visibility: visible; transition-delay: 0s; }
  .main { margin-left: 0; }
  .burger { display: grid; }
  .topbar { gap: 12px; padding: 0 16px; }
  .topbar__label { display: none; }
  .user__hello { display: none; }
  .page { padding: 26px 16px 56px; }
  .page__head { flex-wrap: wrap; }
}
