/* KleCoffee Retro Manager - versão mais limpa e dinâmica */
:root {
  --orange: #E0400D;
  --orange-dark: #aa300b;
  --cream: #fff6e8;
  --soft: #fffaf1;
  --coffee: #2b1710;
  --black: #15110f;
  --muted: #7a6255;
  --line: rgba(43, 23, 16, .16);
  --white: #fff;
  --green: #23a455;
  --green-soft: #ddf8e7;
  --blue: #2563eb;
  --blue-soft: #e7efff;
  --yellow: #f4b400;
  --yellow-soft: #fff4c8;
  --red: #db3b24;
  --red-soft: #ffe2db;
  --shadow: 0 14px 30px rgba(25, 12, 8, .10);
  --shadow-small: 0 8px 18px rgba(25, 12, 8, .08);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(224,64,13,.18), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(255,196,86,.14), transparent 24%),
    linear-gradient(135deg, #31170f, #120806 55%, #281009);
  color: var(--black);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button, input, select {
  font-family: inherit;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.app {
  width: min(1480px, calc(100% - 28px));
  margin: 18px auto 34px;
  border-radius: 28px;
  background: var(--cream);
  box-shadow: 0 20px 70px rgba(0,0,0,.35);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: linear-gradient(90deg, var(--orange), #ff8744);
  color: var(--white);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(255,255,255,.96);
  color: var(--orange);
  font-size: 25px;
  box-shadow: var(--shadow-small);
}

.brand-text h1 {
  font-size: clamp(20px, 3vw, 32px);
  line-height: 1;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.brand-text p {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 700;
  opacity: .92;
  overflow-wrap: anywhere;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: flex-end;
}

.layout {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 760px;
}

.sidebar {
  padding: 18px;
  background: var(--coffee);
  color: var(--white);
}

.menu-title {
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: rgba(255,255,255,.62);
}

.menu {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.btn,
.menu button,
.tiny {
  border: 0;
  border-radius: 14px;
  background: var(--white);
  color: var(--black);
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-small);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  white-space: normal;
  overflow-wrap: anywhere;
}

.btn,
.menu button {
  padding: 11px 13px;
  font-size: 12px;
}

.menu button {
  text-align: left;
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.88);
  box-shadow: none;
}

.btn:hover,
.menu button:hover,
.tiny:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(0,0,0,.14);
}

.btn.primary,
.menu button.active,
.tiny.primary {
  background: var(--orange);
  color: var(--white);
}

.btn.ghost,
.tiny.ghost {
  background: rgba(255,255,255,.92);
}

.btn.danger,
.tiny.danger {
  background: var(--red-soft);
  color: #8a1f10;
}

.tiny {
  padding: 7px 9px;
  font-size: 11px;
}

.side-card {
  padding: 13px;
  margin-bottom: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.10);
}

.side-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
}

.side-card span {
  display: block;
  color: rgba(255,255,255,.75);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.main {
  padding: 20px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.025) 1px, transparent 1px),
    linear-gradient(rgba(0,0,0,.025) 1px, transparent 1px),
    var(--cream);
  background-size: 24px 24px;
}

.view {
  display: none;
  animation: fadeIn .18s ease-out;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: .45; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.panel,
.metric,
.indicator-card,
.card,
.table-wrap,
.modal-card,
.footer-note,
.stat-chip,
.info-box,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
  backdrop-filter: blur(4px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.1;
  letter-spacing: -.03em;
  overflow-wrap: anywhere;
}

.panel-head p {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  position: relative;
  min-height: 118px;
  padding: 15px;
  overflow: hidden;
}

.metric small,
.card-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  overflow-wrap: anywhere;
}

