/* ==========================================================================
   SECTION 1: CORE TOKENS & TYPOGRAPHY STACK
   ========================================================================== */

@font-face {
  font-family: WrapKorean;
  src: url('./vendor/NotoSansKR.ttf') format('truetype');
  font-display: swap;
}

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

:root {
  color-scheme: dark;
  --bg: #141618;
  --panel: #1e2225;
  --panel-card: #252a2e;
  --line: #2f363c;
  --muted: #8b979f;
  --text: #f0f4f6;
  --accent: #a8c3d0;
  --accent-hover: #c4d9e3;
  --green: #4ade80;

  --font-body: 'Montserrat', WrapKorean, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-accent: 'Space Grotesk', monospace, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

:lang(ko) {
  font-family: 'Montserrat', WrapKorean, -apple-system, sans-serif;
  word-break: keep-all;
  letter-spacing: -0.02em;
}

button,
input,
select,
textarea {
  font-family: var(--font-body);
  color: inherit;
}

/* Base Unified Button Styling */
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #252b2f;
  color: var(--text);
  border-radius: 8px;
  padding: 0 16px;
  min-height: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

button:hover {
  background: #2f373d;
  border-color: #434e56;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Inputs, Selects & Date Pickers Unified */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  display: block;
  width: 100%;
  background: #181b1d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 44px;
  height: 44px;
  font-family: var(--font-body);
  font-size: 14px !important;
  color: var(--text) !important;
  opacity: 1 !important;
  -webkit-text-fill-color: var(--text) !important;
  -webkit-appearance: none;
  appearance: none;
}

/* Clear Distinction for Placeholders */
input::placeholder,
textarea::placeholder {
  color: var(--muted) !important;
  opacity: 0.42 !important;
  font-style: italic;
  letter-spacing: normal;
  font-weight: 400;
  -webkit-text-fill-color: var(--muted) !important;
}

input:focus::placeholder,
textarea:focus::placeholder {
  opacity: 0.25 !important;
}

input:not(:placeholder-shown),
textarea:not(:placeholder-shown) {
  color: var(--text) !important;
  opacity: 1 !important;
  font-style: normal;
  -webkit-text-fill-color: var(--text) !important;
}

select {
  padding-right: 32px !important;
  cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%238b979f" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
}

input[type="date"] {
  min-height: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 14px !important;
  line-height: 44px !important;
  font-size: 14px !important;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  opacity: 1 !important;
}

input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  line-height: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
}

textarea {
  resize: vertical;
  min-height: 84px;
  height: auto;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

label input:not([type="checkbox"]),
label select,
label textarea {
  margin-top: 6px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

/* Guide hint on fresh shoot load */
.guide-hint {
  color: var(--accent) !important;
  font-weight: 600;
  margin-top: 6px;
  font-size: 11px;
}

/* ==========================================================================
   GAME-HUD TOAST (RESPONSIVE WRAPPING & NO TRUNCATION)
   ========================================================================== */

.hud-toast {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -18px) scale(0.96);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 480px);
  padding: 10px 18px;
  background: rgba(18, 21, 24, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(168, 195, 208, 0.28);
  border-radius: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 12px rgba(168, 195, 208, 0.15);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.22s ease,
    visibility 0.22s ease;
}

.hud-toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
}

.hud-toast.is-error {
  border-color: rgba(229, 135, 131, 0.45);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 14px rgba(229, 135, 131, 0.2);
}

.hud-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}

.hud-toast.is-error .hud-dot {
  background: #e58783;
  box-shadow: 0 0 8px #e58783;
}

.hud-text {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  white-space: normal;
  /* Permits 2-line wraps cleanly on mobile */
  line-height: 1.35;
}

dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  max-width: 480px;
  width: calc(100% - 32px);
  background: #1e2225;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  z-index: 1000;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* ==========================================================================
   SPACE GROTESK TECHNICAL ACCENTS
   ========================================================================== */

.eyebrow,
.beta,
.section-head .tag,
.badge,
.steps button span,
#inspect-counter,
.invoice-paper .inv-tag,
.invoice-paper small,
.preview-prompt-bar span,
footer {
  font-family: var(--font-accent);
  letter-spacing: 0.8px;
}

