* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-bottom: 92px;
  font-family: system-ui, -apple-system, sans-serif;
  background: #f2f3f7;
  min-height: 100vh;
  font-size: 14px;
}

h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
  color: #333;
}

h3 {
  margin: 0 0 16px;
  font-size: 1rem;
  color: #333;
}

.tab {
  display: none;
  padding: 16px 14px 132px;
}

.tab.active {
  display: block;
}

.card {
  background: white;
  padding: 14px;
  margin-top: 10px;
  margin-bottom: 10px;
  border-radius: 16px;
  word-break: break-word;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 700;
  gap: 8px;
}

.card .meta {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #555;
  line-height: 1.5;
}

.card button {
  width: auto;
  margin-top: 10px;
}

.card .detail {
  margin-top: 12px;
}

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

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.badge.low {
  background: #e6f7e6;
  color: #1b5e20;
}

.badge.mid {
  background: #fff4cc;
  color: #7a6200;
}

.badge.high {
  background: #ffe5e5;
  color: #940000;
}

input,
select,
button {
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid #ddd;
  font-size: 14px;
  background: white;
  min-width: 0;
}

select {
  font-size: 14px;
  line-height: 1.4;
  min-height: 48px;
}

option {
  font-size: 14px;
}

input:focus,
select:focus {
  outline: none;
  border-color: #1677ff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.16);
}

button {
  background: #1677ff;
  color: white;
  cursor: pointer;
  border: none;
  font-weight: 600;
  transition: background 0.2s;
}

button:hover {
  background: #0d47a1;
}

button:active {
  transform: scale(0.98);
}

button + button {
  margin-top: 10px;
}

button.secondary-btn {
  background: #e8e8e8;
  color: #333;
}

button.secondary-btn:hover {
  background: #d0d0d0;
}

.delete-btn {
  background: #ff4444;
  margin-top: 8px;
  width: auto;
  color: white;
  padding: 8px 12px;
  font-size: 12px;
}

.delete-btn:hover {
  background: #cc0000;
}

.bottom-delete {
  background: #ff4444;
  color: white;
  margin-top: 20px;
}

.bottom-delete:hover {
  background: #cc0000;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  padding: 16px;
  z-index: 30;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  margin: 0 auto;
  padding: 22px;
  border-radius: 18px;
  max-width: 420px;
  width: 100%;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.fab {
  position: fixed;
  bottom: 96px;
  right: 16px;
  width: 60px;
  height: 60px;
  background: #1677ff;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 22px;
  box-shadow: 0 8px 20px rgba(22, 119, 255, 0.25);
  z-index: 10;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.fab:hover {
  background: #0d47a1;
  box-shadow: 0 12px 24px rgba(22, 119, 255, 0.35);
}

.fab:active {
  transform: scale(0.95);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 62px;
  background: white;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.08);
  padding: 0 8px;
  gap: 4px;
  z-index: 10;
}

.nav-item {
  flex: 1;
  text-align: center;
  font-size: 16px;
  padding: 10px 4px;
  color: #444;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  background: none;
  border: none;
}

.nav-item:active {
  background: rgba(22, 119, 255, 0.1);
}

.nav-item.active {
  color: #1677ff;
}

#toast {
  position: fixed;
  bottom: 118px;
  left: 50%;
  transform: translateX(-50%);
  background: #1677ff;
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.2s ease;
  max-width: calc(100vw - 40px);
  text-align: center;
  z-index: 20;
  font-weight: 500;
}

#toast.show {
  opacity: 1;
}

canvas {
  width: 100% !important;
  height: 260px !important;
  max-height: 320px;
}

/* CUSTOM ALERT STYLES */
.custom-alert {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.alert-box {
  position: relative;
  background: white;
  padding: 24px;
  border-radius: 16px;
  max-width: 320px;
  width: calc(100% - 40px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  text-align: center;
  font-size: 14px;
}

.alert-message {
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  margin-bottom: 20px;
}

.alert-btn {
  padding: 14px 26px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  width: auto;
  margin: 0;
}

.alert-btn + .alert-btn {
  margin-left: 10px;
}

.alert-btn.cancel-btn {
  background: #e8e8e8;
  color: #333;
}

.alert-btn.cancel-btn:hover {
  background: #d0d0d0;
}

.alert-btn.confirm-btn {
  background: #1677ff;
  color: white;
}

.alert-btn.confirm-btn:hover {
  background: #0d47a1;
}

@media (max-width: 600px) {
  .tab {
    padding: 14px 10px 140px;
  }

  .card {
    padding: 12px;
    border-radius: 14px;
  }

  h2 {
    font-size: 1.2rem;
  }

  input,
  select,
  button {
    font-size: 12px;
    padding: 12px;
  }

  .modal-content {
    margin: 0 auto;
    padding: 16px;
    border-radius: 16px;
  }

  .fab {
    bottom: 102px;
    right: 14px;
    width: 54px;
    height: 54px;
    font-size: 20px;
  }

  .bottom-nav {
    height: 64px;
  }

  .nav-item {
    font-size: 14px;
    padding: 8px 2px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .alert-box {
    max-width: 280px;
  }

  .alert-btn {
    padding: 10px 16px;
    font-size: 11px;
  }
}