.metric b,
.indicator-card strong,
.stat-chip b {
  display: block;
  line-height: 1.05;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.metric b {
  max-width: calc(100% - 34px);
  font-size: clamp(21px, 2.6vw, 31px);
}

.metric span,
.indicator-card span,
.card p,
.info-box p {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.metric .icon {
  position: absolute;
  top: 13px;
  right: 13px;
  font-size: 25px;
  opacity: .85;
}

.progress {
  height: 9px;
  margin-top: 13px;
  border-radius: 999px;
  background: rgba(224,64,13,.12);
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--orange);
  transition: width .2s ease;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px,1fr));
  gap: 10px;
  width: 100%;
  margin-bottom: 14px;
}

.filters.compact {
  grid-template-columns: repeat(3, minmax(150px,1fr));
}

.field {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--black);
  font-size: 13px;
  font-weight: 650;
  outline: none;
}

.field:focus {
  border-color: rgba(224,64,13,.65);
  box-shadow: 0 0 0 4px rgba(224,64,13,.10);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0,1.35fr) minmax(320px,.65fr);
  gap: 18px;
}

.indicator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 14px;
}

.indicator-card {
  padding: 15px;
  min-height: 258px;
  min-width: 0;
  overflow: hidden;
}

.indicator-card.wide {
  grid-column: span 2;
}

.indicator-card strong {
  margin-bottom: 5px;
  font-size: clamp(23px, 3vw, 34px);
}

.indicator-card canvas,
.chart-panel canvas {
  width: 100% !important;
  max-width: 100%;
  margin-top: 12px;
  display: block;
  box-sizing: border-box;
}

.chip,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #12398a;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tag.paid { background: var(--green-soft); color: #0e7439; }
.tag.pending { background: var(--red-soft); color: #9c2514; }
.tag.partial { background: var(--yellow-soft); color: #865f00; }
.tag.event { background: var(--blue-soft); color: #12398a; }

.mini-list {
  display: grid;
  gap: 10px;
}

.mini-list.compact {
  margin-top: 14px;
}

.mini-item {
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.70);
}

.badge-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--orange);
  color: var(--white);
  font-size: 14px;
  font-weight: 900;
}

.mini-item strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.mini-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-chip {
  padding: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  overflow: hidden;
}

.stat-chip b {
  margin-top: 4px;
  color: var(--black);
  font-size: clamp(17px, 2vw, 22px);
  text-transform: none;
}

.table-wrap {
  overflow-x: auto;
  background: rgba(255,255,255,.92);
}

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

th {
  padding: 12px 11px;
  background: rgba(43,23,16,.07);
  color: #4b3328;
  text-align: left;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  max-width: 260px;
  padding: 12px 11px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 650;
  vertical-align: middle;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.client-name-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--coffee);
  font: inherit;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.client-name-link:hover {
  text-decoration: underline;
}

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

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 14px;
}

.card,
.info-box,
.chart-panel {
  padding: 15px;
  min-width: 0;
  overflow: hidden;
}

.card h3,
.info-box h3 {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.15;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}

.machine-icon {
  width: 58px;
  height: 72px;
  margin-bottom: 12px;
  border-radius: 18px;
  background: linear-gradient(180deg, #313131, #1f1f1f);
  position: relative;
}

.machine-icon::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 31px;
  height: 19px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: #9fe8ff;
}

.machine-icon::after {
  content: "";
  position: absolute;
  bottom: 9px;
  left: 50%;
  width: 26px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: 7px;
  background: var(--white);
}

.report-grid,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0,.8fr) minmax(0,1.2fr);
  gap: 14px;
}

.detail-grid {
  grid-template-columns: repeat(2, minmax(0,1fr));
}

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

.info-row {
  display: grid;
  grid-template-columns: 150px minmax(0,1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.info-row span:first-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.attachment-form {
  display: grid;
  grid-template-columns: 1.1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  margin-bottom: 14px;
}

.attachment-list {
  display: grid;
  gap: 10px;
}

.attachment-item {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.7);
}

.attachment-item strong,
.attachment-item span {
  overflow-wrap: anywhere;
}

.attachment-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.attachment-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.58);
}

.modal-backdrop.show {
  display: grid;
}

