html,
body {
  height: 100%;
}

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-secondary: #ffffff;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --text: #182533;
  --muted: #6b7c93;
  --accent: #3390ec;
  --accent-strong: #2481df;
  --accent-soft: rgba(51, 144, 236, 0.14);
  --border: rgba(53, 84, 114, 0.12);
  --danger: #da5252;
  --success: #2ea772;
  --shadow: 0 10px 30px rgba(15, 32, 56, 0.08);
  --field-bg: #ffffff;
  --surface-tint: rgba(255, 255, 255, 0.92);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17212b;
  --bg-secondary: #232e3c;
  --panel: #1f2a38;
  --panel-strong: #253242;
  --text: #f5f7fb;
  --muted: #9aa8b8;
  --accent: #5ba8f6;
  --accent-strong: #7ab8fb;
  --accent-soft: rgba(91, 168, 246, 0.18);
  --border: rgba(136, 170, 204, 0.16);
  --danger: #ff8f8f;
  --success: #7edbb1;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  --field-bg: #253242;
  --surface-tint: rgba(31, 42, 56, 0.94);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.mobile-preview {
  --device-screen-width: 375px;
  --device-screen-height: 812px;
  --device-frame-padding: 7px;
  --device-safe-top: 34px;
  --device-shell-padding: 0;
  --device-panel-radius: 18px;
  --device-panel-padding: 0;
  --device-control-height: 40px;
  --device-control-font: 0.9rem;
  --device-field-font: 0.92rem;
  --device-notch-width: 124px;
  --device-notch-height: 24px;
  --device-frame-radius: 34px;
  --device-screen-radius: 26px;
  --device-preview-scale: 0.88;
  background: var(--bg);
}

body.mobile-preview[data-device="android-tall"] {
  --device-screen-width: 360px;
  --device-screen-height: 800px;
  --device-frame-padding: 6px;
  --device-safe-top: 24px;
  --device-control-height: 38px;
  --device-control-font: 0.88rem;
  --device-field-font: 0.9rem;
  --device-notch-width: 92px;
  --device-notch-height: 16px;
  --device-frame-radius: 30px;
  --device-screen-radius: 24px;
  --device-preview-scale: 0.9;
}

body.mobile-preview[data-device="android-compact"] {
  --device-screen-width: 360px;
  --device-screen-height: 640px;
  --device-frame-padding: 6px;
  --device-safe-top: 20px;
  --device-control-height: 36px;
  --device-control-font: 0.84rem;
  --device-field-font: 0.86rem;
  --device-notch-width: 82px;
  --device-notch-height: 14px;
  --device-frame-radius: 28px;
  --device-screen-radius: 22px;
  --device-preview-scale: 0.96;
}

button,
input,
textarea,
select {
  font: inherit;
}

textarea {
  resize: none;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

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

.hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.6vw, 1.8rem);
  line-height: 1.1;
  font-weight: 700;
}

.hero-copy {
  max-width: 560px;
  color: var(--muted);
  margin: 10px 0 0;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.92rem;
  border: 1px solid transparent;
}

.theme-toggle,
.menu-button,
.subtype-button,
.submit-button {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 32, 56, 0.04);
}

.theme-toggle:hover,
.menu-button:hover,
.subtype-button:hover,
.submit-button:hover {
  border-color: rgba(51, 144, 236, 0.32);
  box-shadow: 0 6px 18px rgba(51, 144, 236, 0.14);
}

.theme-toggle {
  padding: 10px 14px;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border-radius: 999px;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
}

.sidebar,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.menu-grid,
.subtype-list,
.request-form {
  display: grid;
  gap: 12px;
}

.menu-button,
.subtype-button {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
}

.menu-button.active,
.subtype-button.active {
  background: var(--accent-soft);
  border-color: rgba(51, 144, 236, 0.28);
}

.submit-button {
  background: var(--accent);
  border-color: transparent;
  color: #ffffff;
}

.submit-button:hover {
  background: var(--accent-strong);
  border-color: transparent;
}