.row-top strong,
.total strong,
.sum-row strong,
#save-status,
input[type="date"],
.status-indicator-pill {
  font-family: var(--font-accent);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   SECTION 2: HEADER & PRODUCTION ISLAND
   ========================================================================== */

.topbar {
  min-height: 64px;
  height: auto;
  padding-top: env(safe-area-inset-top);
  padding-left: max(5%, env(safe-area-inset-left));
  padding-right: max(5%, env(safe-area-inset-right));
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #141618;
  position: relative;
  z-index: 50;
}

.brand {
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.beta {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-weight: 600;
  margin-left: 4px;
}

.setup-btn {
  background: #252b2f;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
}

main {
  max-width: 1400px;
  margin: auto;
  padding: 32px max(5%, env(safe-area-inset-right)) calc(100px + env(safe-area-inset-bottom)) max(5%, env(safe-area-inset-left));
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  gap: 20px;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}

h1 {
  font-size: clamp(28px, 3.5vw, 44px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -1.2px;
  margin-bottom: 6px;
}

h1 span {
  color: var(--accent);
}

.masthead p {
  font-size: 13px;
  color: var(--muted);
}

/* Production Island */
.project-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  min-height: 48px;
  box-sizing: border-box;
}

.deck-current {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.deck-current strong {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

#save-status {
  font-size: 10px;
  color: var(--green);
  margin-left: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.deck-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.switch-btn-wrap {
  position: relative;
  width: 96px;
}

.switch-btn-wrap select {
  height: 36px !important;
  min-height: 36px !important;
  line-height: 36px !important;
  padding: 0 24px 0 10px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 6px;
  background-color: #252b2f !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="%238b979f" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>') !important;
  background-repeat: no-repeat !important;
  background-position: right 8px center !important;
  background-size: 10px !important;
}

.switch-btn-wrap select:hover {
  border-color: var(--accent) !important;
}

.action-btn-icon-only {
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  font-size: 16px !important;
  border-radius: 6px;
  flex-shrink: 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
  gap: 8px;
}

.steps button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  text-align: left;
  padding: 14px 12px 16px;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: auto;
  height: auto;
}

.steps button span {
  font-size: 11px;
  color: var(--muted);
}

.steps button.active {
  color: var(--text);
  border-color: var(--accent);
}

.steps button.active span {
  color: var(--accent);
  font-weight: bold;
}

/* ==========================================================================
   SECTION 3: WORKSPACE & FORM ERGONOMICS
   ========================================================================== */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
}

.panel {
  padding: 26px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  margin-bottom: 24px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head>div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.section-head h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.section-head p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.section-head .tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--muted);
  text-transform: uppercase;
  text-align: right;
  white-space: pre-line;
  line-height: 1.35;
  opacity: 0.55;
  flex-shrink: 0;
  padding-top: 2px;
  border: 0 !important;
  background: transparent !important;
}

.inline-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.inline-action-row label {
  margin-bottom: 0;
}

.inline-action-row button {
  height: 44px !important;
  min-height: 44px !important;
  margin: 0 !important;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.full {
  grid-column: 1/-1;
}

.profile-vault-card {
  background: #181b1d;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  transition: border-color 0.2s ease;
}

.profile-vault-card.locked {
  border-left: 4px solid var(--accent);
}

.profile-vault-card.editing {
  border: 1px dashed var(--accent);
  background: #1a1e21;
}

.profile-vault-card input:disabled,
.profile-vault-card textarea:disabled {
  background: #141618 !important;
  color: #a4b0b6 !important;
  border-color: #262c30 !important;
  cursor: not-allowed;
}

.vault-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.vault-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.vault-icon {
  font-size: 14px;
}

.terms-due-cell {
  width: 100%;
}

.terms-split-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  width: 100%;
}

.terms-split-row .select-chevron-wrap {
  width: 120px;
}

.terms-split-row input[type="date"] {
  flex: 1;
  margin: 0 !important;
  height: 44px !important;
  min-height: 44px !important;
}

.row-card {
  padding: 20px;
  background: var(--panel-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 16px 0;
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.row-top strong {
  color: var(--accent);
  font-size: 14px;
}

.remove {
  font-size: 11px;
  padding: 0 12px;
  min-height: 36px;
  height: 36px;
  background: transparent;
  color: #e58783;
  border-color: #553333;
}

.remove:hover {
  background: #3d2323;
}

.danger-btn {
  color: #e58783 !important;
  border-color: #553333 !important;
}

.danger-btn:hover {
  background: #3d2323 !important;
  border-color: #774444 !important;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #181b1d;
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  width: fit-content;
  user-select: none;
}

.check-pill input[type="checkbox"] {
  width: 18px !important;
  min-height: 18px !important;
  height: 18px !important;
  margin: 0 !important;
  cursor: pointer;
  accent-color: var(--accent);
  display: inline-block !important;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.receipt-card .actions button {
  height: 44px !important;
  min-height: 44px !important;
  font-size: 13px !important;
  padding: 0 16px !important;
  font-weight: 600;
  border-radius: 8px;
}

.ocr-notice-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(168, 195, 208, 0.08);
  border: 1px solid rgba(168, 195, 208, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text);
}

.ocr-notice-bar a {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.upload-box {
  border: 1px dashed #3e4950;
  background: #181c1e;
  border-radius: 12px;
  text-align: center;
  padding: 24px 16px;
  transition: border-color 0.2s ease, background 0.2s ease;
  position: relative;
}

.upload-box.dragover {
  border-color: var(--accent);
  background: #1e262b;
}

.upload-box .box-icon {
  width: 32px;
  height: 32px;
  fill: var(--accent);
  margin: 0 auto 10px;
  display: block;
}

.upload-box h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-box p {
  font-size: 12px;
  color: var(--muted);
}

.upload-progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(168, 195, 208, 0.15);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
  animation: pulse 1.6s infinite ease-in-out;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.8;
    transform: scale(0.98);
  }
}

.file-actions-grid {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.file-button {
  position: relative !important;
  overflow: hidden !important;
  cursor: pointer !important;
}

.file-button input[type="file"],
.upload-box input[type="file"],
.deck-row input[type="file"] {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  cursor: pointer !important;
  z-index: 2 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  pointer-events: auto !important;
  font-size: 0 !important;
}

.file-actions-grid .file-button,
.file-actions-grid button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #252b2f !important;
  color: var(--text) !important;
  border-radius: 8px;
  padding: 0 16px;
  min-height: 44px;
  height: 44px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.file-actions-grid .file-button:hover,
.file-actions-grid button:hover {
  background: #2f373d !important;
  border-color: var(--accent) !important;
}

.btn-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.receipt-card {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 16px;
}

.receipt-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  background: #101213;
  border-radius: 8px;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  color: #dcb378;
}

.badge.verified {
  color: var(--green);
}

.summary {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  background: linear-gradient(160deg, #22272b, #191c1e);
  position: sticky;
  top: 24px;
}

.summary h2 {
  font-size: 18px;
  margin: 14px 0;
  overflow-wrap: anywhere;
}

.rule {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.sum-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #a4b0b6;
  margin: 12px 0;
}

.sum-row strong {
  color: #fff;
}

.total {
  border-top: 1px solid #384248;
  padding-top: 18px;
  margin-top: 20px;
}

.total span {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--muted);
}

.total strong {
  display: block;
  font-size: 32px;
  font-weight: 600;
  color: var(--accent);
  margin: 4px 0 14px;
}

/* ==========================================================================
   STATUS INDICATOR PILL (REVIEWS ONLY — HIDDEN WHEN EMPTY)
   ========================================================================== */

.status-indicator-pill {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 14px 0 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 1px solid rgba(227, 184, 121, 0.25);
  background: rgba(227, 184, 121, 0.08);
  color: #e3b879;
  transition: all 0.15s ease;
}

/* Zero Ghost Boxes: Explicitly hide when hidden attribute is present */
.status-indicator-pill[hidden] {
  display: none !important;
}

.status-indicator-pill:hover {
  background: rgba(227, 184, 121, 0.16);
  border-color: rgba(227, 184, 121, 0.45);
}

.status-indicator-pill .pill-dot {
  font-size: 8px;
  margin-right: 6px;
  display: inline-block;
}

.status-indicator-pill .pill-arrow {
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.15s ease;
}

.status-indicator-pill:hover .pill-arrow {
  transform: translateX(2px);
}

.status-indicator-pill.verified {
  color: var(--green);
  background: rgba(74, 222, 128, 0.08);
  border-color: rgba(74, 222, 128, 0.2);
  justify-content: center;
  cursor: default;
}

.primary {
  background: var(--accent);
  color: #12181b;
  border: 0;
  font-weight: 600;
}

.primary:hover {
  background: var(--accent-hover);
}

.wide {
  width: 100%;
  justify-content: center;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  margin-top: 50px;
  padding-top: 23px;
  font-size: 9px;
  letter-spacing: 1.2px;
  color: var(--muted);
}

/* ==========================================================================
   SECTION 4: INVOICE DECK & BALANCED 2x2 ACTION GRID
   ========================================================================== */

.swatch-group {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  align-items: center;
}

.swatch-btn {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.swatch-btn.active {
  border-color: #ffffff;
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.deck-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  width: 100%;
}

.deck-row .file-button.deck-btn,
.deck-row button {
  flex: 1 1 0;
  width: 100%;
  background: #252b2f !important;
  color: #f0f4f6 !important;
  border: 1px solid var(--line) !important;
  font-weight: 600;
  padding: 0 14px;
  min-height: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 12px;
  letter-spacing: 0.3px;
  box-sizing: border-box;
}

/* Equalized 2x2 Button Grid */
.invoice-action-bar {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px !important;
  margin-top: 24px !important;
  width: 100% !important;
}

.invoice-action-bar button {
  width: 100% !important;
  height: 44px !important;
  min-height: 44px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  box-sizing: border-box !important;
}

.preview-prompt-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 22px 0 10px;
  padding: 0 4px;
  flex-wrap: wrap;
}

.preview-prompt-bar span {
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.edit-zoom-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(168, 195, 208, 0.12);
  border: 1px solid rgba(168, 195, 208, 0.3);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.preview-viewport-box {
  width: 100%;
  background: #101214;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  cursor: pointer;
}

.preview-scaler-stage {
  width: 680px;
  transform-origin: top center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.invoice-paper {
  background: #ffffff;
  color: #1a1a1a;
  padding: 44px 40px;
  width: 680px;
  min-width: 680px;
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.45);
  font: 12px/1.65 var(--font-body);
  border-radius: 4px;
  box-sizing: border-box;
}

#scaler-viewport .invoice-paper {
  pointer-events: none;
}

#scaler-viewport .invoice-paper [data-edit] {
  outline: none !important;
  background: transparent !important;
}

/* Modal Edit Mode: Clear Interactive Dashed Indicators */
#invoice-modal-content [contenteditable="true"],
#invoice-modal-content [data-edit] {
  outline: 1.5px dashed rgba(40, 110, 150, 0.75) !important;
  outline-offset: 3px;
  border-radius: 2px;
  cursor: text;
  background: rgba(168, 195, 208, 0.18);
  padding: 2px 6px;
}