.modal-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: var(--cream);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.6);
}

.modal-head h2 {
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 13px;
  padding: 16px;
}

.form-group {
  display: grid;
  gap: 6px;
}

.form-group.full,
.section-title,
.form-actions {
  grid-column: 1 / -1;
}

.form-group.double {
  grid-column: span 2;
}

.form label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.section-title {
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--coffee);
  color: var(--white);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 100;
  transform: translateX(-50%) translateY(120px);
  opacity: 0;
  transition: .22s;
  max-width: min(560px, calc(100% - 28px));
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 18px 44px rgba(0,0,0,.18);
  padding: 13px 16px;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.footer-note {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  background: rgba(43,23,16,.92);
  color: var(--white);
  font-size: 12px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .hero-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }
  .metrics,
  .indicator-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .indicator-card.wide {
    grid-column: span 2;
  }
  .card-grid,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 860px) {
  .app {
    width: calc(100% - 18px);
    margin-top: 10px;
  }
  .topbar,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    padding: 14px;
  }
  .menu {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .metrics,
  .indicator-grid,
  .filters,
  .filters.compact,
  .stat-strip,
  .card-grid,
  .detail-grid,
  .form,
  .attachment-form {
    grid-template-columns: 1fr;
  }
  .indicator-card.wide,
  .form-group.double {
    grid-column: auto;
  }
  .indicator-card {
    min-height: auto;
  }
  .info-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

@media (max-width: 520px) {
  .main {
    padding: 12px;
  }
  .brand {
    align-items: flex-start;
  }
  .logo {
    width: 44px;
    height: 44px;
  }
  .menu {
    grid-template-columns: 1fr;
  }
  .top-actions {
    width: 100%;
  }
  .top-actions .btn {
    flex: 1;
  }
}

/* Correção dos gráficos: impede crescimento vertical infinito ao redesenhar canvas */
#chartRevenueBars,
#chartPaidOpen,
#chartMachines {
  height: 150px !important;
  min-height: 150px !important;
  max-height: 150px !important;
}

#chartTrend {
  height: 160px !important;
  min-height: 160px !important;
  max-height: 160px !important;
}

#chartReport {
  height: 220px !important;
  min-height: 220px !important;
  max-height: 220px !important;
}

/* Ajustes pontuais solicitados: dashboard, máquinas e estoque */
.dashboard-filters {
  grid-template-columns: repeat(4, minmax(145px,1fr));
}

.dashboard-extra {
  grid-template-columns: repeat(6, minmax(0,1fr));
}

.machine-card {
  display: grid;
  align-content: start;
  gap: 5px;
}

.machine-card h3 {
  margin-top: 2px;
  margin-bottom: 4px;
  line-height: 1.25;
}

.machine-card p {
  line-height: 1.45;
  letter-spacing: .01em;
}

.machine-name-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--coffee);
  font: inherit;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.machine-name-link:hover {
  text-decoration: underline;
}

.machine-actions {
  margin-top: 7px;
  gap: 9px;
}

.machine-actions .tiny {
  padding: 8px 10px;
  line-height: 1.2;
}

.machine-photo-wrap {
  width: 76px;
  height: 76px;
  margin-bottom: 12px;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(43,23,16,.08);
  display: grid;
  place-items: center;
}

.machine-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.machine-fallback {
  margin: 0;
  transform: scale(.82);
}

.machine-detail-content {
  padding: 16px;
}

.machine-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
}

.machine-detail-header h3 {
  margin-bottom: 4px;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.1;
}

@media (max-width: 1180px) {
  .dashboard-extra {
    grid-template-columns: repeat(3, minmax(0,1fr));
  }
}

@media (max-width: 860px) {
  .dashboard-filters,
  .dashboard-extra {
    grid-template-columns: 1fr;
  }
  .machine-detail-header {
    align-items: flex-start;
  }
}

