:root {
  --bg: #f6f6f2;
  --panel: #fff;
  --text: #202322;
  --muted: #6b706e;
  --line: #deded6;
  --primary: #126b5c;
  --primary-dark: #0d5147;
  --danger: #b83d2f;
  --danger-bg: #fff0ed;
  --ok-bg: #e9f5f1;
  --shadow: 0 10px 22px rgba(22, 30, 28, .08);
}

* { box-sizing: border-box; }

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

button, input, select, textarea { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  background: rgba(246, 246, 242, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar > .round {
  position: absolute;
  right: 16px;
  top: 14px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.topbar p, h1, h2, h3 { margin: 0; }
.topbar p { color: var(--muted); font-size: .82rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.04rem; margin-bottom: 10px; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .08);
}

main {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 14px 14px 92px;
}

.view { display: none; }
.view.active { display: block; }

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

.head.tight { margin-bottom: 8px; }

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

.stats article, .panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stats article {
  min-height: 88px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stats span, .muted {
  color: var(--muted);
  font-size: .9rem;
}

.stats strong {
  font-size: 1.38rem;
}

.stats .danger, .warning {
  background: var(--danger-bg);
  border-color: #efc0b7;
}

.stats .action-card {
  cursor: pointer;
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.stats .action-card span {
  color: rgba(255, 255, 255, .82);
}

.stats .action-card strong {
  font-size: 1.15rem;
}

.quick {
  margin: 14px 0;
}

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

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: .92rem;
}

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

textarea { min-height: 84px; resize: vertical; }

button, .quick a {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.primary:hover { background: var(--primary-dark); }

.small {
  min-height: 38px;
  padding: 8px 10px;
}

.round {
  min-width: 42px;
  width: 42px;
  min-height: 42px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.25rem;
}

.tabs button {
  min-height: 52px;
  border: 0;
  background: transparent;
  padding: 6px 4px;
  font-size: .78rem;
}

.tabs button.active {
  background: var(--ok-bg);
  color: var(--primary-dark);
}

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

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

.cards { margin-top: 12px; }

.card {
  padding: 14px;
}

.card-title {
  margin: 0 0 4px;
  font-weight: 850;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.35;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

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

.sale-card {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.sale-card:last-child {
  border-bottom: 0;
}

.sale-head, .sale-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.sale-head {
  align-items: center;
  justify-content: flex-end;
}

.sale-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content 58px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fafaf8;
}

.sale-money {
  display: grid;
  gap: 2px;
  text-align: right;
  white-space: nowrap;
}

.sale-money span {
  color: var(--primary-dark);
  font-size: .82rem;
  font-weight: 800;
}

.sale-detail {
  min-height: 36px;
  padding: 7px 6px;
  font-size: .82rem;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 16px;
}

.auth-box {
  width: min(420px, 100%);
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: .85rem;
}

.notice {
  margin: 14px 0;
  padding: 10px 12px;
  border-radius: 8px;
}

.notice.success { background: var(--ok-bg); color: var(--primary-dark); }
.notice.error { background: var(--danger-bg); color: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--primary-dark);
  font-size: .78rem;
  font-weight: 850;
  white-space: nowrap;
}

.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.inline-actions {
  display: flex;
  gap: 6px;
}

#reportes .stats {
  margin-top: 14px;
}

.actions button { flex: 1; }

.total {
  min-height: 54px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--ok-bg);
  border-radius: 8px;
}

.total strong { font-size: 1.35rem; }

dialog {
  width: min(560px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .25);
}

dialog::backdrop { background: rgba(0, 0, 0, .36); }
.modal { padding: 16px; }

#toast {
  display: none;
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 84px;
  z-index: 30;
  padding: 12px 14px;
  border-radius: 8px;
  background: #1f2d2a;
  color: #fff;
  box-shadow: var(--shadow);
}

#toast.show { display: block; }

@media (min-width: 760px) {
  main { padding: 20px; }
  .tabs {
    position: sticky;
    top: 68px;
    bottom: auto;
    width: min(980px, calc(100% - 40px));
    margin: 16px auto 0;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
  .sale-item {
    grid-template-columns: minmax(0, 1fr) max-content 58px;
  }
}
