/* Painel master — layout, navegação e componentes específicos */
:root {
  --admin-sidebar-w: 252px;
  --admin-ink: #0d2028;
  --admin-ink-soft: #16333d;
}

/* Login */
.auth-hint {
  margin-top: 1.25rem; color: var(--muted); font-size: .82rem; text-align: center;
}

/* Alvos de toque acessíveis em todo o painel */
.admin-app .btn, .auth-shell .btn, .admin-app .btn--sm { min-height: 44px; }
.admin-app .icon-btn { width: 44px; height: 44px; }
.sidebar__link, .topbar__user, .checkbox-card { min-height: 44px; }

/* Estrutura */
.admin-app { min-height: 100vh; }
.admin-main {
  margin-left: var(--admin-sidebar-w); min-height: 100vh;
  display: flex; flex-direction: column; min-width: 0;
}

/* Sidebar */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  width: var(--admin-sidebar-w); display: flex; flex-direction: column;
  background: var(--admin-ink); color: #dce8ec;
  box-shadow: 4px 0 24px rgba(5, 18, 24, .18);
}
.sidebar__brand {
  display: flex; align-items: center; gap: .7rem; min-height: var(--header-h);
  padding: .8rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.sidebar__mark {
  flex: none; width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; background: var(--brand); color: #fff;
  font-weight: 800; font-size: .95rem; letter-spacing: -.04em;
}
.sidebar__brand-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar__brand-text strong { font-size: .92rem; color: #fff; white-space: nowrap; }
.sidebar__brand-text small { color: #8fa9b2; font-size: .72rem; }
.sidebar__close { display: none; margin-left: auto; background: transparent; border-color: rgba(255,255,255,.2); color: #fff; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 1rem .6rem; }
.sidebar__caption {
  display: block; padding: .9rem .7rem .4rem; color: #72909b;
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em;
}
.sidebar__link {
  display: flex; align-items: center; gap: .8rem; width: 100%; min-height: 46px;
  padding: .6rem .75rem; margin-bottom: .2rem; border: 0; border-radius: 10px;
  background: transparent; color: #c9dbe1; text-align: left; font-size: .9rem; font-weight: 600;
}
.sidebar__link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar__link.is-active { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(15, 118, 110, .28); }
.sidebar__icon { width: 22px; text-align: center; font-size: 1.05rem; flex: none; }
.sidebar__foot {
  padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .09);
  display: flex; flex-direction: column; gap: .35rem; font-size: .76rem; color: #7f9aa4;
}
.sidebar__external { color: #bcd4db; font-weight: 600; }
.sidebar__external:hover { color: #fff; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(7, 20, 26, .55); }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30; min-height: var(--header-h);
  display: flex; align-items: center; gap: .8rem; padding: .6rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar__title { display: flex; flex-direction: column; min-width: 0; }
.topbar__title strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title small { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__spacer { flex: 1; }
.topbar__user {
  display: flex; align-items: center; gap: .6rem; font-size: .84rem; font-weight: 600;
  padding: .3rem .4rem; border-radius: 999px;
}
.topbar__avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-soft); color: var(--brand-dark); font-weight: 800;
}
.topbar__user-text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__user-text small { font-weight: 500; font-size: .7rem; }
.topbar__menu { display: none; }

/* Conteúdo */
.content { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 1.5rem; }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.2rem;
}
.view-head h1 { margin-bottom: .2rem; }
.view-head p { margin-bottom: 0; }
.toolbar {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .8rem 1rem; margin-bottom: 1rem;
}
.toolbar input[type='search'], .toolbar select { width: auto; flex: 1 1 200px; min-width: 160px; }
.toolbar__count { margin-left: auto; color: var(--muted); font-size: .78rem; white-space: nowrap; }
.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  margin: 1.6rem 0 .8rem;
}
.section-title h2 { font-size: 1.1rem; margin: 0; }
.section-title p { margin: 0; color: var(--muted); font-size: .82rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
.kpi--accent { border-left: 3px solid var(--accent); }
.kpi--brand { border-left: 3px solid var(--brand); }
.kpi__icon { float: right; font-size: 1.1rem; opacity: .5; }
.kpi__value--money { font-size: 1.35rem; }

/* Gráfico de barras em CSS */
.chart-card .card__body { padding-bottom: 1rem; }
.chart {
  display: flex; align-items: flex-end; gap: 1rem; height: 220px;
  padding: 1rem .25rem 0; border-bottom: 1px solid var(--line);
}
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart__bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart__bar {
  width: min(64px, 78%); min-height: 4px; border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--brand), var(--brand-dark));
  transition: filter .15s ease;
}
.chart__col:hover .chart__bar { filter: brightness(1.12); }
.chart__bar--h1 { height: 6%; }
.chart__bar--h2 { height: 14%; }
.chart__bar--h3 { height: 24%; }
.chart__bar--h4 { height: 34%; }
.chart__bar--h5 { height: 45%; }
.chart__bar--h6 { height: 57%; }
.chart__bar--h7 { height: 69%; }
.chart__bar--h8 { height: 80%; }
.chart__bar--h9 { height: 91%; }
.chart__bar--h10 { height: 100%; }
.chart__label { padding-top: .55rem; font-size: .7rem; color: var(--muted); text-align: center; white-space: nowrap; }
.chart__value { font-size: .68rem; font-weight: 700; color: var(--text); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .9rem; font-size: .76rem; color: var(--muted); }
.chart-legend__dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--brand); margin-right: .35rem; }

