:root {
  color-scheme: light;
  --blue: #2f80ed;
  --blue-weak: #e8f2ff;
  --green: #1c9b4a;
  --green-weak: #e8f8ec;
  --orange: #ff8a3d;
  --orange-weak: #fff0e5;
  --red: #e84b4b;
  --line: #e6e8ec;
  --text: #1f2a37;
  --muted: #6b7280;
  --bg: #f4f7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.phone {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 40px rgba(31, 42, 55, 0.12);
  padding-bottom: 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 24px 24px;
  background: linear-gradient(135deg, #2878de, #42a5f5);
  color: #fff;
  border-radius: 0 0 22px 22px;
}

.eyebrow {
  margin: 0 0 8px;
  opacity: 0.86;
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.hero-plate {
  align-self: flex-start;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  padding: 10px 12px;
  font-weight: 700;
  min-width: 116px;
  text-align: center;
}

.hero-plate small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 600;
  opacity: 0.84;
}

.panel,
.expense-list,
.expense-title,
.summary {
  margin: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #fff;
}

.grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.combo-field {
  position: relative;
}

.combo-field input {
  padding-right: 46px;
}

.combo-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 18px;
  font-weight: 900;
}

.combo-menu {
  display: none;
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  -webkit-overflow-scrolling: touch;
}

.combo-field.open .combo-menu {
  display: block;
}

.combo-option {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-bottom: 1px solid #eef2f7;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  font: inherit;
}

.combo-option:last-child {
  border-bottom: 0;
}

.combo-option strong {
  font-size: 15px;
}

.combo-option small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.combo-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  resize: vertical;
}

.entry-note {
  margin-top: 12px;
}

.entry-note textarea {
  min-height: 82px;
  line-height: 1.5;
}

.charge-mode-field {
  margin: 12px 0;
}

.charge-percent-grid {
  margin-top: 12px;
}

.mileage-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 16px;
  background: var(--blue-weak);
}

.mileage-card div,
.summary div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mileage-card span,
.summary span {
  color: var(--muted);
  font-size: 12px;
}

.mileage-card strong {
  color: #1557a8;
  font-size: 20px;
}

.mileage-hint {
  margin: 10px 0 0;
  border: 1px solid #f6c56f;
  border-radius: 12px;
  background: #fff8e7;
  color: #8a4b08;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.5;
}

.mileage-reset {
  margin-top: 10px;
  border: 1px solid #f59e0b;
  border-radius: 14px;
  background: #fff7ed;
  color: #7c2d12;
  padding: 12px;
}

.mileage-reset > strong {
  display: block;
  font-size: 15px;
}

.mileage-reset > p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.55;
}

#mileageResetControls {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

#mileageResetControls label:not(.mileage-reset-confirm) {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
}

