:root {
  --bg: #eceae6;
  --ink: #1a2228;
  --muted: #5f6b73;
  --card: #f7f5f1;
  --line: rgba(26, 34, 40, 0.1);
  --accent: #c45c26;
  --accent-deep: #9a4318;
  --steel: #2c3942;
  --steel-2: #1a2228;
  --danger: #b42318;
  --ok: #2f6f5e;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display: "Barlow Condensed", "Noto Sans SC", sans-serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(26,34,40,0.04), transparent 180px),
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 11px,
      rgba(26,34,40,0.015) 11px,
      rgba(26,34,40,0.015) 12px
    ),
    var(--bg);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; background: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes kenburns {
  from { transform: scale(1.08) translate3d(0, 0, 0); }
  to { transform: scale(1.14) translate3d(-1.5%, -1%, 0); }
}
@keyframes stripe-in {
  from { width: 0; }
  to { width: 48px; }
}

.animate-rise { animation: rise 0.55s ease both; }

.brand-mark {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 12vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: 0.06em;
  text-transform: none;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0,0,0,0.35);
}
.brand-mark-sm {
  font-size: clamp(1.7rem, 7vw, 2.1rem);
  letter-spacing: 0.08em;
}
.brand-line {
  margin: 10px 0 0;
  color: rgba(255,255,255,0.88);
  font-size: 0.95rem;
  font-weight: 500;
}
.brand-mark::after {
  content: "";
  display: block;
  margin-top: 10px;
  height: 3px;
  width: 48px;
  background: var(--accent);
  animation: stripe-in 0.7s 0.25s ease both;
}

/* —— Login —— */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--steel-2);
}
.auth-hero {
  position: relative;
  min-height: 46vh;
  overflow: hidden;
  background: var(--steel-2) center/cover no-repeat;
  background-image: linear-gradient(180deg, rgba(26,34,40,0.15), rgba(26,34,40,0.72)), var(--hero);
  isolation: isolate;
}
.auth-hero::before {
  content: "";
  position: absolute;
  inset: -4%;
  background: center/cover no-repeat;
  background-image: var(--hero);
  z-index: -2;
  animation: kenburns 18s ease-in-out alternate infinite;
}
.auth-hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(26,34,40,0.2) 0%, rgba(26,34,40,0.55) 45%, rgba(26,34,40,0.92) 100%),
    linear-gradient(90deg, rgba(196,92,38,0.18), transparent 40%);
  z-index: -1;
}
.auth-hero-content {
  position: relative;
  z-index: 1;
  padding: calc(28px + env(safe-area-inset-top)) 22px 28px;
  min-height: 46vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  animation: rise 0.7s ease both;
}
.auth-panel {
  flex: 1;
  margin-top: -18px;
  padding: 22px 18px calc(28px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--card);
  position: relative;
  z-index: 2;
}
.auth-title {
  margin: 0 0 4px;
  font-size: 1.35rem;
  font-weight: 900;
}
.auth-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}
.auth-tip {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 0.88rem;
}

/* —— App shell —— */
.app-body { min-height: 100vh; }
.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 0 calc(28px + env(safe-area-inset-bottom));
}

