/* MaintKit — Apple-style maintenance log */
:root {
  --bg: #f2f2f7;
  --bg-solid: #ffffff;
  --bg-elevated: rgba(255,255,255,.78);
  --fill: rgba(120,120,128,.12);
  --line: rgba(60,60,67,.12);
  --label: #000;
  --muted: rgba(60,60,67,.6);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --purple: #af52de;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-solid: #1c1c1e;
    --bg-elevated: rgba(28,28,30,.82);
    --fill: rgba(120,120,128,.24);
    --line: rgba(84,84,88,.65);
    --label: #fff;
    --muted: rgba(235,235,245,.6);
    --shadow: 0 8px 28px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--label);
  font-family: var(--font); font-size: 17px;
  letter-spacing: -0.022em; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
#app { min-height: 100%; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  padding: calc(8px + var(--safe-top)) 16px 10px;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #64d2ff, #007aff);
  font-size: 18px;
}
.brand strong { display: block; font-size: 17px; font-weight: 600; letter-spacing: -0.03em; }
.brand small { color: var(--muted); font-size: 12px; }
.tabs {
  display: flex; gap: 2px; padding: 2px; overflow-x: auto;
  background: var(--fill); border-radius: 9px; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto; border: 0; background: transparent; color: var(--label);
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  touch-action: manipulation;
}
.tab.active {
  background: var(--bg-solid); font-weight: 600;
  box-shadow: 0 0.5px 1px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  .tab.active { background: #636366; box-shadow: none; }
}

main {
  flex: 1; padding: 18px 16px calc(28px + var(--safe-bottom));
  max-width: 720px; width: 100%; margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; animation: in .28s cubic-bezier(.22,1,.36,1); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
}

.hero {
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: 20px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.hero h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
.hero p { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; margin: 10px 0 12px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.35; }
.foot { margin-top: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat {
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: var(--radius); padding: 12px; box-shadow: 0 0.5px 0 rgba(0,0,0,.04);
}
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.stat strong { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.card {
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: var(--radius); padding: 4px 16px 12px; margin-bottom: 12px;
}
.card-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  touch-action: manipulation; transition: transform .1s ease;
}
.item-card:active { transform: scale(0.985); }
.item-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.item-card .top strong { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.item-card .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.item-card .meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--muted); }

.badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  text-transform: capitalize; white-space: nowrap;
}
.badge.open, .badge.in_progress { background: rgba(0,122,255,.12); color: var(--blue); }
.badge.waiting { background: rgba(255,149,0,.16); color: var(--orange); }
.badge.done { background: rgba(52,199,89,.15); color: var(--green); }
.badge.low { background: var(--fill); color: var(--muted); }
.badge.medium { background: rgba(0,122,255,.12); color: var(--blue); }
.badge.high { background: rgba(255,149,0,.16); color: var(--orange); }
.badge.emergency { background: rgba(255,59,48,.14); color: var(--red); }

.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer;
  font-size: 16px; font-weight: 600; letter-spacing: -0.02em;
  background: var(--fill); color: var(--label); touch-action: manipulation;
  transition: transform .08s ease-out, opacity .1s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.secondary { background: rgba(52,199,89,.14); color: var(--green); }
.btn.ghost { background: transparent; color: var(--blue); border: 0.5px solid var(--line); }
.btn.danger { color: var(--red); background: rgba(255,59,48,.1); }
.btn.block { width: 100%; margin-top: 8px; }

.filter-row, .seg { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip, .seg-btn {
  border: 0; background: var(--fill); color: var(--label);
  padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  cursor: pointer; touch-action: manipulation;
}
.chip.active, .seg-btn.active { background: var(--blue); color: #fff; }

label {
  display: block; font-size: 13px; color: var(--muted);
  padding: 10px 0; border-bottom: 0.5px solid var(--line); margin: 0;
}
label:last-child { border-bottom: 0; }
label input, label select, label textarea {
  display: block; width: 100%; margin-top: 6px;
  background: transparent; border: 0; padding: 0; outline: none;
  font-size: 17px; color: var(--label);
}
label select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M1.4 0L6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 2px center; padding-right: 18px;
}
.check {
  display: flex; align-items: center; gap: 10px; color: var(--label);
  font-size: 16px; padding: 12px 0;
}
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--blue); }
.form-stack h3 { margin: 8px 0 4px; font-size: 20px; letter-spacing: -0.03em; }
hr { border: 0; border-top: 0.5px solid var(--line); margin: 16px 0; }

.kit-summary { padding: 14px 16px; margin-bottom: 12px; }
.kit-summary strong { font-size: 22px; letter-spacing: -0.03em; }
.kit-list { display: flex; flex-direction: column; gap: 8px; }
.kit-cat {
  font-size: 13px; font-weight: 700; color: var(--muted);
  margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em;
}
.kit-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-solid); border: 0.5px solid var(--line);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
  touch-action: manipulation;
}
.kit-item input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--blue); flex-shrink: 0; }
.kit-item .ki-body { flex: 1; min-width: 0; }
.kit-item .ki-body strong { display: block; font-size: 15px; font-weight: 600; }
.kit-item .ki-body span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.kit-item.checked { opacity: 0.72; }
.kit-item.checked strong { text-decoration: line-through; }

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.36); }
.modal-sheet {
  position: relative; z-index: 1; width: min(640px, 100%);
  max-height: 92dvh; overflow: auto;
  background: var(--bg); border-radius: 16px 16px 0 0;
  padding: 4px 16px calc(18px + var(--safe-bottom));
  box-shadow: 0 -8px 40px rgba(0,0,0,.18);
  animation: sheet .32s cubic-bezier(.22,1,.36,1);
}
@keyframes sheet { from { transform: translateY(24px); opacity: .7; } to { transform: none; opacity: 1; } }
.sheet-grab { display: flex; justify-content: center; padding: 8px 0 4px; }
.sheet-grab-pill { width: 36px; height: 5px; border-radius: 999px; background: rgba(120,120,128,.4); }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  position: sticky; top: 0; background: var(--bg); padding: 6px 0 10px; z-index: 2;
}
.sheet-body { padding-bottom: 8px; }

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .hero h1 { font-size: 22px; }
}