/* Invoice Structure */
.invoice-paper .invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-top: 6px solid var(--invoice-accent, #a8c3d0);
  border-bottom: 1.5px solid #1a1a1a;
  padding: 18px 0 14px;
  margin-bottom: 20px;
}

.invoice-paper .logo {
  max-height: 44px;
  margin-bottom: 8px;
  display: block;
}

.invoice-paper h1 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #000;
  margin: 0 0 4px;
}

.invoice-paper .inv-meta {
  text-align: right;
  font-size: 11px;
  color: #333;
}

.invoice-paper .inv-tag {
  background: var(--invoice-accent, #a8c3d0) !important;
  color: #11181c !important;
  font-weight: 800;
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.8px;
  display: inline-block;
  margin-bottom: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.invoice-paper .bill-to-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: #f8fafb;
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 22px;
  border: 1px solid #e2e7eb;
  border-left: 4px solid var(--invoice-accent, #a8c3d0);
}

.invoice-paper .bill-to-strip small {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #666;
  display: block;
  margin-bottom: 2px;
}

.invoice-paper .bill-to-strip strong {
  font-size: 13px;
  color: #000;
}

.invoice-paper .bill-to-strip p {
  font-size: 11px;
  color: #555;
  margin-top: 2px;
}

.invoice-paper h2 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 24px 0 10px;
  color: #111;
  display: flex;
  align-items: center;
  gap: 8px;
}

.invoice-paper h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 12px;
  background: var(--invoice-accent, #a8c3d0);
  border-radius: 2px;
}

.invoice-paper table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 6px;
}