.masthead {
  position: relative;
  overflow: hidden;
  min-height: 148px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 20px;
  color: #fff;
  isolation: isolate;
}
.masthead::before {
  content: "";
  position: absolute;
  inset: -6%;
  background: center/cover no-repeat;
  background-image: var(--hero);
  z-index: -2;
  animation: kenburns 22s ease-in-out alternate infinite;
}
.masthead-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(26,34,40,0.88) 10%, rgba(26,34,40,0.55) 55%, rgba(196,92,38,0.35) 100%);
  z-index: -1;
}
.masthead-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  animation: rise 0.55s ease both;
}
.masthead .sub {
  margin: 6px 0 0;
  color: rgba(255,255,255,0.78);
  font-size: 0.86rem;
}
.pill {
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-weight: 700;
  font-size: 0.86rem;
  backdrop-filter: blur(6px);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin: -12px 12px 14px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(247, 245, 241, 0.96);
  box-shadow: 0 8px 24px rgba(26,34,40,0.1);
  position: relative;
  z-index: 3;
}
.tab {
  padding: 11px 4px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.tab.active {
  background: var(--steel);
  color: #fff;
}
.tab:active { transform: scale(0.97); }

.panel { padding: 0 14px; }

.summary {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 0;
  margin-bottom: 16px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--steel-2);
  color: #fff;
  box-shadow: 0 12px 28px rgba(26,34,40,0.18);
  animation: rise 0.6s 0.05s ease both;
}
.summary-photo {
  min-height: 100%;
  background: center/cover no-repeat;
}
.summary-body { padding: 14px 14px 14px 12px; }
.summary-label { margin: 0; opacity: 0.72; font-size: 0.8rem; }
.summary-balance {
  margin: 4px 0 12px;
  font-family: var(--mono);
  font-size: clamp(1.45rem, 6.5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.summary-grid > div {
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.summary-grid span { font-size: 0.7rem; opacity: 0.68; }
.summary-grid strong { font-family: var(--mono); font-size: 0.88rem; }

.block { margin-bottom: 18px; }
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.block h2, .sheet-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}
.block-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-deep);
  letter-spacing: 0.04em;
}

.me-banner {
  height: 96px;
  margin: 0 0 14px;
  border-radius: 16px;
  background: center/cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(26,34,40,0.08);
  position: relative;
  overflow: hidden;
}
.me-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(26,34,40,0.35), transparent 60%);
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.toolbar input, .toolbar select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}
.fin-sum {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}
.fin-sum strong { color: var(--ink); font-family: var(--mono); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid rgba(26,34,40,0.05);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.list-item:active { transform: scale(0.985); border-color: rgba(196,92,38,0.35); }
.list-item .t { font-weight: 700; }
.list-item .s { margin-top: 3px; font-size: 0.8rem; color: var(--muted); }
.list-item .r { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.list-item .r.warn { color: var(--accent-deep); }
.list-item .r.bad { color: var(--danger); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(47,111,94,0.12);
  color: var(--ok);
}
.badge.open { background: rgba(196,92,38,0.14); color: var(--accent-deep); }
.badge.done { background: rgba(47,111,94,0.12); color: var(--ok); }
.badge.cancelled { background: rgba(26,34,40,0.08); color: var(--muted); }

.empty, .hint, .loc-status { color: var(--muted); font-size: 0.9rem; }
.empty { padding: 8px 2px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.field span { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.field textarea { min-height: 72px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 800;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(165deg, var(--accent), var(--accent-deep));
  color: #fff;
}
.btn.ghost { background: rgba(26,34,40,0.06); color: var(--ink); }
.btn.danger { background: rgba(180,35,24,0.1); color: var(--danger); }
.btn.sm { padding: 10px 12px; font-size: 0.86rem; white-space: nowrap; }
.btn.block { width: 100%; }
.btn.row { width: 100%; margin-top: 8px; }

.sheet-mask {
  position: fixed; inset: 0;
  background: rgba(26,34,40,0.5);
  z-index: 40;
  animation: rise 0.2s ease both;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: min(92vh, 860px);
  overflow: auto;
  z-index: 50;
  background: #f4f1ec;
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
  animation: rise 0.28s ease both;
}
.sheet-handle {
  width: 42px; height: 4px; border-radius: 99px;
  background: rgba(26,34,40,0.18);
  margin: 6px auto 10px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.text-btn { font-weight: 700; color: var(--accent-deep); }
.sheet-actions { display: flex; gap: 8px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; }

.parts-box {
  border: 1px dashed rgba(26,34,40,0.18);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.55);
}
.part-row {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.9fr auto;
  gap: 6px;
  margin-bottom: 6px;
}
.part-row input {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  width: 100%;
}

@media (min-width: 640px) {
  .auth-hero { min-height: 52vh; }
  .summary { grid-template-columns: 140px 1fr; }
}