.mileage-reset-confirm {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.mileage-reset-confirm input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.mileage-reset.needs-fill {
  border-color: #dc2626;
  background: #fef2f2;
}

.mileage-reset-applied {
  border-radius: 10px;
  background: #dcfce7;
  color: #166534;
  padding: 9px 10px;
  font-weight: 700;
}

.daily-meter-upload {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.daily-meter-upload.needs-fill .file-dropzone {
  border-color: #fb923c;
  background: #fff7ed;
}

.auto-info {
  margin-top: 12px;
  border-radius: 14px;
  background: var(--green-weak);
  color: #166534;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

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

.expense-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.expense-title span {
  border-radius: 999px;
  background: var(--green-weak);
  color: var(--green);
  padding: 6px 12px;
  font-weight: 800;
}

.expense-list {
  display: grid;
  gap: 12px;
}

.expense-module-group {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 20px;
  background: linear-gradient(180deg, #fff8f8 0%, #fff 100%);
}

.expense-module-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 3px;
}

.expense-module-heading .icon {
  background: #fee2e2;
  color: #b91c1c;
}

.expense-module-heading strong,
.expense-module-heading small {
  display: block;
}

.expense-module-heading small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.expense-module-list {
  display: grid;
  gap: 10px;
}

.expense-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.expense-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
}

.expense-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.expense-hint {
  display: block;
  margin: 3px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-weight: 900;
}

.fuel .icon {
  background: #ffe4bc;
  color: #b45309;
}

.charge .icon {
  background: #cffafe;
  color: #0e7490;
}

.maintenance .icon {
  background: #fee2e2;
  color: #b91c1c;
}

.travel .icon {
  background: #dbeafe;
  color: #1d4ed8;
}

.other .icon {
  background: #f3f4f6;
  color: #374151;
}

.material .icon {
  background: #dcfce7;
  color: #15803d;
}

.badge {
  border-radius: 999px;
  padding: 5px 10px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.done {
  background: var(--green-weak);
  color: var(--green);
}

.switch {
  position: relative;
  width: 50px;
  height: 28px;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #d1d5db;
  cursor: pointer;
}

.slider::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: 0.18s ease;
}

.switch input:checked + .slider {
  background: var(--blue);
}

.switch input:checked + .slider::after {
  transform: translateX(22px);
}

.expense-body {
  display: none;
  border-top: 1px solid var(--line);
  padding: 14px;
  background: #fbfdff;
}

.expense-card.open > .expense-body {
  display: block;
}

.add-row {
  width: 100%;
  margin-top: 12px;
  min-height: 42px;
  border: 1px dashed #93c5fd;
  border-radius: 12px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 800;
}

.entry {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  margin-bottom: 10px;
}

.material-list {
  display: grid;
  gap: 10px;
}

.material-state {
  margin: 0;
  padding: 12px;
  border: 1px dashed #bfdbfe;
  border-radius: 12px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 14px;
  font-weight: 700;
}

.material-state.warn {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.material-row {
  display: grid;
  grid-template-columns: 1fr 166px;
  align-items: center;
  gap: 10px;
  border: 1px solid #dbe7df;
  border-radius: 14px;
  background: #fff;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
}

.material-row span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.material-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.material-row input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}

.qty-stepper {
  display: grid;
  grid-template-columns: 36px 1fr auto 36px;
  align-items: center;
  border: 1px solid #c7d7e9;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.qty-stepper button {
  width: 36px;
  height: 40px;
  border: 0;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 20px;
  font-weight: 900;
}

.qty-stepper button:disabled {
  color: #a8b3c2;
  background: #f3f4f6;
}

.qty-stepper input[type="number"] {
  border: 0;
  border-left: 1px solid #dbe7f3;
  border-radius: 0;
  min-height: 38px;
  text-align: center;
  font-weight: 800;
  padding: 6px;
}

.qty-stepper input[type="number"]:disabled {
  background: #f8fafc;
}

.qty-stepper em {
  align-self: stretch;
  display: grid;
  place-items: center;
  min-width: 28px;
  border-left: 1px solid #dbe7f3;
  border-right: 1px solid #dbe7f3;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.entry-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
}

.file-dropzone {
  position: relative;
  display: grid;
  gap: 7px;
  border: 1.5px dashed #bfdbfe;
  border-radius: 14px;
  background: #f8fbff;
  padding: 12px;
  cursor: default;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.file-section {
  display: grid;
  gap: 10px;
}

.file-section .file-dropzone {
  min-height: 86px;
}

.file-dropzone strong {
  color: #1d4ed8;
  font-size: 13px;
}

.file-dropzone small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.file-control {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border: 1px solid #c7d7e9;
  border-radius: 12px;
  background: #fff;
  padding: 6px 10px;
}

.upload-picker-trigger {
  width: 100%;
  appearance: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.upload-picker-trigger:active {
  border-color: var(--blue);
  background: var(--blue-weak);
}

.upload-picker-trigger:focus-visible {
  outline: 3px solid rgba(47, 128, 237, 0.2);
  outline-offset: 2px;
}

.file-control.compact {
  grid-template-columns: auto 1fr;
  border-style: dashed;
  background: #fbfdff;
}

.file-action {
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 900;
  padding: 7px 11px;
  white-space: nowrap;
}

.file-names {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-names.done {
  color: var(--green);
}

.native-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-dropzone.dragging {
  border-color: var(--blue);
  background: var(--blue-weak);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.file-list {
  display: grid;
  gap: 8px;
}

.role-file-list {
  display: grid;
  gap: 7px;
}

.role-file-list:not(:empty) {
  margin-top: 3px;
  padding-top: 10px;
  border-top: 1px dashed #dbe7f5;
}

.attachment-result {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  border: 1px solid #e5e7eb;
  border-radius: 11px;
  background: #f8fafc;
  color: var(--muted);
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.attachment-result[hidden],
.ocr-status[hidden] {
  display: none;
}

.attachment-result.loading {
  border-color: #bfdbfe;
  background: var(--blue-weak);
  color: #1d4ed8;
}

.attachment-result.ok {
  border-color: #bbf7d0;
  background: var(--green-weak);
  color: #166534;
}

.attachment-result.warn {
  border-color: #fed7aa;
  background: var(--orange-weak);
  color: #9a3412;
}

.file-list-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #f8fbff;
  padding: 8px 10px;
  font-size: 13px;
}

.role-file-list .file-chip {
  background: #fff;
  padding: 7px;
}

.role-file-list .file-thumb {
  width: 46px;
  height: 46px;
}

.file-thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #eef2f7;
  cursor: pointer;
}

.file-thumb-doc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  cursor: default;
}

.file-chip-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.file-chip small {
  color: var(--muted);
  font-size: 11px;
  flex: 0 0 auto;
}

.file-chip button {
  border: 0;
  border-radius: 9px;
  background: #fff1f2;
  color: var(--red);
  padding: 5px 7px;
  font-weight: 800;
  flex: 0 0 auto;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: rgba(8, 12, 22, 0.9);
  overscroll-behavior: contain;
}

.preview-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.preview-close:active {
  background: rgba(255, 255, 255, 0.32);
}

.preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 12px 12px;
}

.preview-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.preview-caption {
  flex: 0 0 auto;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.preview-open {
  overflow: hidden;
}

.upload-source-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.48);
}

.upload-source-sheet {
  width: min(100%, 448px);
  display: grid;
  gap: 9px;
  border-radius: 20px;
  background: #fff;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.upload-source-heading {
  display: grid;
  gap: 3px;
  padding: 2px 4px 7px;
}

.upload-source-heading strong {
  color: var(--text);
  font-size: 16px;
}

.upload-source-heading small {
  color: var(--muted);
  font-size: 12px;
}

.upload-source-sheet > button {
  width: 100%;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #f8fbff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.upload-source-sheet > button:not(.upload-source-cancel) {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 12px;
}

.upload-source-sheet > button > span:last-child {
  display: grid;
  gap: 3px;
}

.upload-source-sheet > button strong {
  font-size: 15px;
}

.upload-source-sheet > button small {
  color: var(--muted);
  font-size: 12px;
}

.upload-source-sheet > button:active {
  border-color: var(--blue);
  background: var(--blue-weak);
}

.upload-source-icon {
  flex: 0 0 auto;
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 900;
}

.upload-source-icon.album {
  background: #dcfce7;
  color: #15803d;
}

.upload-source-sheet .upload-source-cancel {
  min-height: 46px;
  border-color: #e5e7eb;
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

body.upload-source-open {
  overflow: hidden;
}

.ocr-status {
  white-space: pre-wrap;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

.ocr-status.loading {
  background: var(--blue-weak);
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.ocr-status.ok {
  background: var(--green-weak);
  border-color: #bbf7d0;
  color: #166534;
}

.ocr-status.warn {
  background: var(--orange-weak);
  border-color: #fed7aa;
  color: #9a3412;
}

.needs-fill {
  border-color: #fb923c !important;
  background: #fff7ed !important;
}

.remove {
  border: 0;
  color: var(--red);
  background: #fff1f2;
  border-radius: 10px;
  padding: 6px 8px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.summary strong {
  font-size: 18px;
}

.submit {
  width: calc(100% - 32px);
  margin: 0 16px;
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.submit:disabled {
  opacity: 0.65;
}

.result {
  white-space: pre-wrap;
  margin: 14px 16px 0;
  padding: 12px;
  border-radius: 14px;
  background: #111827;
  color: #d1fae5;
  font-size: 12px;
  display: none;
}
.result.loading {
  background: #0b1220;
  color: #bfdbfe;
}

.result.ok {
  background: #06281c;
  color: #bbf7d0;
}

.result.err {
  background: #2a0f12;
  color: #fecaca;
}

.file-list {
  min-width: 0;
}

.file-chip {
  min-width: 0;
  max-width: 100%;
}

.file-chip small {
  white-space: nowrap;
}

.ocr-status {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 430px) {
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }
}
