:root {
  --bg: #fff8ef;
  --bg-2: #ffe8d1;
  --card: #ffffff;
  --ink: #1f2732;
  --muted: #5d6a79;
  --accent: #ff6a00;
  --accent-2: #ff9f45;
  --line: #f0dcc8;
  --danger: #b42318;
  --safe-bottom: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at -10% -20%, #ffe2bf 0%, transparent 50%),
    radial-gradient(700px 400px at 100% 10%, #ffd4ba 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
}

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #2f2f2f;
  color: #fff;
  text-align: center;
  padding: 10px 14px;
  font-size: 13px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 700;
  color: #935108;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.small-text {
  font-size: 12px;
}

.status {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  display: grid;
  gap: 14px;
  box-shadow: 0 20px 45px rgba(38, 19, 4, 0.12);
}

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

.compact-form {
  margin-top: 8px;
}

.soft-details {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf9;
  padding: 8px 10px;
}

.soft-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}

.mini-fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.mini-fieldset legend {
  font-size: 12px;
  color: var(--muted);
  padding: 0 6px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 11px 12px;
  min-height: 44px;
}

input:focus,
select:focus {
  outline: 2px solid #ffd4a9;
  border-color: var(--accent-2);
}

button {
  border: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.7;
  cursor: default;
}

.ghost-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 10px;
}

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

.auth-user {
  padding: 0 14px 10px;
  color: var(--muted);
  font-size: 13px;
}

.sync-state {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.view-stack {
  padding: 0 14px calc(88px + var(--safe-bottom));
}

.view-panel {
  display: grid;
  gap: 12px;
}

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

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

.quick-action {
  text-align: left;
  padding: 12px;
  min-height: 52px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.quick-action:focus,
.quick-action:hover {
  border-color: var(--accent-2);
}

.action-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.chip.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
}

.muted-chip {
  color: var(--muted);
}

.muted-row {
  opacity: 0.92;
}

.stepper-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  gap: 8px;
  align-items: center;
}

.stepper-btn {
  min-height: 54px;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 26px;
  font-weight: 700;
  padding: 0;
}

.stepper-value {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf9;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4px 8px;
}

.stepper-value span {
  font-size: 22px;
  font-weight: 800;
}

.stepper-value small {
  color: var(--muted);
  font-size: 12px;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-height: 84px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 7px;
  font-weight: 800;
  font-size: 20px;
}

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

.data-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.data-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  font-size: 14px;
  line-height: 1.35;
}

.soft-panel {
  margin: 0;
  padding: 10px;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(16, 18, 21, 0.88);
  display: grid;
  place-items: center;
  padding: 16px;
}

.scan-panel {
  width: min(420px, 100%);
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.scan-panel video {
  width: 100%;
  border-radius: 12px;
  background: #171717;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  background: rgba(255, 250, 243, 0.95);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.bottom-nav button {
  min-height: 46px;
  border-radius: 12px;
  font-size: 10px;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 700;
  display: grid;
  gap: 2px;
  justify-items: center;
  align-content: center;
  padding: 6px 4px;
}

.bottom-nav button.active {
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.bottom-nav button[aria-current="page"] {
  border-color: var(--accent);
}

.nav-icon {
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.06em;
  color: #8f5b20;
}

.nav-label {
  font-size: 10px;
  line-height: 1.1;
}

@media (min-width: 900px) {
  .app-shell {
    max-width: 920px;
    margin: 0 auto;
  }

  .view-stack {
    padding: 0 18px 100px;
  }

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

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