:root {
  --bg-1: #f9f5ef;
  --bg-2: #f2ebe3;
  --card: #fffdf8;
  --text: #2e241e;
  --muted: #6a5d54;
  --accent: #e25a2c;
  --accent-strong: #c9441a;
  --info: #2563eb;
  --ok: #1c8a57;
  --danger: #b83737;
  --line: #e7ddd2;
  --shadow: 0 14px 34px rgba(51, 32, 22, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Outfit", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  position: relative;
  overflow-x: hidden;
}

.background-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(45px);
  z-index: -1;
  opacity: 0.45;
}

.shape-1 {
  width: 260px;
  height: 260px;
  background: #ffd6be;
  top: -90px;
  left: -70px;
}

.shape-2 {
  width: 300px;
  height: 300px;
  background: #ffe8a3;
  right: -110px;
  bottom: -90px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: linear-gradient(180deg, rgba(249, 245, 239, 0.96), rgba(242, 235, 227, 0.96));
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(440px, 94vw);
  border: 1px solid #eed8c6;
  background: #fffcf8;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px 20px;
}

.login-card h2 {
  margin: 0;
  font-size: 1.3rem;
}

.login-card > p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-form {
  margin-top: 14px;
  border: 1px solid #efdfd1;
  background: #fffaf4;
  border-radius: 14px;
  padding: 14px;
}

.login-form h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.login-help {
  margin: 12px 0 0;
  color: #654f41;
  font-size: 0.84rem;
}

.login-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.88rem;
}

.login-info {
  margin: 10px 0 0;
  color: var(--ok);
  font-weight: 600;
  font-size: 0.88rem;
}

.login-info.is-error {
  color: var(--danger);
}

body.app-locked {
  overflow: hidden;
}

body.app-locked .app {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

.app {
  width: min(1100px, 92vw);
  margin: 36px auto;
  display: grid;
  gap: 18px;
}

.app-header {
  text-align: center;
}

.app-header-shell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  letter-spacing: 0.04em;
}

.app-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #efd8c4;
  background: #fff6ec;
  color: #8c4729;
  font-weight: 700;
  white-space: nowrap;
}

.admin-panel {
  border-color: #efd8c4;
  background:
    radial-gradient(circle at top right, rgba(255, 230, 210, 0.55), transparent 38%),
    var(--card);
}

.admin-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.admin-panel-header h2 {
  margin-bottom: 6px;
}

.admin-panel-header p {
  margin: 0;
  color: var(--muted);
}

.admin-user-form {
  margin-top: 14px;
}

.admin-users-list-wrap {
  margin-top: 18px;
}

.admin-users-list-wrap h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.admin-users-list {
  display: grid;
  gap: 12px;
}

.admin-user-item {
  border: 1px solid #ecd8c8;
  background: #fffaf5;
  border-radius: 14px;
  padding: 14px;
}

.admin-user-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-user-top strong {
  font-size: 1rem;
}

.admin-user-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid #d7e7d8;
  background: #edf8ef;
  color: #21683d;
}

.admin-user-status.is-inactive {
  border-color: #efc9c9;
  background: #fff0f0;
  color: #a03c3c;
}

.admin-user-status.is-admin {
  border-color: #f0d2bf;
  background: #fff3e8;
  color: #934f2d;
}

.admin-user-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.2rem;
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
}

.summary-item {
  background: #fff8f2;
  border: 1px solid #f1dfd0;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.summary-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-item strong {
  font-size: 1.2rem;
}

.progress-wrap {
  grid-column: 1 / -1;
  height: 12px;
  background: #f0dfd2;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 2px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #ff9b47, var(--accent));
  transition: width 0.25s ease;
}

.progress-text {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.grid-panels {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(250px, 1fr));
}

