* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
  padding-bottom: 2rem;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 1rem 0.75rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

header h1 {
  font-size: 0.85rem;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.total-remain {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1.1;
  transition: color 0.3s;
}

.total-remain.safe { color: #16a34a; }
.total-remain.warn { color: #ca8a04; }
.total-remain.danger { color: #dc2626; }

.total-sub {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.toolbar button {
  background: #e2e8f0;
  color: #475569;
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.toolbar button:active {
  background: #cbd5e1;
}

/* Zone grid */
.zones {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
  max-width: 480px;
  margin: 0 auto;
}

.zone-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #e2e8f0;
  gap: 0.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.zone-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.zone-name {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 2.5rem;
  color: #1e293b;
}

.btn-edit {
  background: none;
  border: 1px solid #cbd5e1;
  color: #64748b;
  font-size: 0.65rem;
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-edit:active {
  background: #e2e8f0;
}

.zone-bar-wrap {
  flex: 1;
  min-width: 0;
}

.zone-count-text {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-bottom: 0.15rem;
  display: flex;
  justify-content: space-between;
}

.zone-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.zone-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s, background 0.3s;
}

.fill-safe { background: #22c55e; }
.fill-warn { background: #eab308; }
.fill-danger { background: #ef4444; }

/* Buttons */
.zone-btns {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.zone-remain {
  font-size: 1.4rem;
  font-weight: 800;
  min-width: 2ch;
  text-align: center;
  color: #1e293b;
}

.btn {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 0.5rem;
  border: none;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  line-height: 1;
}

.btn:active { transform: scale(0.92); }

.btn-in {
  background: #dcfce7;
  color: #16a34a;
}
.btn-in:disabled {
  background: #f1f5f1;
  color: #a3d4a3;
}

.btn-out {
  background: #fee2e2;
  color: #dc2626;
}
.btn-out:disabled {
  background: #f5f1f1;
  color: #d4a3a3;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.5rem;
  width: 85%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.modal h2 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #1e293b;
}

.modal p {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 1rem;
}

.modal-btns { display: flex; gap: 0.5rem; }

.modal-btns button {
  flex: 1;
  padding: 0.6rem;
  border-radius: 0.5rem;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.modal-cancel {
  background: #e2e8f0;
  color: #1e293b;
}

.modal-confirm {
  background: #dc2626;
  color: #ffffff;
}

.modal-apply {
  background: #2563eb;
  color: #ffffff;
}

/* Edit input */
.edit-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1rem;
  outline: none;
  color: #1e293b;
  background: #f8fafc;
}

.edit-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