/* Ajustes pontuais solicitados: anexos, manutenção, eventos e lucro do estoque */
.form-hint {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.45;
}

.event-product-picker {
  display: grid;
  gap: 9px;
}

.event-product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.72);
}

.event-product-row strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.event-product-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.event-products {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0 2px;
}

.event-products span {
  width: fit-content;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(224,64,13,.10);
  color: var(--coffee);
  font-size: 11px;
  font-weight: 800;
}

.preview-card {
  width: min(1100px, 100%);
}

.file-preview-body {
  padding: 16px;
  min-height: 480px;
}

.file-preview-body iframe,
.file-preview-body img {
  width: 100%;
  height: min(72vh, 720px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  display: block;
}

.file-preview-body img {
  object-fit: contain;
  padding: 10px;
}

.profit.positive { color: #0e7439; }
.profit.negative { color: #9c2514; }

@media (max-width: 860px) {
  .event-product-row {
    grid-template-columns: 1fr;
  }
  .file-preview-body {
    min-height: 320px;
  }
}

#estoque table {
  min-width: 1160px;
}

/* Ajustes adicionais: dashboard, eventos, receber e envio automático */
#chartProducts {
  height: 150px !important;
  min-height: 150px !important;
  max-height: 150px !important;
}

.soft-head {
  margin-top: 4px;
  padding-top: 4px;
}

.event-name-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--coffee);
  font: inherit;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.event-name-link:hover {
  text-decoration: underline;
}

.event-detail-content {
  padding: 16px;
}

.payment-section.hidden,
.hidden {
  display: none !important;
}

.payment-summary {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(224,64,13,.08);
  color: var(--coffee);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.auto-payment-card {
  background:
    linear-gradient(135deg, rgba(224,64,13,.10), rgba(255,255,255,.82));
}

#receber .stat-strip {
  grid-template-columns: repeat(6, minmax(0,1fr));
}

#paymentHistoryRows td,
#receiveRows td {
  vertical-align: top;
}

@media (max-width: 1180px) {
  #receber .stat-strip {
    grid-template-columns: repeat(3, minmax(0,1fr));
  }
}

@media (max-width: 860px) {
  #receber .stat-strip {
    grid-template-columns: 1fr;
  }
}

/* Ajustes incrementais: seleção suspensa de produtos, relatórios e envio automático */
.product-select-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px auto;
  gap: 9px;
  align-items: center;
  margin-bottom: 10px;
}

.selected-products-list {
  display: grid;
  gap: 9px;
}

.selected-product-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.74);
}

.selected-product-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.selected-product-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.74);
  color: var(--coffee);
  font-size: 12px;
  font-weight: 800;
}

.inline-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--orange);
}

#relatorios .panel-head .actions {
  justify-content: flex-end;
}

#relatorios .filters {
  margin-top: 14px;
}

@media (max-width: 760px) {
  .product-select-line,
  .selected-product-item {
    grid-template-columns: 1fr;
  }
}


/* Ajustes incrementais: logo, filtros de eventos/receber e histórico */
.logo.logo-image {
  width: 124px;
  height: 52px;
  padding: 7px 10px;
  border-radius: 18px;
  background: rgba(43,23,16,.22);
}

.logo.logo-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.event-filters,
.receive-filters {
  grid-template-columns: repeat(6, minmax(135px,1fr));
}

.archived-card {
  opacity: .86;
  background: rgba(255,255,255,.66);
}

#paymentHistoryRows .actions {
  min-width: 130px;
}

#paymentHistoryRows td:last-child,
#receiveRows td:last-child {
  min-width: 150px;
}

@media (max-width: 1180px) {
  .event-filters,
  .receive-filters {
    grid-template-columns: repeat(3, minmax(0,1fr));
  }
}

@media (max-width: 860px) {
  .event-filters,
  .receive-filters {
    grid-template-columns: 1fr;
  }
  .logo.logo-image {
    width: 108px;
    height: 48px;
  }
}

