:root {
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --primary: #ff7a45;
  --primary-dark: #d65c2d;
  --secondary: #f0f0f0;
  --text-main: #222222;
  --text-sub: #888888;
  --danger: #ff4d4f;
  --nav-h: 64px;
  --border-radius-lg: 16px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@supports (height: 100dvh) {
  .app {
    min-height: 100dvh;
  }
}

.app-header {
  padding: calc(10px + env(safe-area-inset-top)) 16px 6px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(245, 245, 247, 0.9);
}

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

.status-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text-sub);
}

.status-pill.online {
  color: #2f7d32;
  border-color: rgba(47, 125, 50, 0.25);
  background: rgba(47, 125, 50, 0.08);
}

.status-text {
  font-size: 12px;
  color: var(--text-sub);
  text-align: right;
  white-space: nowrap;
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.install-hint {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 122, 69, 0.28);
  background: rgba(255, 122, 69, 0.10);
  color: #7a3b22;
}

.install-hint.hidden {
  display: none;
}

.install-hint-text {
  font-size: 12px;
  line-height: 1.3;
}

.install-hint-close {
  border: none;
  background: rgba(0, 0, 0, 0.04);
  color: rgba(0, 0, 0, 0.5);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
}

.app-main {
  flex: 1;
  padding: 0 12px calc(16px + var(--nav-h) + env(safe-area-inset-bottom));
}

/* 隐藏滚动条但保留滚动 */
body::-webkit-scrollbar { width: 0; height: 0; }
.app-main::-webkit-scrollbar { width: 0; height: 0; }
body { scrollbar-width: none; }
.app-main { scrollbar-width: none; -webkit-overflow-scrolling: touch; }

.tab-content.hidden {
  display: none;
}

.toolbar {
  margin-bottom: 12px;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

input[type="search"],
input[type="date"],
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--border-radius-sm);
  border: 1px solid #dddddd;
  font-size: 16px; /* iOS: 防止输入框聚焦自动放大 */
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(255, 122, 69, 0.2);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn.primary {
  background: var(--primary);
  color: #ffffff;
}

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

.btn.secondary {
  background: var(--secondary);
  color: var(--text-main);
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  border: none;
  background: #f5f5f5;
  color: var(--text-sub);
}

.chip.outlined {
  border: 1px solid #dddddd;
  background: #ffffff;
}

.chip.active {
  background: rgba(255, 122, 69, 0.1);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 32px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--border-radius-lg);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-sub);
}

.badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #f5f5f5;
  color: var(--text-sub);
}

.badge.danger {
  background: rgba(255, 77, 79, 0.08);
  color: var(--danger);
}

.card-body {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 6px;
}

.qty-block {
  display: flex;
  flex-direction: column;
}

.qty-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-value {
  font-size: 20px;
  font-weight: 600;
}

.qty-unit {
  font-size: 13px;
  color: var(--text-sub);
}

.qty-edit-link {
  font-size: 12px;
  color: var(--primary-dark);
  text-decoration: underline;
}

.qty-sub {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

.actions-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stepper {
  display: flex;
  gap: 4px;
}

.step-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f7f7f7;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.step-btn:active {
  background: #eaeaea;
}

.danger-text-btn {
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--danger);
  text-align: right;
}

.date-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.date-row label {
  flex: 1;
  font-size: 12px;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.stats-summary {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.stats-item-title {
  font-size: 14px;
  font-weight: 500;
}

.stats-item-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
}

.dialog {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.dialog.hidden {
  display: none;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.dialog-content {
  position: relative;
  background: #ffffff;
  width: 100%;
  max-width: 420px;
  margin: 0 16px;
  border-radius: 20px;
  padding: 16px 16px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.dialog-content h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.dialog-content form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialog-content label {
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  z-index: 20;
}

.nav-button {
  border: none;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
}

.nav-button.active {
  background: rgba(255, 122, 69, 0.14);
  color: var(--primary-dark);
}

.nav-label {
  display: block;
  line-height: 1;
}

@media (min-width: 768px) {
  .app-main {
    max-width: 640px;
    margin: 0 auto;
  }

  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    width: 640px;
    border-radius: 18px 18px 0 0;
  }
}

