/* Taitung credit application — Jira-style theme */
:root {
  --blue: #0052cc;
  --blue-dark: #0747a6;
  --blue-light: #deebff;
  --red: #c8342a; /* Taitung brand red */
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #172b4d;
  --muted: #5e6c84;
  --border: #dfe1e6;
  --danger: #de350b;
  --danger-bg: #ffebe6;
  --green: #00875a;
  --green-bg: #e3fcef;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(9, 30, 66, 0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

/* header */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar img { height: 34px; width: auto; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar h1 { font-size: 16px; margin: 0; }
.topbar p { font-size: 12px; color: var(--muted); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
}

/* layout: rail + content */
.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.rail { display: none; }

@media (min-width: 900px) {
  .layout { grid-template-columns: 240px 1fr; padding: 24px; }
  .rail {
    display: block;
    position: sticky;
    top: 76px;
    align-self: start;
  }
}

.rail ol { list-style: none; margin: 0; padding: 0; }
.rail li {
  padding: 8px 12px;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.rail li .dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  flex: none;
  background: var(--card);
}
.rail li.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.rail li.active { background: var(--blue-light); color: var(--blue-dark); }
.rail li.active .dot { border-color: var(--blue); color: var(--blue); }

/* cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-head h2 { font-size: 15px; margin: 0; flex: 1; }
.card-head .step {
  background: var(--blue-light);
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 12px;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.card-body { padding: 16px 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* fields */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="url"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fafbfc;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
}
.field.error input, .field.error select, .field.error textarea { border-color: var(--danger); }
.field .err {
  display: none;
  color: var(--danger);
  font-size: 12px;
  margin-top: 3px;
}
.field.error .err { display: block; }

.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.checkline input { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.checkline.error { color: var(--danger); }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 4px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: #f0f1f3;
  color: var(--text);
}
.btn:hover { background: #e8eaee; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.subtle { background: transparent; color: var(--blue); }
.btn.subtle:hover { background: var(--blue-light); }
.btn.danger-subtle { background: transparent; color: var(--danger); }
.btn.danger-subtle:hover { background: var(--danger-bg); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.big { width: 100%; padding: 13px; font-size: 16px; }

/* address check — field with button on the right (below on small phones), note underneath */
.addr-row { display: flex; gap: 8px; align-items: stretch; }
.addr-row textarea { flex: 1; min-width: 0; }
.addr-row .btn { flex: none; }
@media (max-width: 639px) {
  .addr-row { flex-direction: column; align-items: flex-end; }
  .addr-row textarea { width: 100%; }
}
.addr-note { display: block; }
.addr-note:empty { display: none; }

/* choice tiles (company selection, own/rent) */
.choice-row { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 2px; }
@media (min-width: 640px) {
  .choice-row { grid-template-columns: 1fr 1fr; }
  .choice-row.three { grid-template-columns: repeat(3, 1fr); }
}
.choice {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 14px 48px;
  min-height: 52px;
  cursor: pointer;
  background: #fafbfc;
  transition: border-color 0.15s, background 0.15s;
  margin: 0;
}
.choice:hover { border-color: #b3bac5; }
.choice input {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--blue);
  cursor: pointer;
}
.choice .choice-title { display: block; font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.3; }
.choice .choice-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.3; }
.choice:has(input:checked) { border-color: var(--blue); background: var(--blue-light); }
.choice:has(input:checked) .choice-title { color: var(--blue-dark); }
.field.error .choice { border-color: var(--danger); }

/* ABN lookup row */
.abn-row { display: flex; gap: 8px; }
.abn-row input { flex: 1; }
.abn-note { font-size: 12px; margin-top: 5px; }
.abn-note.ok { color: var(--green); }
.abn-note.warn { color: #974f0c; }

/* photo capture */
.photo-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  background: #fafbfc;
}
.photo-box.has-image { border-style: solid; padding: 8px; }
.photo-box img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 4px;
  display: block;
  margin: 0 auto 8px;
}
.photo-box .photo-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.photo-box.error-box { border-color: var(--danger); }

/* signature */
.sig-wrap {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  position: relative;
}
.sig-wrap.error-box { border-color: var(--danger); }
.sig-wrap canvas { width: 100%; height: 160px; display: block; border-radius: 6px; touch-action: none; }
.sig-clear { position: absolute; top: 6px; right: 6px; }

/* guarantor / reference cards */
.sub-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  background: #fafbfc;
}
.sub-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sub-card-head h3 { margin: 0; font-size: 14px; }

/* terms box */
.tc-heading { font-size: 14px; margin: 0 0 4px; color: var(--text); }
.tc-box {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafbfc;
  max-height: 240px;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.tc-box h4 { font-size: 13px; color: var(--text); margin: 14px 0 4px; }
.tc-box h4:first-of-type { margin-top: 6px; }
.tc-box p { margin: 0 0 8px; line-height: 1.5; }
.tc-box .tc-updated { font-size: 12px; font-style: italic; color: var(--muted); margin-bottom: 10px; }
.tc-box .tc-contact { color: var(--blue-dark); font-weight: 600; }

/* review summary */
.summary dl { margin: 0; display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }
.summary h4 { margin: 14px 0 6px; font-size: 13px; color: var(--blue-dark); }
.summary h4:first-child { margin-top: 0; }

/* banners */
.banner {
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.banner.show { display: block; }
.banner.danger { background: var(--danger-bg); color: var(--danger); white-space: pre-line; }

/* success screen */
.success {
  text-align: center;
  padding: 40px 20px;
}
.success .tick {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  font-size: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.success .refno {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--blue-dark);
  margin: 10px 0;
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}
.btn.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 0 34px; }