.invoice-paper th {
  background: #f0f3f5;
  color: #111;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 800;
  padding: 8px 6px;
  border-bottom: 2px solid var(--invoice-accent, #a8c3d0) !important;
}

.invoice-paper td {
  padding: 10px 4px;
  border-bottom: 1px solid #eee;
  font-size: 11px;
}

.invoice-paper td:last-child,
.invoice-paper th:last-child {
  text-align: right;
}

.invoice-paper .invoice-totals {
  margin: 20px 0 22px auto;
  max-width: 290px;
  border-top: 1.5px solid #1a1a1a;
  padding-top: 6px;
}

.invoice-paper .invoice-totals div {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 11px;
}

.invoice-paper .amount-due {
  background: #f4f7f9 !important;
  border-top: 3px solid var(--invoice-accent, #a8c3d0) !important;
  margin-top: 8px;
  padding: 10px 8px !important;
  border-radius: 4px;
  font-size: 15px !important;
  font-weight: 800;
  color: #000;
}

.invoice-paper .payment-block,
.invoice-paper .notes-block {
  margin-top: 22px;
}

.invoice-paper .payment-block p,
.invoice-paper .notes-block p {
  font-size: 11px;
  line-height: 1.6;
  color: #444;
}

.invoice-paper .proof-section {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid #ddd;
}

.invoice-paper .proof-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.invoice-paper .proof-grid figure {
  border: 1px solid #e2e7eb;
  border-top: 3px solid var(--invoice-accent, #a8c3d0);
  padding: 8px;
  border-radius: 4px;
  background: #ffffff;
  break-inside: avoid;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.invoice-paper .proof-grid figure img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #fff;
  border-radius: 2px;
}

.invoice-paper .proof-grid figure figcaption {
  font-size: 9px;
  color: #555;
  margin-top: 6px;
  text-align: center;
}

.invoice-paper .invoice-footer {
  margin-top: 36px;
  padding-top: 14px;
  border-top: 1px solid #e5e5e5;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #777;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Natural 100% Zoom Edit Modal Container */
dialog#invoice-zoom-modal {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border: 0;
  border-radius: 0;
  background: #141618;
  padding: 0;
  margin: 0;
  overflow: hidden;
  display: none;
  flex-direction: column;
}

dialog#invoice-zoom-modal[open] {
  display: flex;
}

.zoom-modal-header {
  min-height: 56px;
  padding-top: env(safe-area-inset-top);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: 10px;
  background: #1e2225;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  flex-shrink: 0;
}

.zoom-modal-header span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.zoom-modal-header button {
  height: 38px;
  min-height: 38px;
  padding: 0 16px;
  font-size: 13px;
}

.zoom-modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 16px calc(60px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: rgba(13, 15, 16, 0.98);
  box-sizing: border-box;
}

/* Invoice in edit modal stays at full native readable resolution (no minified squishing) */
.zoom-modal-body>.invoice-paper {
  width: 680px;
  min-width: 680px;
  transform: none !important;
  margin: 0 auto;
}

dialog#receipt-inspect-modal {
  width: 92vw;
  max-width: 960px;
  height: 88dvh;
  max-height: 88dvh;
  background: #181b1d;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  margin: auto;
  overflow: hidden;
  display: none;
  flex-direction: column;
}

dialog#receipt-inspect-modal[open] {
  display: flex;
}