.db-chip {
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.14);
}

.db-chip[data-mode="online"] {
  background: rgba(22, 163, 74, .12);
}

.db-chip[data-mode="offline"] {
  background: rgba(224, 64, 13, .14);
}

.db-chip[data-mode="loading"] {
  background: rgba(255,255,255,.08);
}

/* Login e usuários */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 18% 12%, rgba(224,64,13,.25), transparent 30%),
    radial-gradient(circle at 82% 0%, rgba(255,196,86,.16), transparent 28%),
    linear-gradient(135deg, #31170f, #120806 56%, #281009);
}

.login-screen.hidden,
.app.app-locked {
  display: none !important;
}

.login-card {
  width: min(460px, 100%);
  padding: 22px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: 0 24px 80px rgba(0,0,0,.42);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
}

.login-brand h1 {
  font-size: clamp(22px, 4vw, 32px);
  line-height: 1;
  letter-spacing: -.04em;
}

.login-brand p,
.login-message {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.login-message {
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.7);
}

.login-form {
  display: grid;
  gap: 9px;
}

.login-form label,
.action-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.login-form .btn {
  margin-top: 6px;
}

.current-user-chip {
  background: rgba(255,255,255,.18);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.20);
}

.auto-payment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .7fr);
  gap: 14px;
  align-items: start;
}

.auto-payment-actions {
  display: grid;
  gap: 10px;
}

.auto-payment-actions > div {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.68);
}

#usuarios table {
  min-width: 980px;
}

@media (max-width: 860px) {
  .auto-payment-layout {
    grid-template-columns: 1fr;
  }
  .current-user-chip {
    width: 100%;
  }
}

/* Ajustes solicitados: login em página separada + dashboard mais compacto */
.login-shell {
  width: min(1100px, 100%);
  min-height: min(680px, calc(100vh - 36px));
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(360px, .82fr);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 32px;
  background: var(--cream);
  box-shadow: 0 28px 90px rgba(0,0,0,.44);
}

.login-photo-panel {
  position: relative;
  min-height: 560px;
  background:
    linear-gradient(180deg, rgba(18,8,6,.10), rgba(18,8,6,.72)),
    url('../assets/login-coffee-photo.svg') center/cover no-repeat;
}

.login-photo-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 18%, rgba(255,255,255,.14), transparent 28%);
  pointer-events: none;
}

.login-photo-overlay {
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 30px;
  z-index: 1;
  color: var(--white);
}

.login-kicker {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.20);
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.88);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.login-photo-overlay h2 {
  max-width: 520px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: .95;
  letter-spacing: -.06em;
}

.login-photo-overlay p {
  max-width: 420px;
  margin-top: 14px;
  color: rgba(255,255,255,.82);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.42;
}

.login-shell .login-card {
  width: 100%;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: clamp(22px, 4vw, 42px);
}

.metrics {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 96px;
  padding: 12px 13px;
  border-radius: 16px;
}

.metric small,
.card-label {
  margin-bottom: 6px;
  font-size: 10px;
  letter-spacing: .055em;
}

.metric b {
  font-size: clamp(18px, 2.1vw, 25px);
}

.metric span,
.indicator-card span {
  font-size: 11.5px;
}

.metric .icon {
  top: 11px;
  right: 12px;
  font-size: 21px;
}

.progress {
  height: 7px;
  margin-top: 9px;
}

.dashboard-extra.stat-strip,
.dashboard-extra {
  gap: 8px;
  margin-bottom: 12px;
}

.dashboard-extra .stat-chip {
  padding: 10px 11px;
  border-radius: 15px;
}

.dashboard-extra .stat-chip b {
  font-size: clamp(15px, 1.6vw, 19px);
}

.indicator-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
}

.indicator-card {
  min-height: 218px;
  padding: 13px;
  border-radius: 16px;
}

.indicator-card.wide {
  grid-column: span 2;
}