/* Tabelas responsivas (cards no mobile) */
.data-table { font-size: .85rem; }
.data-table th { white-space: nowrap; }
.data-table td { vertical-align: middle; }
.data-table .cell-main { display: flex; flex-direction: column; gap: .1rem; }
.data-table .cell-main strong { font-size: .88rem; color: var(--text); }
.data-table .cell-main small { font-size: .74rem; }
.data-table .cell-actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.data-table .actions { display: table-cell; }
.entity-mark {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--surface-soft); color: var(--brand-dark); font-size: .78rem; font-weight: 800;
}
.entity-line { display: flex; align-items: center; gap: .6rem; }
.entity-line > span:last-child { min-width: 0; }
.permissions-list { display: flex; flex-wrap: wrap; gap: .25rem; max-width: 340px; }
.permission-chip {
  padding: .12rem .45rem; border-radius: 999px; background: var(--surface-soft);
  color: var(--muted); font-size: .68rem; font-weight: 700;
}
.permission-chip--all { background: #dcfce7; color: var(--success); }

/* Atividade */
.event-list { display: flex; flex-direction: column; }
.event {
  display: flex; gap: .9rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line);
}
.event:last-child { border-bottom: 0; }
.event__icon {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; background: var(--surface-soft); color: var(--brand-dark); font-size: 1rem;
}
.event__body { min-width: 0; }
.event__title { font-weight: 650; font-size: .87rem; }
.event__meta { color: var(--muted); font-size: .75rem; margin-top: .15rem; }
.event__desc { color: var(--muted); font-size: .82rem; margin-top: .25rem; overflow-wrap: anywhere; }
.action-badge {
  display: inline-block; padding: .1rem .4rem; border-radius: 5px;
  background: var(--surface-soft); color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .03em;
}

/* Modelos de ambientes */
.template-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.template-card { display: flex; flex-direction: column; height: 100%; }
.template-card__media {
  height: 120px; display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(135deg, var(--surface-soft), color-mix(in srgb, var(--brand) 10%, var(--surface)));
  color: var(--brand-dark); font-size: 2.6rem;
}
.template-card__media img { width: 100%; height: 100%; object-fit: cover; }
.template-card__body { flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.template-card__title { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.template-card__title h3 { margin: 0; font-size: 1rem; }
.template-card__price { font-weight: 800; color: var(--brand-dark); white-space: nowrap; }
.template-card__desc { color: var(--muted); font-size: .82rem; margin: 0; min-height: 2.4em; }
.template-card__meta { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .75rem; color: var(--muted); }
.template-card__amenities { display: flex; flex-wrap: wrap; gap: .3rem; }
.template-card__foot { display: flex; gap: .4rem; flex-wrap: wrap; padding: .8rem 1.1rem; border-top: 1px solid var(--line); }

/* Formulários em modal */
.form-section { margin-bottom: 1.4rem; }
.form-section:last-child { margin-bottom: 0; }
.form-section__title {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem;
  font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-dark);
}
.form-section__title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.form-note { color: var(--muted); font-size: .78rem; margin: -.2rem 0 .8rem; }
.checkbox-card {
  display: flex; align-items: center; gap: .6rem; min-height: 44px;
  padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  cursor: pointer; font-size: .84rem;
}
.checkbox-card:hover { background: var(--surface-soft); }
.checkbox-card input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.checkbox-card small { display: block; font-size: .7rem; color: var(--muted); }
.checkbox-card.is-locked { opacity: .75; cursor: default; }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; flex-wrap: wrap; }
.color-field { display: flex; align-items: center; gap: .5rem; }
.color-field input[type='color'] { width: 46px; height: 42px; min-height: 42px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }
.color-field input[type='text'] { flex: 1; min-width: 0; }

/* Paginação */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination__info { color: var(--muted); font-size: .78rem; }

/* Utilitários */
.loading-box { padding: .5rem 1.2rem 1.2rem; }
.error-box {
  padding: 1rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid #fecaca;
  background: #fef2f2; color: #991b1b; font-size: .86rem;
}
.text-danger { color: var(--danger); }
.nowrap { white-space: nowrap; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar__close { display: inline-flex; }
  .admin-main { margin-left: 0; }
  .topbar__menu { display: inline-flex; }
}
@media (max-width: 760px) {
  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
  .topbar__user-text { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Tabelas viram cartões */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    margin-bottom: .8rem; padding: .5rem .9rem; box-shadow: var(--shadow-sm);
  }
  .data-table td {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    border-bottom: 1px solid var(--line); padding: .55rem 0; white-space: normal; text-align: right;
  }
  .data-table td:last-child { border-bottom: 0; }
  .data-table td::before {
    content: attr(data-label); flex: none; color: var(--muted);
    font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; text-align: left;
  }
  .data-table td.actions, .data-table td.cell-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; }
  .data-table .cell-actions { justify-content: flex-end; }
  .data-table .permissions-list { justify-content: flex-end; }
  .template-grid { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: 1fr; }
  .chart { height: 180px; gap: .4rem; }
  .chart__label { font-size: .62rem; writing-mode: vertical-rl; transform: rotate(180deg); }
  .settings-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 460px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .toolbar input[type='search'], .toolbar select { flex-basis: 100%; }
  .form-actions .btn { flex: 1; }
}