.subtype-button span,
.panel-header p {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

.content {
  display: grid;
  gap: 20px;
}

.panel-header h2,
.sidebar h2 {
  margin: 0 0 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-weight: 600;
}

.date-stack {
  display: grid;
  gap: 8px;
}

.date-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--field-bg);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: rgba(51, 144, 236, 0.52);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent-strong) 50%),
    linear-gradient(135deg, var(--accent-strong) 50%, transparent 50%);
  background-position:
    calc(100% - 21px) calc(50% - 2px),
    calc(100% - 15px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.submit-button {
  padding: 14px 18px;
  font-weight: 700;
}

.feedback,
.alert,
.instruction-box {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.feedback.success {
  background: rgba(46, 167, 114, 0.12);
  color: var(--success);
}

.feedback.error,
.alert {
  background: rgba(218, 82, 82, 0.12);
  color: var(--danger);
}

.instruction-box {
  background: var(--accent-soft);
  color: var(--text);
}

.hidden {
  display: none;
}

.mobile-stepbar {
  display: none;
}

body.mobile-preview .page-shell {
  max-width: none;
  min-height: 100%;
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

body.mobile-preview .layout {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 8px;
  position: relative;
}

body.mobile-preview .hero {
  position: relative;
  flex-direction: column;
  margin-bottom: 0;
  padding: calc(var(--device-safe-top) + 4px) 12px 8px;
  gap: 8px;
  background: var(--bg);
  z-index: 2;
}

body.mobile-preview .hero h1 {
  font-size: 1.05rem;
  line-height: 1.2;
  max-width: calc(100% - 52px);
  color: var(--text);
}

body.mobile-preview .hero-copy {
  font-size: 0.82rem;
  margin: 0;
  color: var(--muted);
}

body.mobile-preview .hero-actions {
  position: absolute;
  top: calc(var(--device-safe-top) + 2px);
  right: 12px;
  width: auto;
  gap: 8px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
}

body.mobile-preview .hero-actions #adminLink {
  flex: 0 0 auto;
  width: 34px;
  max-width: 34px;
  min-width: 34px;
  min-height: 34px;
  height: 34px;
  padding: 0;
  font-size: 0.98rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-preview .hero-actions .icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 999px;
}

body.mobile-preview .mobile-stepbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  padding: 0 12px 8px;
  position: relative;
  z-index: 2;
  background: var(--bg);
}

body.mobile-preview .mobile-step-title {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

body.mobile-preview .theme-toggle,
body.mobile-preview .menu-button,
body.mobile-preview .subtype-button,
body.mobile-preview .submit-button {
  min-height: var(--device-control-height);
  font-size: var(--device-control-font);
}

body.mobile-preview .theme-toggle,
body.mobile-preview .menu-button,
body.mobile-preview .subtype-button {
  background: var(--surface-tint);
  color: var(--text);
  border-color: var(--border);
}

body.mobile-preview .sidebar,
body.mobile-preview .panel {
  padding: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.mobile-preview .sidebar {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  padding: 0 12px 12px;
}

body.mobile-preview .sidebar h2 {
  display: none;
}

body.mobile-preview .content {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: 0 12px 12px;
}

body.mobile-preview .content > .panel {
  flex: 1 1 auto;
}

body.mobile-preview .menu-grid,
body.mobile-preview .subtype-list {
  gap: 8px;
  width: 100%;
}

body.mobile-preview .menu-grid {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

body.mobile-preview .menu-button,
body.mobile-preview .subtype-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  text-align: center;
  color: var(--text);
}

body.mobile-preview .menu-button {
  flex: 1 1 0;
}

body.mobile-preview .subtype-button {
  justify-content: flex-start;
  text-align: left;
}

body.mobile-preview .menu-button.active,
body.mobile-preview .subtype-button.active {
  background: rgba(51, 144, 236, 0.16);
  border-color: rgba(51, 144, 236, 0.2);
  color: var(--text);
}

body.mobile-preview .field input,
body.mobile-preview .field textarea,
body.mobile-preview .field select {
  padding: 11px 12px;
  border-radius: 12px;
  font-size: var(--device-field-font);
  background: var(--field-bg);
}

body.mobile-preview .field span,
body.mobile-preview .field-hint,
body.mobile-preview .panel-header p,
body.mobile-preview .subtype-button span {
  color: var(--muted);
  font-size: 0.8rem;
}

body.mobile-preview #menuPanel:not(.hidden) {
  flex: 1 1 auto;
  min-height: 100%;
}

body.mobile-preview #menuPanel:not(.hidden) .menu-grid {
  height: 100%;
}

body.mobile-preview .content.hidden,
body.mobile-preview #menuPanel.hidden + .content.hidden {
  display: none;
}

body.mobile-preview .layout.show-menu-step {
  gap: 0;
}

body.mobile-preview .layout.show-menu-step > #menuPanel {
  flex: 1 1 auto;
}

body.mobile-preview .layout.show-menu-step > .content,
body.mobile-preview .layout.show-type-step > #menuPanel,
body.mobile-preview .layout.show-form-step > #menuPanel {
  display: none;
}

body.mobile-preview .layout.show-type-step > .content,
body.mobile-preview .layout.show-form-step > .content {
  flex: 1 1 auto;
  display: flex;
}

body.mobile-preview.mobile-menu-step .layout {
  flex: 1 1 auto;
  gap: 0;
  overflow: hidden;
}

body.mobile-preview.mobile-menu-step #menuPanel {
  padding: 0 12px 12px;
}

.iphone-frame {
  width: min(100%, 390px);
  margin: 12px auto;
  padding: 10px;
  border-radius: 34px;
  background: #0f131b;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
  position: relative;
}

.iphone-notch {
  width: 124px;
  height: 24px;
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  border-radius: 0 0 16px 16px;
  background: #070a10;
  z-index: 3;
}

.iphone-screen {
  min-height: 760px;
  border-radius: 26px;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

body.mobile-preview .iphone-screen {
  width: var(--device-screen-width);
  height: var(--device-screen-height);
  min-height: 0;
  border-radius: var(--device-screen-radius);
  background: var(--bg);
}

body.mobile-preview .iphone-frame {
  width: calc(var(--device-screen-width) + (var(--device-frame-padding) * 2));
  max-width: 100%;
  margin: 12px auto;
  padding: var(--device-frame-padding);
  border-radius: var(--device-frame-radius);
}

body.mobile-preview:not(.embedded-preview) .iphone-frame {
  transform: scale(var(--device-preview-scale));
  transform-origin: top center;
}

body.mobile-preview .iphone-notch {
  width: var(--device-notch-width);
  height: var(--device-notch-height);
}

body.mobile-preview[data-device="android-tall"] .iphone-notch,
body.mobile-preview[data-device="android-compact"] .iphone-notch {
  border-radius: 0 0 12px 12px;
  background: #111823;
}

body.mobile-preview.embedded-preview .iphone-frame {
  width: 100%;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.mobile-preview.embedded-preview .iphone-notch {
  display: none;
}

body.mobile-preview.embedded-preview .iphone-screen {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
  }

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