:root {
  --red: #b50018;
  --red-dark: #69000e;
  --red-deep: #360008;
  --red-soft: #f9e9ec;
  --gold: #e8b54c;
  --ink: #2a2022;
  --muted: #715e62;
  --line: #ead4d8;
  --panel: #fff;
  --shadow: 0 16px 42px rgba(63, 0, 10, .17);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f7f1f2; }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: Inter, "Segoe UI", Arial, sans-serif; background: radial-gradient(circle at top, #fff 0, #f8eef0 50%, #f2e5e8 100%); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--red); }

#app-shell { width: 390px; max-width: calc(100vw - 20px); min-height: calc(100vh - 20px); min-height: calc(100dvh - 20px); margin: 10px auto; overflow: hidden; border: 1px solid rgba(105,0,14,.16); border-radius: 28px; background: rgba(255,255,255,.48); box-shadow: 0 18px 70px rgba(79,0,12,.16); }
.screen { display: none; min-height: calc(100vh - 20px); min-height: calc(100dvh - 20px); padding: max(22px, env(safe-area-inset-top)) 14px calc(100px + env(safe-area-inset-bottom)); }
.screen.active { display: block; animation: enter .24s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.splash-screen { position: relative; overflow: hidden; text-align: center; color: #fff; background: linear-gradient(155deg, #420007, #8f0013 48%, #c40621); display: none; flex-direction: column; align-items: center; justify-content: center; padding-bottom: 48px; }
.splash-screen.active { display: flex; }
.splash-glow { position: absolute; width: 480px; height: 480px; border-radius: 50%; background: rgba(255,205,104,.2); filter: blur(60px); top: -180px; right: -180px; }
.splash-logo { position: relative; width: min(78vw, 390px); max-height: 48vh; object-fit: contain; filter: drop-shadow(0 18px 32px rgba(0,0,0,.35)); }
.splash-screen h1 { margin: 20px 0 8px; font-size: clamp(30px, 8vw, 48px); letter-spacing: .06em; }
.splash-screen p { max-width: 520px; margin: 0 0 28px; font-size: 17px; line-height: 1.5; color: rgba(255,255,255,.88); }

.auth-screen { background: linear-gradient(160deg, #4b0009, #9b0015 58%, #c50722); color: #fff; }
.auth-screen .back-button { color: #fff; }
.login-logo { display: block; width: min(56vw, 265px); margin: 8px auto 18px; filter: drop-shadow(0 12px 24px rgba(0,0,0,.28)); }
.panel { background: var(--panel); border: 1px solid rgba(181,0,24,.12); border-radius: 24px; box-shadow: var(--shadow); }
.login-panel { max-width: 520px; margin: 0 auto; padding: 28px; color: var(--ink); }
.login-panel h2 { margin: 0 0 8px; text-align: center; color: var(--red); }
.login-panel > p { text-align: center; line-height: 1.5; }

label { display: block; margin: 15px 0 0; font-weight: 700; }
label small { display: block; margin-top: 3px; font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; margin-top: 7px; padding: 13px 14px; border: 1px solid #d9c4c8; border-radius: 12px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(181,0,24,.12); }
input[readonly] { background: #f4edef; color: #6d5b5f; }
textarea { min-height: 125px; resize: vertical; }
.password-row { display: grid; grid-template-columns: 1fr auto; align-items: stretch; margin-top: 7px; }
.password-row input { margin: 0; border-radius: 12px 0 0 12px; }
.password-row button { border: 0; padding: 0 14px; border-radius: 0 12px 12px 0; background: var(--red-soft); color: var(--red-dark); font-weight: 800; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; padding: 12px 22px; border: 0; border-radius: 13px; cursor: pointer; font-weight: 800; letter-spacing: .03em; text-decoration: none; transition: transform .15s ease, opacity .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.primary-button { width: 100%; margin-top: 20px; color: #fff; background: linear-gradient(135deg, var(--red-dark), var(--red)); box-shadow: 0 8px 20px rgba(181,0,24,.22); }
.gold-button { min-width: 230px; color: #401d00; background: linear-gradient(135deg, #fff0a8, var(--gold)); box-shadow: 0 12px 26px rgba(42,17,0,.25); }
.status { min-height: 1.4em; margin: 14px 0 0; text-align: center; color: var(--red-dark); font-weight: 700; line-height: 1.4; }
.status.success { color: #136829; }
.help-line { font-size: 14px; }

.app-header { display: grid; grid-template-columns: 64px 1fr 44px; gap: 12px; align-items: center; margin: -22px -14px 22px; padding: max(14px, env(safe-area-inset-top)) 14px 14px; color: #fff; background: linear-gradient(120deg, var(--red-dark), var(--red)); box-shadow: 0 7px 24px rgba(84,0,13,.25); }
.app-header img { width: 64px; height: 64px; object-fit: contain; }
.app-header div { display: flex; flex-direction: column; gap: 3px; }
.app-header span { font-size: 12px; letter-spacing: .11em; color: rgba(255,255,255,.78); }
.app-header strong { font-size: 18px; }
.icon-button { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; background: rgba(255,255,255,.13); color: #fff; font-size: 22px; cursor: pointer; }
.welcome-card { padding: 22px; border-radius: 22px; color: #fff; background: linear-gradient(140deg, #6b0010, #bd001b); box-shadow: var(--shadow); }
.welcome-card h2 { margin: 0 0 8px; font-size: 23px; }
.welcome-card p { margin: 7px 0 0; color: rgba(255,255,255,.88); line-height: 1.45; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 18px; }
.menu-card { min-height: 145px; padding: 11px 8px; border: 1px solid var(--line); border-radius: 21px; background: #fff; color: var(--ink); box-shadow: 0 8px 22px rgba(70,0,11,.08); cursor: pointer; font-size: 13px; font-weight: 800; line-height: 1.25; }
.menu-card img { display: block; width: 78px; height: 76px; object-fit: contain; margin: 0 auto 8px; }
.menu-card:hover { border-color: rgba(181,0,24,.45); transform: translateY(-2px); }

.screen-header { display: grid; grid-template-columns: 45px 1fr 45px; align-items: center; margin-bottom: 20px; }
.screen-header h2 { margin: 0; text-align: center; color: var(--red-dark); font-size: clamp(21px, 5vw, 30px); }
.back-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(181,0,24,.1); color: var(--red-dark); font-size: 28px; cursor: pointer; }
.screen-intro { max-width: 610px; margin: 0 auto 18px; text-align: center; color: var(--muted); line-height: 1.55; }
.document-list { display: grid; gap: 13px; }
.document-card { display: grid; grid-template-columns: 76px 1fr 24px; gap: 12px; align-items: center; width: 100%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 18px; background: #fff; color: var(--ink); text-align: left; font-weight: 800; box-shadow: 0 8px 22px rgba(70,0,11,.07); cursor: pointer; }
.document-card img { width: 72px; height: 72px; object-fit: contain; }
.document-card b { color: var(--red); font-size: 31px; }

.form-panel, .content-panel { padding: 17px; border-radius: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.member-strip { padding: 16px; border-radius: 14px; background: var(--red-soft); color: var(--red-dark); line-height: 1.55; }
fieldset { min-width: 0; }
.choice-group { margin: 22px 0 0; padding: 0; border: 0; }
.choice-group legend { margin-bottom: 10px; font-size: 19px; font-weight: 900; color: var(--red-dark); }
.package-card, .check-card, .confirm-card { display: flex; gap: 13px; align-items: flex-start; margin: 10px 0 0; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #fff; cursor: pointer; font-weight: 600; }
.package-card:has(input:checked), .check-card:has(input:checked), .confirm-card:has(input:checked) { border-color: var(--red); background: var(--red-soft); box-shadow: 0 0 0 2px rgba(181,0,24,.08); }
.package-card input, .check-card input, .confirm-card input { flex: 0 0 20px; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--red); }
.package-card span, .check-card span, .confirm-card span { flex: 1; }
.package-card strong { display: block; color: var(--red-dark); }
.package-card small { display: block; margin-top: 5px; color: var(--muted); font-weight: 400; line-height: 1.45; }
.check-card b { white-space: nowrap; color: var(--red-dark); }
.check-card.disabled { opacity: .48; cursor: not-allowed; }
.order-total { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; padding: 18px; border-radius: 16px; color: #fff; background: var(--red-dark); font-size: 21px; }
.order-total strong { color: #ffe096; font-size: 26px; }
.payment-note { text-align: center; color: var(--muted); }
.paypal-container { min-height: 48px; margin-top: 14px; }
.character-count { margin-top: 5px; text-align: right; color: var(--muted); font-size: 13px; }
.support-logo { display: block; width: min(62vw, 260px); margin: 0 auto 18px; }
.content-panel { text-align: center; line-height: 1.6; }
.content-panel h3 { color: var(--red-dark); }
.support-email { overflow-wrap: anywhere; font-size: 18px; font-weight: 800; }

#bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 0; display: none; width: 390px; max-width: calc(100vw - 20px); transform: translateX(-50%); padding: 7px 6px calc(7px + env(safe-area-inset-bottom)); border: 1px solid #e4cdd1; border-bottom: 0; border-radius: 18px 18px 0 0; background: rgba(255,255,255,.96); backdrop-filter: blur(16px); box-shadow: 0 -8px 25px rgba(76,0,12,.1); }
#bottom-nav.visible { display: grid; grid-template-columns: repeat(5, 1fr); }
#bottom-nav button { padding: 5px 2px; border: 0; background: transparent; color: #674f54; font-size: 10px; font-weight: 800; cursor: pointer; }
#bottom-nav button span { display: block; margin-bottom: 2px; color: var(--red); font-size: 22px; }

#document-dialog { width: min(calc(100vw - 20px), 390px); max-width: 390px; height: min(92vh, 840px); padding: 0; border: 0; border-radius: 22px; overflow: hidden; background: #fff; box-shadow: 0 28px 90px rgba(25,0,4,.5); }
#document-dialog::backdrop { background: rgba(25,0,4,.76); backdrop-filter: blur(5px); }
#document-dialog header { display: grid; grid-template-columns: 54px 1fr 42px; gap: 10px; align-items: center; padding: 12px 15px; color: #fff; background: var(--red-dark); }
#document-dialog header img { width: 52px; height: 52px; object-fit: contain; }
#document-dialog h2 { margin: 0; font-size: 18px; }
#document-close { width: 40px; height: 40px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.16); font-size: 27px; cursor: pointer; }
#document-stage { display: flex; align-items: center; justify-content: center; height: calc(100% - 132px); padding: 12px; overflow: auto; background: #e9e4e5; }
#document-image, #document-canvas { display: none; max-width: 100%; max-height: 100%; object-fit: contain; }
#document-image.visible, #document-canvas.visible { display: block; }
#document-download { width: calc(100% - 24px); margin: 10px 12px; }
#document-download.hidden { display: none; }
#document-error { color: var(--red-dark); font-weight: 800; text-align: center; }

#app-message { position: fixed; z-index: 50; left: 50%; bottom: 100px; display: none; width: min(calc(100% - 30px), 600px); transform: translateX(-50%); padding: 15px 18px; border-radius: 14px; color: #fff; background: #321016; box-shadow: 0 16px 45px rgba(0,0,0,.3); text-align: center; font-weight: 700; }
#app-message.visible { display: block; }
#app-message.success { background: #145f2c; }

@media (max-width: 410px) {
  #app-shell { width: 100vw; max-width: 100vw; min-height: 100vh; min-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .screen { min-height: 100vh; min-height: 100dvh; }
  #bottom-nav { width: 100vw; max-width: 100vw; border-right: 0; border-left: 0; border-radius: 0; }
  .document-card { grid-template-columns: 65px 1fr 20px; padding: 10px; font-size: 14px; }
  .document-card img { width: 62px; height: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