.inspect-header {
  min-height: 52px;
  padding: 0 18px;
  background: #1e2225;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.inspect-nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inspect-nav-btn {
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  border-radius: 6px;
}

#inspect-counter {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  min-width: 55px;
  text-align: center;
}

.inspect-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  background: #101214;
  touch-action: pan-y;
}

.inspect-img-pane {
  background: #090a0b;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.inspect-img-pane img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.inspect-form-pane {
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.exporting {
  width: 760px !important;
  min-width: 760px !important;
  transform: none !important;
}

.exporting tr,
.exporting figure,
.exporting .invoice-totals {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
  -webkit-column-break-inside: avoid !important;
}

/* ==========================================================================
   SECTION 5: MOBILE SPECIFIC OPTIMIZATIONS (≤ 760px)
   ========================================================================== */

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
  }
}

@media (max-width: 760px) {

  html,
  body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  body {
    user-select: none;
    -webkit-user-select: none;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  [contenteditable] {
    user-select: text;
    -webkit-user-select: text;
    font-size: 16px !important;
  }

  .topbar {
    min-height: calc(56px + env(safe-area-inset-top));
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: 12px;
  }

  .brand {
    font-size: 17px;
  }

  .brand-icon {
    width: 26px;
    height: 26px;
  }

  .beta {
    display: none;
  }

  main {
    display: flex;
    flex-direction: column;
    padding: 16px max(16px, env(safe-area-inset-right)) calc(95px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) !important;
  }

  .masthead {
    order: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 18px;
  }

  .masthead-copy h1 {
    font-size: 26px;
  }

  .project-deck {
    width: 100%;
    max-width: 100%;
    padding: 6px 10px;
  }

  .deck-current strong {
    max-width: 100%;
  }

  .switch-btn-wrap {
    width: 90px;
  }

  .steps {
    order: 2;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 18px;
    background: #181b1d;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--line);
  }

  .steps button {
    justify-content: center;
    padding: 9px 2px;
    font-size: 12px;
    border-radius: 8px;
    border: 0;
  }

  .steps button span {
    display: none;
  }

  .steps button.active {
    background: var(--accent);
    color: #12181b;
    font-weight: 700;
  }

  .workspace {
    order: 3;
    display: block;
    width: 100%;
    margin-bottom: calc(90px + env(safe-area-inset-bottom));
  }

  #view {
    width: 100%;
    min-width: 0;
  }

  .panel {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .inline-action-row {
    grid-template-columns: 1fr 110px;
    gap: 8px;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .terms-split-row {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
  }

  /* Compact Clean Bottom Summary Dock */
  .summary {
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: calc(64px + env(safe-area-inset-bottom)) !important;
    max-height: calc(85px + env(safe-area-inset-bottom)) !important;
    z-index: 999 !important;
    background: rgba(20, 23, 25, 0.98) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 0 !important;
    border-top: 1px solid #363e44 !important;
    border-radius: 14px 14px 0 0 !important;
    padding: 10px 16px max(14px, env(safe-area-inset-bottom)) !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 8px !important;
    box-sizing: border-box !important;
  }

  .summary .eyebrow,
  .summary h2,
  .summary .rule,
  .summary .sum-row,
  .summary>p,
  .summary .local-note {
    display: none !important;
  }

  .summary .total {
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0;
  }

  .summary .total span {
    font-size: 8px;
    letter-spacing: 1px;
    color: #8fa0aa;
  }

  .summary .total strong {
    font-size: 17px;
    color: var(--accent);
    line-height: 1.1;
    margin: 2px 0 0;
  }

  /* Mobile dock review pill: single-line compact tag */
  .summary .status-indicator-pill {
    width: auto !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 12px !important;
    border-radius: 20px !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    font-size: 11px !important;
  }

  .summary .status-indicator-pill span {
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  .summary button.primary {
    min-height: 38px !important;
    height: 38px !important;
    font-size: 12px;
    padding: 0 14px;
    border-radius: 8px;
    margin: 0;
    width: auto !important;
    flex-shrink: 0;
  }

  .zoom-modal-body {
    padding: 12px 10px calc(60px + env(safe-area-inset-bottom));
    display: block;
    overflow-x: auto;
  }

  footer {
    display: none;
  }
}
/* Personal PDF templates and the pointer-following invoice hint. */
.invoice-pointer-hint {position:fixed;z-index:1200;pointer-events:none;display:flex;gap:16px;align-items:center;padding:12px 16px;border:1px solid #a8c3d055;border-radius:14px;background:#1e2225f5;color:#fff;box-shadow:0 10px 32px #0005;backdrop-filter:blur(12px);font-size:13px;}
.invoice-pointer-hint[hidden]{display:none}
.invoice-pointer-hint small,.invoice-pointer-hint span{display:block}
.invoice-pointer-hint small{font-size:9px;letter-spacing:.15em;color:#a8c3d0;margin-bottom:4px}
.personal-template-card{margin:18px 0;padding:18px;border:1px solid #a8c3d044;border-radius:14px;background:#a8c3d008}
.personal-template-card p{margin:10px 0}
.pdf-template-page{position:relative;overflow:hidden;background:#fff;color:#111;flex-shrink:0;font-family:WrapKorean,sans-serif}
.pdf-template-background{position:absolute;inset:0;width:100%;height:100%;max-width:none!important;border-radius:0!important}
.pdf-filled-field{position:absolute;white-space:pre-wrap;overflow:hidden;overflow-wrap:anywhere;line-height:1.35;color:#111;padding:2px;font-family:WrapKorean,sans-serif;font-weight:400;text-align:left;letter-spacing:normal}
.invoice-paper.has-pdf-template{padding:0!important;width:680px!important;min-width:680px!important;background:white}
.pdf-export-root{position:absolute;left:0;top:0;width:680px;z-index:-1;background:white;color:#111}
.pdf-proof-page{width:680px;height:961.7px;padding:40px;background:#fff;color:#111;font:14px WrapKorean,sans-serif}
.pdf-proof-page img{display:block;width:600px;height:800px;object-fit:contain;margin-top:20px}
.pdf-map-dialog{width:min(1200px,96vw);max-width:96vw;max-height:94dvh;margin:auto;padding:24px;background:#1e2225;color:white;border:1px solid #a8c3d055;border-radius:20px;overflow:auto}
.pdf-map-dialog::backdrop{background:#000b;backdrop-filter:blur(8px)}
.pdf-map-header{position:static;display:flex;align-items:center;justify-content:space-between;padding:0;background:none}
.pdf-map-toolbar{display:flex;align-items:end;gap:12px;flex-wrap:wrap;margin:18px 0}
.pdf-map-toolbar label{flex:1;min-width:130px}
.pdf-map-dialog label{display:block;font-size:12px;color:#a8c3d0}
.pdf-map-dialog input,.pdf-map-dialog select{width:100%;font-size:16px;min-height:44px;margin-top:6px}
.pdf-map-layout{display:grid;grid-template-columns:minmax(0,1fr) 230px;gap:20px;margin-top:16px}
.pdf-map-scroll{overflow:auto;max-height:65vh;background:#111;padding:20px 10px;-webkit-overflow-scrolling:touch}
#pdf-map-canvas{position:relative;width:680px;background:white}
#pdf-map-canvas>img{position:absolute;width:100%;height:100%;pointer-events:none}
.pdf-map-field{position:absolute!important;min-height:0!important;min-width:0!important;padding:2px!important;border:1px dashed #247baf!important;border-radius:2px!important;background:#a8c3d033;color:#111;touch-action:none;cursor:move;text-align:left;overflow:visible;display:block!important;line-height:1.35;font-family:WrapKorean,sans-serif}
.pdf-map-field.selected{outline:2px solid #247baf;z-index:2}
.pdf-map-field.reviewed{border-color:#258b65!important}
.pdf-map-label{position:absolute;bottom:100%;left:0;background:#174461;color:white;font:10px sans-serif;padding:3px;white-space:nowrap}
.pdf-map-value{display:block;overflow:hidden;width:100%;height:100%;white-space:pre-wrap;overflow-wrap:anywhere}
.pdf-coordinate-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.pdf-map-dialog .check-pill input{width:20px;min-height:20px}
.pdf-map-actions{display:flex!important;position:sticky;bottom:-24px;background:#1e2225;padding:16px 0;justify-content:flex-end;gap:12px;margin-top:20px}
#pdf-map-status{min-height:24px;color:#a8c3d0;margin-top:12px}
@media(max-width:700px){.pdf-map-dialog{padding:16px}.pdf-map-layout{grid-template-columns:minmax(0,1fr)}.pdf-map-scroll{max-height:45vh}.pdf-map-actions{bottom:-16px}.pdf-map-dialog button{min-height:48px}.pdf-map-header h2{font-size:20px}}
