:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-strong: #f0f4ef;
  --ink: #16211d;
  --muted: #62706b;
  --line: #dfe6df;
  --green: #1f7a58;
  --green-soft: #dff1e8;
  --amber: #b76918;
  --amber-soft: #faead7;
  --red: #b33b38;
  --red-soft: #f8dedb;
  --blue: #3267a8;
  --shadow: 0 18px 45px rgba(20, 34, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #14231d;
  color: #f8fbf7;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #e8f6ef;
  color: #173528;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #bbcac3;
  font-size: 13px;
  margin-top: 2px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  height: 44px;
  border: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: transparent;
  color: #d9e3df;
  text-align: left;
}

.nav-tab svg,
.icon-button svg,
.primary-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.nav-tab.active,
.nav-tab:hover {
  background: #21372e;
  color: #ffffff;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 17px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--ink);
}

/* Label usado como botão de import */
.import-label {
  cursor: pointer;
}

.import-label input[type="file"] {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.alert-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.alert {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 700;
}

.alert svg {
  width: 17px;
  height: 17px;
}

.alert.danger {
  background: var(--red-soft);
  color: #792522;
  border-color: #efbfbb;
}

.alert.warning {
  background: var(--amber-soft);
  color: #70400f;
  border-color: #efcfaa;
}

.alert.ok {
  background: var(--green-soft);
  color: #19533d;
  border-color: #bde1cf;
}

.metric,
.panel,
.entry-form,
.list-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  min-height: 154px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric span,
.metric small,
.panel-head span,
.meter-row span,
.meta,
label span {
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 27px;
  line-height: 1.1;
  margin: 10px 0 4px;
  overflow-wrap: anywhere;
}

.metric-chart {
  height: 48px;
  display: flex;
  align-items: end;
  gap: 5px;
  margin-top: 12px;
}

.chart-bar {
  flex: 1;
  min-width: 7px;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--green);
}

.chart-bar.amber {
  background: var(--amber);
}

.chart-bar.negative {
  background: var(--red);
}

.metric.emphasis {
  border-color: #bed9cb;
  background: #f8fcfa;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.indicators-panel {
  margin-top: 14px;
}

.buckets-panel {
  margin-top: 14px;
}

.bucket-table {
  display: grid;
  gap: 8px;
}

.bucket-row {
  display: grid;
  grid-template-columns: minmax(132px, 1.1fr) repeat(3, minmax(96px, 0.7fr));
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.bucket-row div {
  display: grid;
  gap: 3px;
}

.bucket-row span {
  color: var(--muted);
  font-size: 13px;
}

.bucket-row strong {
  overflow-wrap: anywhere;
}

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

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

.report-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.report-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: #fbfcfb;
  border-bottom: 1px solid var(--line);
}

.report-row:last-child {
  border-bottom: 0;
}