.field-row {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

label {
  font-size: 0.92rem;
  color: var(--muted);
}

input,
select {
  border: 1px solid #e6d9cb;
  background: #fffefb;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input,
select,
.button {
  min-height: 44px;
}

input:focus,
select:focus {
  border-color: #ed8f67;
  box-shadow: 0 0 0 3px rgba(226, 90, 44, 0.16);
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
}

.button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.2s ease;
}

.button:hover {
  filter: brightness(0.97);
}

.button:active {
  transform: translateY(1px);
}

.button.primary {
  color: #fff;
  background: linear-gradient(130deg, var(--accent), var(--accent-strong));
}

.button.ghost {
  color: var(--accent-strong);
  background: #ffe8dc;
  border: 1px solid #ffd1ba;
}

.button.danger {
  color: #fff;
  background: linear-gradient(130deg, #d55a5a, var(--danger));
}

.button.neutral {
  color: #3f4754;
  background: #f3f5f8;
  border: 1px solid #d4dbe5;
}

.button.small {
  padding: 7px 10px;
  font-size: 0.82rem;
  min-height: 32px;
}

.is-hidden {
  display: none !important;
}

.form-actions {
  margin-top: 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.table-tools {
  margin: 14px 0;
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.backup-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.field-row.no-margin {
  margin-bottom: 0;
}

.shortcut-divider {
  border-top: 1px dashed #e8d9cb;
  margin: 16px 0 12px;
}

.shortcut-subtitle {
  margin: 0 0 10px;
  font-size: 0.98rem;
  color: #4c3d32;
}

.shortcut-form {
  display: grid;
  gap: 10px;
}

.shortcut-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.shortcut-search-controls {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.shortcut-search-controls input {
  min-width: 0;
}

.shortcut-search-controls .button {
  margin: 0;
  white-space: nowrap;
}

.shortcut-list-wrap {
  margin-top: 12px;
}

.shortcut-list {
  display: grid;
  gap: 8px;
}

.shortcut-item {
  border: 1px solid #eddccc;
  background: #fff9f3;
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.shortcut-item strong {
  font-size: 0.92rem;
}

.shortcut-item small {
  color: var(--muted);
  font-size: 0.8rem;
}

.shortcut-item-info {
  display: grid;
  gap: 2px;
}

.shortcut-remove {
  border: 1px solid #f0bcbc;
  background: #ffecec;
  color: var(--danger);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 0.8rem;
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1140px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 11px 9px;
  font-size: 0.95rem;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #fffaf5;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
}

.tag-refeicao {
  display: inline-block;
  border: 1px solid #ffcfb5;
  color: #b3532f;
  background: #fff1e8;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.8rem;
}

.acao-btn {
  border: 1px solid #f2c2c2;
  color: var(--danger);
  background: #ffeded;
  border-radius: 8px;
  font-size: 0.82rem;
  padding: 6px 9px;
  cursor: pointer;
}

.acao-btn:hover {
  filter: brightness(0.98);
}

.acao-wrap {
  display: flex;
  gap: 6px;
}

.acao-btn.edit {
  color: var(--info);
  background: #eaf1ff;
  border-color: #bfd3ff;
}

.photo-preview-wrap {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.photo-preview {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #eadccf;
  background: #f7efe8;
}

.food-thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #e3d7ca;
  background: #f6eee7;
  display: block;
}

.food-thumb.empty {
  display: grid;
  place-items: center;
  color: #8e7c6d;
  font-size: 0.72rem;
  font-weight: 600;
}

.meal-summary-list {
  display: grid;
  gap: 8px;
}

.meal-summary-item {
  border: 1px solid #efe2d4;
  border-radius: 10px;
  background: #fff8f2;
  padding: 9px 11px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.meal-summary-item span {
  color: var(--muted);
  font-size: 0.92rem;
}

.meal-summary-item strong {
  font-size: 0.95rem;
}

.weekly-chart {
  min-height: 180px;
  display: grid;
  grid-template-columns: repeat(7, minmax(30px, 1fr));
  align-items: end;
  gap: 8px;
}

.week-col {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.week-bar {
  width: 100%;
  max-width: 46px;
  border-radius: 10px 10px 6px 6px;
  background: linear-gradient(180deg, #ffb46b, #e6783d);
  min-height: 8px;
  height: 16px;
  transition: height 0.3s ease;
}

.week-bar.today {
  background: linear-gradient(180deg, #5ba7ff, #2563eb);
}

.week-label {
  font-size: 0.76rem;
  color: var(--muted);
}

.week-value {
  font-size: 0.76rem;
  color: #564537;
  font-weight: 600;
}

.report-dashboard {
  background:
    radial-gradient(circle at top right, rgba(255, 213, 185, 0.45), transparent 40%),
    radial-gradient(circle at bottom left, rgba(255, 232, 163, 0.35), transparent 42%),
    var(--card);
  border: 1px solid #f0d9c6;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.report-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.report-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.report-badge {
  border: 1px solid #f2cdb1;
  background: #fff4e9;
  color: #9a4d29;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.report-badge.is-over {
  border-color: #efbbbb;
  background: #ffeaea;
  color: #9b2d2d;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.report-kpi {
  border: 1px solid #eddccc;
  background: #fffaf4;
  border-radius: 12px;
  padding: 11px;
  display: grid;
  gap: 6px;
}

.report-kpi span {
  color: var(--muted);
  font-size: 0.84rem;
}

.report-kpi strong {
  font-size: 1.02rem;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 10px;
}

.report-block {
  border: 1px solid #efdfd1;
  background: #fffdf8;
  border-radius: 12px;
  padding: 12px;
}

.report-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.report-meal-list {
  display: grid;
  gap: 9px;
}

.report-meal-item {
  display: grid;
  gap: 5px;
}

.report-meal-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
}

.report-meal-row span {
  color: var(--muted);
}

.report-meal-row strong {
  color: #47362a;
}

.report-meal-track {
  width: 100%;
  height: 8px;
  background: #f1e2d5;
  border-radius: 999px;
  overflow: hidden;
}

.report-meal-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb670, #e3743a);
}

.report-weekly {
  min-height: 164px;
}

.report-table-block {
  margin-top: 10px;
}

.report-table-wrap {
  overflow-x: auto;
}

.report-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.report-table th,
.report-table td {
  border-bottom: 1px solid #ecdfd2;
  padding: 8px 7px;
  font-size: 0.9rem;
  text-align: left;
}

.report-table th {
  background: #fff8f0;
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 760px) {
  .registro-table,
  .report-table {
    min-width: 0;
    width: 100%;
  }

  .registro-table thead,
  .report-table thead {
    display: none;
  }

  .registro-table tbody,
  .report-table tbody,
  .registro-table tr,
  .report-table tr,
  .registro-table td,
  .report-table td {
    display: block;
    width: 100%;
  }

  .registro-table tr,
  .report-table tr {
    border: 1px solid #e9dccf;
    border-radius: 12px;
    background: #fffdf9;
    margin-bottom: 10px;
    padding: 8px;
  }

  .registro-table td,
  .report-table td {
    border-bottom: 0;
    padding: 6px 6px;
  }

  .registro-table td::before,
  .report-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
  }

  .registro-table td.empty-state,
  .report-table td.empty-state {
    text-align: center;
    padding: 18px 10px;
  }

  .registro-table td.empty-state::before,
  .report-table td.empty-state::before {
    content: none;
  }

  .registro-table .acao-wrap {
    width: 100%;
    justify-content: flex-start;
  }

  .registro-table .acao-btn {
    min-height: 38px;
  }
}

@media (max-width: 880px) {
  .app-header-shell {
    flex-direction: column;
    align-items: flex-start;
  }

  .session-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .summary-panel {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .form-grid,
  .grid-panels {
    grid-template-columns: 1fr;
  }

  .report-kpis {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .report-grid {
    grid-template-columns: 1fr;
  }

  .shortcut-grid {
    grid-template-columns: 1fr;
  }

  .admin-user-grid {
    grid-template-columns: 1fr;
  }

  .table-tools {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .backup-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 500px) {
  .app {
    width: 94vw;
    margin: 24px auto;
  }

  .panel {
    padding: 14px;
  }

  .button {
    width: 100%;
  }

  .shortcut-search-controls {
    grid-template-columns: 1fr;
  }

  .shortcut-search-controls .button {
    width: 100%;
  }

  .table-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
  }

  .login-card {
    padding: 18px 16px;
  }

  .report-kpis {
    grid-template-columns: 1fr;
  }

  .report-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .backup-actions {
    flex-direction: column;
  }

  .session-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@page {
  size: A4 portrait;
  margin: 12mm;
}

@media print {
  .login-screen,
  .background-shape {
    display: none !important;
  }

  html,
  body {
    width: 100%;
    min-height: auto;
  }

  body {
    margin: 0;
    padding: 0;
    background: #fff !important;
    color: #1b1b1b;
    font-size: 11pt;
    line-height: 1.35;
  }

  .app {
    width: 100%;
    margin: 0;
    gap: 5mm;
  }

  .app > * {
    display: none !important;
  }

  #painelRelatorioDashboard {
    display: block !important;
    border: 0;
    box-shadow: none;
    padding: 0;
    background: #fff;
  }

  #painelRelatorioDashboard .report-header {
    margin-bottom: 4mm;
    align-items: flex-start;
  }

  #painelRelatorioDashboard .report-header h2 {
    font-size: 17pt;
  }

  #painelRelatorioDashboard .report-subtitle {
    font-size: 10pt;
  }

  #painelRelatorioDashboard .report-badge {
    font-size: 9pt;
    padding: 5px 10px;
  }

  #painelRelatorioDashboard .report-kpis {
    grid-template-columns: repeat(3, 1fr);
    gap: 3mm;
    margin-bottom: 4mm;
  }

  #painelRelatorioDashboard .report-kpi {
    padding: 8px;
    break-inside: avoid;
  }

  #painelRelatorioDashboard .report-grid {
    grid-template-columns: 1fr 1fr;
    gap: 3mm;
  }

  #painelRelatorioDashboard .report-block {
    padding: 8px;
    break-inside: avoid;
  }

  #painelRelatorioDashboard .report-table-wrap {
    overflow: visible;
  }

  #painelRelatorioDashboard .report-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    display: table;
  }

  #painelRelatorioDashboard .report-table thead {
    display: table-header-group;
  }

  #painelRelatorioDashboard .report-table tbody {
    display: table-row-group;
  }

  #painelRelatorioDashboard .report-table tr {
    display: table-row;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  #painelRelatorioDashboard .report-table th,
  #painelRelatorioDashboard .report-table td {
    display: table-cell;
    font-size: 9pt;
    padding: 4px 3px;
    border-bottom: 1px solid #d9d9d9;
    word-break: break-word;
    vertical-align: middle;
  }

  #painelRelatorioDashboard .report-table td::before {
    content: none !important;
  }

  #painelRelatorioDashboard .report-table th:nth-child(1),
  #painelRelatorioDashboard .report-table td:nth-child(1) {
    width: 10%;
  }

  #painelRelatorioDashboard .report-table th:nth-child(2),
  #painelRelatorioDashboard .report-table td:nth-child(2) {
    width: 20%;
  }

  #painelRelatorioDashboard .report-table th:nth-child(3),
  #painelRelatorioDashboard .report-table td:nth-child(3) {
    width: 12%;
  }

  #painelRelatorioDashboard .report-table th:nth-child(4),
  #painelRelatorioDashboard .report-table td:nth-child(4) {
    width: 7%;
  }

  #painelRelatorioDashboard .report-table th:nth-child(5),
  #painelRelatorioDashboard .report-table td:nth-child(5),
  #painelRelatorioDashboard .report-table th:nth-child(6),
  #painelRelatorioDashboard .report-table td:nth-child(6),
  #painelRelatorioDashboard .report-table th:nth-child(7),
  #painelRelatorioDashboard .report-table td:nth-child(7),
  #painelRelatorioDashboard .report-table th:nth-child(8),
  #painelRelatorioDashboard .report-table td:nth-child(8) {
    width: 10%;
  }

  #painelRelatorioDashboard .report-table th:nth-child(9),
  #painelRelatorioDashboard .report-table td:nth-child(9) {
    width: 11%;
  }

  #painelRelatorioDashboard .food-thumb {
    width: 26px;
    height: 26px;
  }

  .week-bar,
  .progress-fill,
  .report-meal-fill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
