:root {
  --bg: #ffffff;
  --text: #1a2230;
  --text-muted: #6b7584;
  --border: #d9dee5;
  --primary: #2f6fde;
  --primary-hover: #2459b8;
  --error: #c8392f;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --header-height: 3.5rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding-top: var(--header-height);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.public-login {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.public-brand {
  display: flex;
  align-items: center;
  flex: none;
  max-width: 40%;
  height: 100%;
  padding: 0.5rem 0;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
}

.public-brand .sidebar-logo {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.public-login form {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.public-login input {
  width: 11rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

.public-login input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.public-login button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  background: var(--primary);
  color: #fff;
}

.public-login button:hover {
  background: var(--primary-hover);
}

#result {
  position: absolute;
  top: 100%;
  right: 1.5rem;
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

#result.error {
  color: var(--error);
}

.public-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.public-soon {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.public-login-toggle {
  display: none;
}

@media (max-width: 560px) {
  .public-login {
    height: auto;
    min-height: var(--header-height);
    padding: 0.6rem 1rem;
    flex-wrap: wrap;
    align-content: center;
    gap: 0.6rem;
  }

  .public-brand {
    height: 2.25rem;
    max-width: 60%;
    padding: 0;
  }

  .public-login .public-login-toggle {
    display: inline-block;
    width: auto;
  }

  .public-login form {
    display: none;
    width: 100%;
  }

  .public-login.is-open form {
    display: flex;
  }

  .public-login input,
  .public-login form button {
    width: 100%;
  }

  #result {
    right: 1rem;
  }
}

body.has-apply .public-main {
  flex: none;
  min-height: 40vh;
}

.public-apply {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.public-apply h2 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

.public-apply-intro {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.apply-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.apply-wide {
  grid-column: 1 / -1;
}

.apply-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.apply-optional {
  color: var(--text-muted);
  font-weight: 400;
}

.apply-field input,
.apply-field textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  resize: vertical;
}

.apply-field input:focus,
.apply-field textarea:focus,
.apply-consent input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.apply-trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.apply-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.apply-consent input {
  margin-top: 0.2rem;
}

#apply-send {
  margin-top: 1.25rem;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.3rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  background: var(--primary);
  color: #fff;
}

#apply-send:hover {
  background: var(--primary-hover);
}

#apply-send:disabled {
  opacity: 0.6;
  cursor: default;
}

.apply-message {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 6px;
  font-size: 0.92rem;
  line-height: 1.4;
}

.apply-message.success {
  background: #e7f6ee;
  color: #1e7a4a;
}

.apply-message.error {
  background: #fdecea;
  color: var(--error);
}

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

.mdl .mdl-apply {
  max-width: none;
  margin: 0;
  padding: 92px 24px;
  background: var(--mdl-bg);
  border-top: 1px solid var(--mdl-line);
  color: var(--mdl-text);
}

.mdl .mdl-apply > * {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.mdl .mdl-apply h2 {
  color: var(--mdl-text);
  line-height: 1.15;
  font-size: clamp(28px, 3.4vw, 38px);
  letter-spacing: -1px;
  font-weight: 700;
  margin-bottom: 14px;
}

.mdl .mdl-apply .public-apply-intro {
  color: var(--mdl-muted);
  font-size: 17px;
  margin-bottom: 34px;
}

.mdl .mdl-apply .apply-grid {
  gap: 18px;
}

.mdl .mdl-apply .apply-field label {
  color: var(--mdl-muted);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.mdl .mdl-apply .apply-optional {
  color: var(--mdl-muted);
  opacity: 0.75;
}

.mdl .mdl-apply .apply-field input,
.mdl .mdl-apply .apply-field textarea {
  padding: 12px 14px;
  border: 1px solid var(--mdl-line);
  border-radius: 10px;
  background: var(--mdl-bg);
  color: var(--mdl-text);
  font-family: inherit;
  font-size: 16px;
  color-scheme: dark;
}

.mdl .mdl-apply .apply-field input::placeholder,
.mdl .mdl-apply .apply-field textarea::placeholder {
  color: var(--mdl-muted);
  opacity: 0.6;
}

.mdl .mdl-apply .apply-field input:focus,
.mdl .mdl-apply .apply-field textarea:focus {
  outline: 2px solid var(--mdl-accent-soft);
  outline-offset: 0;
  border-color: var(--mdl-accent);
}

.mdl .mdl-apply .apply-consent {
  color: var(--mdl-muted);
  font-size: 15px;
}

.mdl .mdl-apply .apply-consent input {
  accent-color: var(--mdl-accent);
}

.mdl .mdl-apply .apply-consent input:focus {
  outline: 2px solid var(--mdl-accent-soft);
}

.mdl .mdl-apply #apply-send {
  display: inline-block;
  margin-top: 28px;
  padding: 15px 32px;
  border: none;
  border-radius: 999px;
  background: var(--mdl-accent);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.mdl .mdl-apply #apply-send:hover {
  background: var(--mdl-accent);
  filter: brightness(1.18);
  transform: translateY(-1px);
}

.mdl .mdl-apply #apply-send:disabled {
  filter: none;
  transform: none;
}

.mdl .mdl-apply .apply-message {
  border-radius: 10px;
}

.mdl .mdl-apply .apply-message.success {
  background: var(--mdl-accent-soft);
  color: var(--mdl-accent-light);
}

.mdl .mdl-apply .apply-message.error {
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
}

@media (max-width: 900px) {
  .mdl .mdl-apply {
    padding: 64px 24px;
  }
}

body.public-plain {
  padding-top: 0;
}

.public-sign {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.sign-html {
  line-height: 1.5;
}

.sign-html:empty {
  display: none;
}

.sign-pdf {
  display: block;
  width: 100%;
  height: 70vh;
  margin: 1.25rem 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.public-sign textarea {
  resize: vertical;
}

.sign-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}

.sign-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.sign-item.reading .sign-item-name {
  font-weight: 600;
}

.sign-item-num {
  color: var(--text-muted);
  margin-right: 0.4rem;
}

.sign-item-actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.sign-signed {
  color: #1e7a4a;
  font-weight: 600;
  font-size: 0.9rem;
}

.sign-primary,
.sign-secondary {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.4rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font);
}

.sign-primary {
  border: none;
  background: var(--primary);
  color: #fff;
}

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

.sign-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.sign-secondary {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.sign-secondary:hover {
  border-color: var(--text-muted);
}

.sign-id {
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sign-id-status {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.9rem;
}

.sign-id-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.sign-id-upload input[type="file"] {
  flex: 1;
  min-width: 0;
}

.public-sign [hidden] {
  display: none !important;
}

.public-thanks {
  width: 100%;
  max-width: 640px;
  margin: 1.5rem auto 0;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  background: #e7f6ee;
  color: #1e7a4a;
  line-height: 1.5;
}

.public-thanks[hidden] {
  display: none;
}