.indicator-card strong {
  margin-bottom: 4px;
  font-size: clamp(19px, 2.2vw, 27px);
}

.indicator-card canvas,
.chart-panel canvas {
  margin-top: 9px;
}

#chartRevenueBars,
#chartPaidOpen,
#chartMachines,
#chartProducts {
  height: 136px !important;
  min-height: 136px !important;
  max-height: 136px !important;
}

#chartTrend {
  height: 150px !important;
  min-height: 150px !important;
  max-height: 150px !important;
}

@media (max-width: 1180px) {
  .indicator-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-photo-panel {
    min-height: 220px;
  }

  .login-photo-overlay {
    left: 22px;
    right: 22px;
    bottom: 22px;
  }

  .login-photo-overlay h2 {
    font-size: clamp(28px, 9vw, 42px);
  }

  .login-shell .login-card {
    min-height: auto;
  }
}

@media (max-width: 520px) {
  .login-screen {
    padding: 10px;
  }

  .login-shell {
    border-radius: 24px;
  }

  .login-photo-panel {
    min-height: 180px;
  }

  .login-photo-overlay p {
    display: none;
  }
}


/* Organização final dos blocos inferiores do Dashboard */
#dashboard .indicator-grid {
  align-items: start;
}

#dashboard .indicator-card.wide,
#dashboard .indicator-grid > .indicator-card:last-child {
  grid-column: span 2;
}

#dashboard .indicator-card.wide {
  min-height: 210px;
}

#dashboard .indicator-grid > .indicator-card:last-child {
  min-height: 210px;
}

#dashboard #quickList {
  gap: 8px;
  margin-top: 10px;
}

#dashboard #quickList .mini-item {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 14px;
}

#dashboard #quickList .badge-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 12px;
}

#dashboard .indicator-card #quickList .mini-item strong {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.15;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

#dashboard .indicator-card #quickList .mini-item span {
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.2;
}

#dashboard #quickList .tag {
  padding: 5px 8px;
  font-size: 10px;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  #dashboard .indicator-card.wide,
  #dashboard .indicator-grid > .indicator-card:last-child {
    grid-column: span 2;
  }
}

@media (max-width: 860px) {
  #dashboard .indicator-card.wide,
  #dashboard .indicator-grid > .indicator-card:last-child {
    grid-column: span 1;
  }
}


/* Ajustes desta versão: dashboard mais dinâmico, edição de clientes e cards de eventos */
.event-card {
  display: grid;
  gap: 12px;
}

.event-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(122,98,85,.14);
}

.event-title-block {
  min-width: 0;
}

.event-period {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.event-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.event-lines {
  display: grid;
  gap: 7px;
}

.event-line {
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding-bottom: 7px;
  border-bottom: 1px dashed rgba(122,98,85,.16);
}

.event-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.event-line span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .03em;
  line-height: 1.25;
}

.event-line strong {
  color: var(--coffee);
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.event-finance-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  padding: 10px 0 2px;
  border-top: 1px dashed rgba(122,98,85,.16);
  border-bottom: 1px dashed rgba(122,98,85,.16);
}

.event-finance-item {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.event-finance-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .03em;
  line-height: 1.2;
}

.event-finance-item strong {
  color: var(--coffee);
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.event-finance-item.highlight strong {
  color: var(--orange);
}

.event-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.event-progress-row span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  line-height: 1.25;
}

.event-progress-row span:last-child {
  text-align: right;
}

.event-actions {
  align-items: center;
}

@media (max-width: 980px) {
  .event-finance-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .event-card-head {
    flex-direction: column;
  }

  .event-tags {
    justify-content: flex-start;
  }

  .event-line {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

.auto-payment-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}

.auto-payment-actions > div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.58);
}

.auto-payment-actions .tiny {
  margin: 3px 4px 0 0;
}

@media (max-width: 980px) {
  .event-info-grid,
  .event-finance-grid,
  .auto-payment-actions {
    grid-template-columns: 1fr;
  }
}