.indicator {
  min-height: 118px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.indicator span,
.indicator small {
  color: var(--muted);
}

.indicator strong {
  font-size: 20px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.panel {
  padding: 18px;
}

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

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

.split-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 100px;
  gap: 12px;
  align-items: center;
}

.bar,
.withdrawal-meter {
  height: 10px;
  background: #eef2ef;
  border-radius: 999px;
  overflow: hidden;
}

.bar div,
.withdrawal-meter div {
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 180ms ease;
}

.split-row strong {
  text-align: right;
}

.withdrawal-meter {
  height: 16px;
}

.withdrawal-meter div.warning {
  background: var(--amber);
}

.withdrawal-meter div.danger {
  background: var(--red);
}

.meter-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.bill-strip {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.bill-pill {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.bill-pill.overdue {
  background: var(--red-soft);
  color: #6f1f1d;
}

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

.entry-form.compact {
  grid-template-columns: 1.1fr 0.7fr 0.8fr 0.7fr 0.7fr auto;
  align-items: end;
  margin-bottom: 16px;
}

.routine-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.entry-form.purchase-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.entry-form.stock-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

.entry-form.stock-form .is-hidden {
  display: none;
}

.stock-move-form {
  margin-bottom: 14px;
}

.closing-preview {
  min-height: 100%;
}

.closing-preview .inline-list {
  max-height: 202px;
  overflow-y: auto;
  padding-right: 4px;
}

.compact-split {
  gap: 10px;
}

.auto-cmv-row {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 2px;
}

.split-note {
  color: var(--muted);
  font-size: 13px;
}

.prolabore-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 2px;
}

.prolabore-action div {
  display: grid;
  gap: 3px;
}

.prolabore-action span {
  color: var(--muted);
  font-size: 13px;
}

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

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 14px;
  align-items: start;
}

.entry-form.settings-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-section-title {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 2px;
}

.form-section-title span {
  color: var(--muted);
  font-size: 13px;
}

.wide-row {
  margin-top: 6px;
}

.user-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.compact-list {
  gap: 8px;
}

.user-item {
  box-shadow: none;
}

.user-item .list-item-title strong {
  overflow-wrap: normal;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label.wide {
  grid-column: span 2;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fbfcfb;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid #b9ddcb;
  border-color: #8cc3a7;
}

.primary-button {
  height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  align-self: end;
  white-space: nowrap;
}

.secondary-button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fbfcfb;
  color: var(--green);
  font-weight: 800;
  align-self: end;
  white-space: nowrap;
}

.secondary-button svg {
  width: 18px;
  height: 18px;
}

.icon-button.small {
  width: 32px;
  height: 32px;
  box-shadow: none;
}

.wide-row {
  grid-column: 1 / -1;
}

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

.inline-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.inline-list-item div {
  display: grid;
  gap: 2px;
}

.inline-list-item span,
.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.cash-form {
  margin-top: 14px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  min-width: 104px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

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

.list-item {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.list-item-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.list-item-title strong {
  overflow-wrap: anywhere;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 5px;
  font-size: 13px;
}

.amount {
  font-weight: 800;
  text-align: right;
}

.stock-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.status-field {
  min-width: 126px;
  gap: 4px;
}

.status-field span {
  font-size: 12px;
  text-align: right;
}

.status-select {
  height: 34px;
  padding: 0 9px;
  background: var(--amber-soft);
  border-color: #efcf9a;
  color: #7b420e;
  font-size: 13px;
  font-weight: 700;
}

.status-select.paid {
  background: var(--green-soft);
  border-color: #b6dac8;
  color: #19533d;
}

.stock-movement-list {
  margin-bottom: 14px;
}

.stock-movement-item {
  background: var(--surface-strong);
}

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

.inventory-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.inventory-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
}

.inventory-icon svg {
  width: 22px;
  height: 22px;
}

.inventory-card div,
.inventory-numbers {
  display: grid;
  gap: 3px;
}

.inventory-card span {
  color: var(--muted);
  font-size: 13px;
}

.inventory-numbers {
  text-align: right;
}

.status {
  min-width: 74px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #7b420e;
  font-size: 13px;
  font-weight: 700;
}

.status.paid {
  background: var(--green-soft);
  color: #19533d;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chip.warning {
  background: var(--amber-soft);
  color: #7b420e;
}

.chip.danger {
  background: var(--red-soft);
  color: #7a2523;
}

.warning-text {
  color: var(--amber) !important;
  font-weight: 800;
}

.danger-text {
  color: var(--red) !important;
  font-weight: 800;
}

/* ── Overlay de login ───────────────────────────── */

.login-backdrop {
  position: fixed;
  inset: 0;
  background: #14231d;
  display: grid;
  place-items: center;
  z-index: 300;
  padding: 16px;
}

.login-backdrop[hidden] {
  display: none;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-brand-mark {
  width: 48px;
  height: 48px;
  font-size: 22px;
}

.login-card h2 {
  margin: 0;
  font-size: 22px;
}

.login-subtitle {
  margin: -12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.login-submit {
  width: 100%;
  height: 46px;
  font-size: 15px;
}

/* ── Navegação de meses ─────────────────────────── */

.month-nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.month-nav .icon-button {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  flex-shrink: 0;
}

.month-nav .eyebrow {
  margin: 0;
  min-width: 148px;
}

/* ── Modal de confirmação ───────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  max-width: 360px;
  width: calc(100% - 32px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  display: grid;
  gap: 20px;
}

.modal p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

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

.danger-button {
  background: var(--red) !important;
}

/* ── Painel de lembretes (configurações) ────────── */

.notification-panel {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.notification-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.notification-time-row {
  display: flex;
  align-items: end;
  gap: 10px;
}

.notification-time-label {
  display: grid;
  gap: 6px;
}

.notification-time-label input[type="time"] {
  width: 120px;
  height: 42px;
}

.notification-btn {
  align-self: flex-start;
}

/* ── Toast de feedback ──────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: 8px;
  background: #14231d;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: toast-in 180ms ease;
  max-width: 320px;
}

.toast[hidden] {
  display: none;
}

.toast.error {
  background: var(--red);
}

.toast.warning {
  background: var(--amber);
}

@keyframes toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
    gap: 12px;
  }

  .brand {
    display: none;
  }

  .nav-tabs {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .nav-tab {
    justify-content: center;
    padding: 0 6px;
  }

  .nav-tab span {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .kpi-grid,
  .dashboard-layout,
  .routine-layout,
  .entry-form,
  .entry-form.compact,
  .entry-form.settings-form,
  .entry-form.purchase-form,
  .entry-form.stock-form,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .indicator-grid,
  .stock-summary,
  .report-grid,
  .inventory-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  label.wide {
    grid-column: auto;
  }

  .split-row {
    grid-template-columns: 112px minmax(0, 1fr) 86px;
    font-size: 14px;
  }

  .metric strong {
    font-size: 24px;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 25px;
  }

  .panel-head,
  .list-item {
    grid-template-columns: 1fr;
    display: grid;
  }

  .amount {
    text-align: left;
  }

  .inline-list-item {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    min-width: 0;
  }

  .indicator-grid,
  .stock-summary,
  .report-grid,
  .inventory-board {
    grid-template-columns: 1fr;
  }

  .prolabore-action,
  .inventory-card {
    grid-template-columns: 1fr;
  }

  .inventory-numbers {
    text-align: left;
  }

  .bucket-row {
    grid-template-columns: 1fr;
  }

  .toast {
    bottom: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}
