* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1115;
  color: #e6e7e9;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}

header {
  padding: 28px 20px 12px;
  max-width: 600px;
  margin: 0 auto;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

main {
  padding: 8px 20px 40px;
  max-width: 600px;
  margin: 0 auto;
}

h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b8d93;
  margin-bottom: 12px;
  font-weight: 600;
}

.projection {
  background: linear-gradient(180deg, #1c2030, #161924);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid #232838;
}

.totals {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.totals thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b8d93;
  font-weight: 600;
  padding-bottom: 8px;
  text-align: right;
}

.totals thead th:first-child {
  text-align: left;
}

.totals tbody th {
  font-size: 12px;
  color: #8b8d93;
  font-weight: 500;
  text-align: left;
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.totals tbody td {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-align: right;
  letter-spacing: -0.02em;
  padding: 8px 0 8px 12px;
  font-variant-numeric: tabular-nums;
}

.totals tbody tr:first-child td {
  color: #4f7cff;
}

.label {
  font-size: 11px;
  color: #8b8d93;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.basis {
  font-size: 12px;
  color: #8b8d93;
}

.install-banner {
  width: 100%;
  padding: 12px;
  background: #1f4ed8;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
  font-family: inherit;
}

.install-banner:active {
  background: #1a3fbc;
}

.primary-button {
  width: 100%;
  padding: 16px;
  background: #4f7cff;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 28px;
  font-family: inherit;
}

.primary-button:active {
  background: #3f6ae8;
  transform: scale(0.99);
}

.secondary-button-wide {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: #b9bcc4;
  border: 1px solid #2a2f3e;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: -16px;
  margin-bottom: 28px;
  font-family: inherit;
}

.secondary-button-wide:active {
  background: #1a1e2a;
}

.webcam-content {
  max-width: 480px;
}

#webcam-video {
  width: 100%;
  border-radius: 10px;
  background: #000;
  margin-bottom: 12px;
  display: block;
}

.webcam-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.webcam-controls:empty {
  display: none;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.06);
  color: #d0d2d6;
  border: 1px solid #2a2f3e;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.ghost-button.active {
  background: #ffd86b;
  color: #1a1a1a;
  border-color: #ffd86b;
}

.thumbnails {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  min-height: 0;
}

.thumbnails:empty {
  display: none;
}

.thumb {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #2a2f3e;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  border: none;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-buttons.three {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

.modal-buttons.three button {
  margin-bottom: 0;
}

.primary-button:disabled {
  background: #2a2f3e;
  color: #6b6e76;
  cursor: not-allowed;
}

.secondary-button {
  padding: 12px 16px;
  background: transparent;
  color: #e6e7e9;
  border: 1px solid #2a2f3e;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}

.history ul {
  list-style: none;
}

.history li {
  background: #161924;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid #1f2331;
}

.history li.empty {
  color: #8b8d93;
  font-size: 14px;
  text-align: center;
  padding: 28px 16px;
  border: 1px dashed #2a2f3e;
  background: transparent;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.row.amounts {
  margin-top: 8px;
  gap: 24px;
}

.row.amounts > div {
  font-size: 15px;
  color: #d0d2d6;
}

.row.amounts .label {
  display: inline;
  font-size: 11px;
  margin-right: 6px;
}

.date {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}

.delete {
  background: transparent;
  border: none;
  color: #6b6e76;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.delete:active {
  color: #ff6b6b;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-content {
  background: #1c2030;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  border: 1px solid #2a2f3e;
}

.modal-content h2 {
  color: #fff;
  font-size: 18px;
  text-transform: none;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  font-weight: 700;
}

.hint {
  font-size: 13px;
  color: #8b8d93;
  margin-bottom: 18px;
  line-height: 1.4;
}

.modal-content label {
  display: block;
  font-size: 11px;
  color: #8b8d93;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
  font-weight: 600;
}

.modal-content input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  background: #0f1115;
  border: 1px solid #2a2f3e;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-family: inherit;
}

.modal-content input:focus {
  outline: none;
  border-color: #4f7cff;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.modal-buttons button {
  flex: 1;
  margin-bottom: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
  color: #fff;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #2a2f3e;
  border-top-color: #4f7cff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}
