:root {
  --red: #e00000;
  --dark-red: #a90000;
  --black: #0b0b0d;
  --soft-black: #1a1a1f;
  --white: #ffffff;
  --light: #f3f3f3;
  --grey: #707070;
  --green: #118a3b;
  --shadow: 0 12px 30px rgba(0,0,0,.12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg,#fff 0%,#f4f4f4 100%);
  color: var(--black);
  min-height: 100vh;
}
button, input { font: inherit; }
button { cursor: pointer; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  min-height: 88px;
  background: #fff;
  border-bottom: 6px solid var(--red);
  padding: 10px 18px;
  box-shadow: 0 5px 18px rgba(0,0,0,.09);
}
.brand-logo { width: min(430px, 82vw); max-height: 68px; object-fit: contain; margin: 0 auto; }
.back-btn {
  position: absolute;
  left: 14px;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 14px;
  background: var(--black);
  color: white;
  font-size: 34px;
  font-weight: 900;
}
.app-shell { max-width: 920px; margin: 0 auto; padding: 18px 16px 50px; }
.hidden { display: none !important; }
.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 300px;
  border-radius: 28px;
  background: var(--black);
  box-shadow: var(--shadow);
  border: 4px solid var(--black);
}
.hero-card img { width: 100%; height: 100%; min-height: 300px; object-fit: cover; display: block; }
.hero-overlay {
  position: absolute;
  inset: auto 0 0;
  padding: 52px 24px 24px;
  background: linear-gradient(transparent,rgba(0,0,0,.92));
  color: white;
}
.hero-overlay h1 { margin: 0; font-size: clamp(34px,7vw,60px); letter-spacing: 1px; }
.hero-overlay p { margin: 8px 0 0; font-size: clamp(18px,3.6vw,26px); font-weight: 700; }
.today-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 18px 0 24px;
}
.today-summary div {
  border-radius: 22px;
  padding: 20px 14px;
  text-align: center;
  background: var(--black);
  color: white;
  box-shadow: var(--shadow);
}
.today-summary div:last-child { background: var(--red); }
.today-summary span { display:block; font-size: 16px; font-weight: 800; letter-spacing: .5px; }
.today-summary strong { display:block; font-size: clamp(32px,7vw,52px); margin-top: 8px; }
.section-title { font-size: 28px; margin: 28px 0 14px; }
.area-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
.area-card {
  min-height: 150px;
  border: 0;
  border-radius: 22px;
  padding: 0;
  text-align: left;
  background: white;
  border: 3px solid var(--black);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.area-card-main {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 150px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 18px;
  cursor: pointer;
}
.area-card::after {
  content: '';
  position: absolute;
  right: -30px;
  bottom: -45px;
  width: 115px;
  height: 115px;
  transform: rotate(35deg);
  background: var(--red);
}
.area-card h3 { margin:0 0 10px; font-size: clamp(24px,4.8vw,34px); line-height: 1.04; max-width: 85%; }
.area-card p { margin:0; font-size: 18px; font-weight: 800; color: var(--red); }
.primary-big, .secondary-big, .danger-outline {
  width: 100%;
  min-height: 68px;
  border-radius: 18px;
  font-size: 22px;
  font-weight: 900;
  padding: 14px 18px;
}
.primary-big { border:0; background: var(--red); color: #fff; box-shadow: 0 8px 0 var(--dark-red); }
.secondary-big { margin-top: 18px; border: 3px solid var(--black); background: #fff; color: var(--black); }
.danger-outline { margin-top: 24px; border: 3px solid var(--red); background:#fff; color:var(--red); }
.route-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  background: var(--black);
  color:white;
  border-radius:24px;
  padding:22px;
  margin-bottom:16px;
  border-left: 10px solid var(--red);
}
.eyebrow { margin:0 0 6px; color:var(--red); font-weight:900; letter-spacing:.8px; }
.route-head h1 { margin:0; font-size: clamp(30px,6vw,46px); line-height:1.05; }
.route-progress { min-width:88px; text-align:center; font-size:32px; font-weight:900; background:var(--red); padding:14px 10px; border-radius:18px; }
.store-list, .history-list { display:flex; flex-direction:column; gap:14px; }
.store-card {
  background:white;
  border-radius:22px;
  border:3px solid #dedede;
  padding:18px;
  box-shadow:0 8px 20px rgba(0,0,0,.08);
  position: relative;
}
.store-card.visited { border-color: var(--green); background:#f1fff6; }
.store-top { display:flex; justify-content:space-between; gap:14px; align-items:flex-start; }
.store-name { margin:0; font-size: clamp(25px,5vw,38px); line-height:1.05; }
.store-last { margin:9px 0 0; font-size:18px; color:var(--grey); font-weight:700; }
.visited-badge { white-space:nowrap; background:var(--green); color:#fff; padding:8px 10px; border-radius:12px; font-weight:900; }
.visit-btn {
  width:100%;
  min-height:62px;
  margin-top:15px;
  border:0;
  border-radius:16px;
  color:white;
  background:var(--red);
  font-size:22px;
  font-weight:900;
}
.store-card.visited .visit-btn { background:var(--black); }
.modal {
  position:fixed;
  inset:0;
  z-index:40;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  background:rgba(0,0,0,.7);
  padding:14px;
}
.modal-card {
  width:min(680px,100%);
  max-height:94vh;
  overflow:auto;
  background:#fff;
  border-radius:28px 28px 18px 18px;
  padding:26px 20px 22px;
  border-top:9px solid var(--red);
  position:relative;
}
.modal-close { position:absolute; right:14px; top:12px; width:52px; height:52px; border:0; border-radius:50%; background:var(--black); color:#fff; font-size:35px; }
.modal-card h2 { margin:0 58px 12px 0; font-size:34px; }
.auto-stamp { background:#f1f1f1; border:2px solid #d4d4d4; padding:16px; border-radius:16px; font-size:20px; font-weight:900; margin-bottom:20px; }
.modal-card label { display:block; font-size:20px; font-weight:900; margin:18px 0 8px; }
.modal-card label span { color:var(--grey); font-size:15px; }
.modal-card input { width:100%; min-height:62px; border:3px solid var(--black); border-radius:16px; padding:12px 15px; font-size:23px; }
.money-input { display:flex; align-items:center; border:3px solid var(--black); border-radius:16px; overflow:hidden; }
.money-input b { font-size:28px; padding:0 14px; color:var(--red); }
.money-input input { border:0; border-left:2px solid #ddd; border-radius:0; }
.history-card { background:#fff; border:3px solid var(--black); border-left:10px solid var(--red); border-radius:20px; padding:18px; box-shadow:var(--shadow); }
.history-card h3 { margin:0; font-size:28px; }
.history-card .meta { margin:8px 0; font-size:18px; font-weight:800; color:var(--grey); }
.history-card .sale { font-size:22px; font-weight:900; color:var(--red); }
.empty-state { text-align:center; padding:42px 20px; background:#fff; border:3px dashed #aaa; border-radius:22px; font-size:23px; font-weight:800; }
.toast { position:fixed; left:50%; bottom:24px; transform:translateX(-50%); z-index:60; width:min(90vw,520px); background:var(--black); color:#fff; border-left:8px solid var(--red); border-radius:15px; padding:16px 18px; text-align:center; font-size:20px; font-weight:900; box-shadow:var(--shadow); }
@media (max-width: 560px) {
  .topbar { min-height:76px; }
  .brand-logo { max-height:55px; }
  .area-grid { grid-template-columns:1fr; }
  .hero-card, .hero-card img { min-height:250px; }
  .today-summary { grid-template-columns:1fr 1fr; gap:10px; }
  .today-summary span { font-size:13px; }
  .route-head { align-items:flex-start; }
  .route-progress { min-width:75px; font-size:25px; }
}
.helper-text { font-size: 21px; font-weight: 800; color: var(--grey); margin: 2px 2px 18px; }
.history-store-card {
  width: 100%; min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  text-align: left; background: #fff; border: 3px solid var(--black); border-left: 10px solid var(--red);
  border-radius: 20px; padding: 18px; box-shadow: var(--shadow);
}
.history-store-card h2 { margin: 0; font-size: clamp(25px,5vw,36px); line-height: 1.05; }
.history-store-card p { margin: 9px 0 0; font-size: 18px; font-weight: 700; color: var(--grey); }
.visit-count { min-width: 84px; text-align: center; border-radius: 16px; background: var(--black); color: #fff; padding: 11px 8px; font-size: 30px; font-weight: 900; }
.visit-count small { display: block; margin-top: 2px; font-size: 11px; letter-spacing: .6px; }
.history-summary { display: grid; grid-template-columns: 1.4fr .8fr; gap: 12px; margin: 0 0 18px; }
.history-summary div { background: #fff; border: 3px solid var(--black); border-radius: 19px; padding: 16px; text-align: center; }
.history-summary div:last-child { border-color: var(--red); }
.history-summary span { display: block; font-weight: 900; font-size: 14px; color: var(--grey); }
.history-summary strong { display: block; margin-top: 7px; font-size: clamp(23px,5vw,35px); }
.history-line { margin: 10px 0; font-size: 20px; }
@media (max-width: 560px) {
  .history-summary { grid-template-columns: 1fr 1fr; }
  .history-store-card { min-height: 105px; }
  .visit-count { min-width: 72px; font-size: 26px; }
}

.install-big {
  width: 100%; min-height: 68px; margin-top: 14px; border: 0; border-radius: 18px;
  background: var(--black); color: #fff; font-size: 22px; font-weight: 900; padding: 14px 18px;
  box-shadow: 0 7px 0 #333;
}
.install-help {
  margin: 14px 0 0; padding: 15px; border: 2px solid var(--black); border-left: 8px solid var(--red);
  border-radius: 14px; background: #fff; font-size: 18px; line-height: 1.4;
}
.delete-visit-btn {
  width: 100%; min-height: 55px; margin-top: 16px; border: 3px solid var(--red); border-radius: 14px;
  background: #fff; color: var(--red); font-size: 18px; font-weight: 900;
}
.delete-visit-btn:active { background: #fff0f0; }

/* ===== Login ===== */
#loginView { padding-top: 18px; }
.login-card {
  width: min(440px, 100%);
  margin: 30px auto 0;
  background: #fff;
  border-radius: 28px;
  padding: 34px 26px 30px;
  border-top: 9px solid var(--red);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { width: min(260px, 70%); object-fit: contain; margin: 0 auto 10px; }
.login-card h1 { margin: 6px 0 2px; font-size: clamp(28px,6vw,38px); }
.login-sub { margin: 0 0 22px; font-weight: 800; color: var(--grey); font-size: 18px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 18px; font-weight: 900; margin: 16px 0 8px; }
.login-card input {
  width: 100%; min-height: 60px; border: 3px solid var(--black); border-radius: 16px;
  padding: 12px 15px; font-size: 20px;
}
.login-card .primary-big { margin-top: 24px; }
.login-error { margin: 16px 0 0; color: var(--red); font-weight: 900; text-align: center; font-size: 17px; }

.logout-btn {
  position: absolute; right: 14px; height: 48px; padding: 0 16px; border: 0; border-radius: 14px;
  background: var(--red); color: #fff; font-size: 15px; font-weight: 900; letter-spacing: .5px; white-space: nowrap;
}
.offline-banner {
  background: var(--black); color: #fff; text-align: center; font-weight: 900;
  font-size: 14px; padding: 10px 16px; border-bottom: 4px solid var(--red);
}

/* ===== Add / edit / delete affordances ===== */
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 14px; }
.section-row .section-title { margin: 0; }
.add-btn {
  border: 3px solid var(--black); background: #fff; color: var(--black);
  border-radius: 14px; padding: 10px 16px; font-size: 15px; font-weight: 900; white-space: nowrap;
}
.add-btn.full { width: 100%; min-height: 58px; margin-bottom: 16px; font-size: 18px; }
.card-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 2; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--black);
  background: #fff; color: var(--black); font-size: 16px; display: flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn.delete { border-color: var(--red); color: var(--red); }
.store-card .card-actions { top: 16px; right: 16px; }

/* ===== Generic form modal (area/store add-edit) ===== */
.modal-card select {
  width: 100%; min-height: 62px; border: 3px solid var(--black); border-radius: 16px;
  padding: 12px 15px; font-size: 20px; background: #fff; font-weight: 700;
}
#formModalBody .hint { margin: -4px 0 0; font-size: 15px; color: var(--grey); font-weight: 700; }

/* ===== Camera capture ===== */
.photo-section { margin-top: 18px; }
.camera-btn {
  width: 100%; min-height: 68px; border: 0; border-radius: 18px; background: var(--black);
  color: #fff; font-size: 21px; font-weight: 900; box-shadow: 0 7px 0 #333;
}
.photo-preview-wrap { margin-top: 14px; }
.photo-preview-wrap img {
  width: 100%; max-height: 260px; object-fit: cover; border-radius: 16px; border: 3px solid var(--black); display: block;
}
.photo-preview-actions { display: flex; gap: 10px; margin-top: 10px; }
.photo-action-btn {
  flex: 1; min-height: 50px; border: 3px solid var(--black); border-radius: 14px;
  background: #fff; color: var(--black); font-weight: 900; font-size: 15px;
}
.photo-action-btn.remove { border-color: var(--red); color: var(--red); }
.history-photo-thumb {
  margin-top: 12px; width: 100%; max-height: 200px; object-fit: cover;
  border-radius: 14px; border: 3px solid var(--black); cursor: pointer; display: block;
}
.edit-visit-btn {
  width: 100%; min-height: 55px; margin-top: 12px; border: 3px solid var(--black); border-radius: 14px;
  background: #fff; color: var(--black); font-size: 18px; font-weight: 900;
}
.history-card-actions { display: flex; gap: 10px; margin-top: 16px; }
.history-card-actions .edit-visit-btn, .history-card-actions .delete-visit-btn { margin-top: 0; flex: 1; }

.photo-view-card {
  width: min(94vw,720px); max-height: 92vh; background: #000; border-radius: 20px;
  overflow: hidden; position: relative; padding: 0;
}
.photo-view-card img { width: 100%; height: 100%; max-height: 92vh; object-fit: contain; display: block; }
.photo-view-card .modal-close { background: #fff; color: #000; }

@media (max-width: 560px) {
  .login-card { padding: 28px 18px 24px; }
  .section-row { flex-direction: column; align-items: stretch; }
  .add-btn { width: 100%; min-height: 52px; }
  .logout-btn { font-size: 13px; padding: 0 12px; height: 42px; }
}

.store-address { margin: 6px 0 0; font-size: 16px; color: var(--grey); font-weight: 700; }
.quick-delete-visit-btn {
  width: 100%; min-height: 50px; margin-top: 10px; border: 3px solid var(--red); border-radius: 14px;
  background: #fff; color: var(--red); font-size: 15px; font-weight: 900;
}
.quick-delete-visit-btn:active { background: #fff0f0; }
