/* AutoMunchies Inventory — mobile-first PWA */

:root {
  --bg: #2d4463;
  --bg-card: #3d5a80;
  --bg-elevated: #4a6894;
  --bg-input: #345270;
  --orange: #f28c28;
  --orange-light: #ffb347;
  --green: #6bcb77;
  --yellow: #ffd166;
  --red: #ef476f;
  --text: #f4f7fb;
  --text-muted: #c5d4e8;
  --border: rgba(255, 255, 255, 0.14);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: linear-gradient(180deg, #243652 0%, var(--bg) 30%, #1f3148 100%);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

#app {
  min-height: 100dvh;
  padding-bottom: calc(1rem + var(--safe-bottom));
}

.panel {
  padding: 1rem;
}

.panel--center {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  text-align: center;
}

.panel--flush {
  padding-top: 0;
}

.brand-logo {
  width: 96px;
  height: auto;
  margin-bottom: 1rem;
  border-radius: 18px;
}

.title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title--sm {
  font-size: 1.15rem;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.35rem;
  max-width: 28rem;
}

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--orange-light);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem 0.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(36, 54, 82, 0.92);
  backdrop-filter: blur(10px);
}

.topbar__center {
  text-align: center;
}

.topbar__spacer {
  width: 4rem;
}

.form {
  width: min(100%, 24rem);
  margin-top: 1.5rem;
  display: grid;
  gap: 0.85rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  text-align: left;
}

.field span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
}

.field input:focus {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  color: #1f3148;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-sm {
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
}

.error {
  color: #ffb4c0;
  font-size: 0.9rem;
}

.error--floating {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(1rem + var(--safe-bottom));
  background: rgba(239, 71, 111, 0.15);
  border: 1px solid rgba(239, 71, 111, 0.35);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.machine-grid {
  display: grid;
  gap: 0.85rem;
}

.machine-card {
  width: 100%;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  color: inherit;
  cursor: pointer;
}

.machine-card__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.machine-card__code {
  font-size: 0.8rem;
  color: var(--orange-light);
  font-weight: 700;
}

.machine-card h2 {
  font-size: 1.2rem;
}

.machine-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}

.badge--warn {
  background: rgba(255, 209, 102, 0.18);
  color: var(--yellow);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0 1rem 0.75rem;
}

.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.5rem;
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 1.1rem;
}

.stat span {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.row-section {
  margin-bottom: 1rem;
}

.row-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  padding: 0 0.25rem 0.5rem;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

@media (min-width: 520px) {
  .slot-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.slot-card {
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem;
  color: inherit;
  cursor: pointer;
  min-height: 118px;
}

.slot-card--low {
  border-color: rgba(255, 209, 102, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.12);
}

.slot-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
}

.slot-code {
  font-weight: 700;
  color: var(--orange-light);
}

.slot-name {
  font-size: 0.88rem;
  margin: 0.35rem 0 0.5rem;
  min-height: 2.4em;
}

.slot-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.fill-bar {
  display: grid;
  gap: 0.25rem;
}

.fill-bar__track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.fill-bar__value {
  height: 100%;
  border-radius: inherit;
}

.fill-bar__value--good {
  background: var(--green);
}

.fill-bar__value--mid {
  background: var(--yellow);
}

.fill-bar__value--low {
  background: var(--red);
}

.fill-bar__label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 30, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  width: min(100%, 28rem);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px 18px 14px 14px;
  padding: 1.1rem;
  margin-bottom: var(--safe-bottom);
}

.modal .form {
  width: 100%;
  margin-top: 1rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 0.65rem;
}

.tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1rem 0 0.25rem;
}

.tab-bar--3 {
  grid-template-columns: repeat(3, 1fr);
}

.tab-bar--3 .tab {
  font-size: 0.82rem;
  padding: 0.6rem 0.35rem;
}

.tab {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 0.65rem 0.5rem;
  font-weight: 600;
  cursor: pointer;
}

.tab--active {
  background: rgba(242, 140, 40, 0.18);
  border-color: rgba(242, 140, 40, 0.45);
  color: var(--orange-light);
}

.hint {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 0.35rem;
}

.preview {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font-size: 0.9rem;
  display: grid;
  gap: 0.15rem;
}

.history-list {
  display: grid;
  gap: 0.65rem;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
}

.history-item__top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.history-item__top time {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.history-item__meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.25rem;
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem 0.75rem;
}

.setup-panel {
  display: grid;
  gap: 0.85rem;
  max-width: 22rem;
  margin: 0 auto;
  text-align: center;
}

.setup-panel .hint {
  text-align: center;
}

.banner {
  margin: 0 1rem 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.banner--info {
  background: rgba(142, 202, 230, 0.12);
  border: 1px solid rgba(142, 202, 230, 0.35);
  color: var(--text);
}
