:root {
  --md-primary: #757575;
  --md-primary-dark: #616161;
  --md-success: #5c8363;
  --md-success-dark: #476b4d;
  --md-warning: #ed6c02;
  --md-warning-dark: #e65100;
  --md-surface: #ffffff;
  --md-background: #f5f6fa;
  --md-text-primary: #212121;
  --md-text-secondary: #757575;
  --md-divider: #e0e0e0;
  --md-error: #c25e5e;
  --md-error-dark: #a64d4d;
  --border-radius: 6px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--md-background);
  color: var(--md-text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------
   1. Header & Avatar
--------------------------------------------------- */
.app-header {
  background: var(--md-surface);
  color: var(--md-text-primary);
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  position: relative;
  z-index: 10;
}

.header-title {
  display: flex;
  align-items: center;
  height: 100%;
}

.header-title img {
  height: 100%;
  max-height: 40px;
  width: auto;
  object-fit: contain;
  cursor: pointer;
}

.avatar-container {
  cursor: pointer;
  font-size: 40px;
  color: var(--md-primary);
  line-height: 1;
}

.user-menu {
  display: none;
  position: absolute;
  top: 70px;
  right: 16px;
  background: var(--md-surface);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  border-radius: var(--border-radius);
  border: 1px solid var(--md-divider);
  padding: 16px;
  width: max-content;
  max-width: calc(100vw - 32px);
  z-index: 100;
}

.user-menu.active {
  display: block;
}

.user-email-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: transparent;
  border: none;
  padding: 4px 8px;
  margin-bottom: 12px;
}

.user-email-wrapper .mdi {
  font-size: 20px;
  color: var(--md-primary);
}

.user-email-wrapper span {
  font-size: 15px;
  font-weight: 600;
  color: var(--md-text-primary);
  word-break: break-all;
}

.user-menu .md-button {
  padding: 14px 16px;
  gap: 4px;
}
.user-menu .md-button .mdi {
  margin-right: 0;
}

/* ---------------------------------------------------
   2. Layout & Cards
--------------------------------------------------- */
.app-container {
  padding: 24px 16px;
  max-width: 600px;
  margin: 0 auto;
}

.md-card {
  background: var(--md-surface);
  border-radius: var(--border-radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  padding: 28px;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.page-title {
  font-size: 22px;
  margin: 0 0 8px 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--md-text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ---------------------------------------------------
   3. Buttons
--------------------------------------------------- */
.md-button {
  border: none;
  padding: 14px 16px;
  border-radius: var(--border-radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary { background: var(--md-primary); color: #fff; }
.btn-success { background: var(--md-success); color: #fff; }
.btn-warning { background: var(--md-warning); color: #fff; }
.btn-outline { background: transparent; color: var(--md-text-primary); border: 1px solid var(--md-divider); }
.btn-danger  { background: var(--md-error); color: #fff; }

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--md-primary-dark); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
  .btn-success:hover:not(:disabled) { background: var(--md-success-dark); box-shadow: 0 2px 6px rgba(92,131,99,0.3); }
  .btn-warning:hover:not(:disabled) { background: var(--md-warning-dark); box-shadow: 0 2px 6px rgba(237,108,2,0.3); }
  .btn-outline:hover:not(:disabled) { background: #f5f5f5; }
  .btn-danger:hover:not(:disabled)  { background: var(--md-error-dark); box-shadow: 0 2px 6px rgba(194,94,94,0.3); }
}

.btn-primary:active:not(:disabled) { background: var(--md-primary-dark); transform: scale(0.98); }
.btn-success:active:not(:disabled) { background: var(--md-success-dark); transform: scale(0.98); }
.btn-warning:active:not(:disabled) { background: var(--md-warning-dark); transform: scale(0.98); }
.btn-outline:active:not(:disabled) { background: #eeeeee; transform: scale(0.98); }
.btn-danger:active:not(:disabled)  { background: var(--md-error-dark); transform: scale(0.98); }

.md-button:disabled {
  background: #e0e0e0;
  color: #9e9e9e;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* ---------------------------------------------------
   4. Forms & Inputs
--------------------------------------------------- */
.form-group, .input-field {
  margin-bottom: 20px;
  text-align: left;
}

.form-label, .input-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--md-text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.form-label .mdi, .input-field label .mdi {
  font-size: 16px;
}

.info-icon-btn {
  cursor: pointer;
  color: #9e9e9e;
  margin-left: 2px;
  font-size: 16px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.info-icon-btn:hover, .info-icon-btn:active {
  color: var(--md-primary-dark);
}

.form-input, .input-field input {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--md-divider);
  border-radius: var(--border-radius);
  font-size: 15px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
  color: var(--md-text-primary);
}

.form-input:focus, .input-field input:focus {
  border-color: var(--md-primary);
}

.form-input[readonly] {
  background-color: var(--md-background);
  color: var(--md-text-secondary);
  cursor: default;
}

.form-input[readonly]:focus {
  border-color: var(--md-divider);
}

.input-error {
  border-color: var(--md-error) !important;
}

.field-error-message {
  display: block;
  font-size: 12px;
  color: var(--md-error);
  margin-top: 4px;
  min-height: 16px;
  text-align: left;
}

/* ---------------------------------------------------
   기기 식별번호 반응형 폰트 처리
--------------------------------------------------- */
#acc_dev {
  font-size: 15px; /* PC 등 넓은 화면에서는 15px */
}

/* 화면 가로폭이 600px 이하인 모바일 환경에서는 12.9px로 축소 */
@media (max-width: 600px) {
  #acc_dev {
    font-size: 12.9px; 
  }
}

/* ---------------------------------------------------
   5. UI Messages & Status
--------------------------------------------------- */
.message {
  margin-bottom: 20px;
  text-align: center;
  font-size: 14px;
  word-break: keep-all;
  line-height: 1.5;
}

.message:empty {
  display: none;
}

.message.error {
  color: var(--md-error);
}

.message.success {
  color: var(--md-success);
}

.status-display {
  text-align: center;
  padding: 20px 0;
  font-weight: 500;
  color: var(--md-text-primary);
}

/* ---------------------------------------------------
   6. Auth Links
--------------------------------------------------- */
.action-links {
  margin-top: 24px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.action-links a {
  color: var(--md-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.action-links a:hover {
  color: var(--md-primary-dark);
  text-decoration: underline;
}

.action-links-divider {
  color: var(--md-divider);
  font-size: 12px;
}

/* ---------------------------------------------------
   7. Menu List
--------------------------------------------------- */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid var(--md-divider);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--md-surface);
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

@media (hover: hover) {
  .menu-item:hover {
    background: #fafafa;
    border-color: #bdbdbd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }
}

.menu-item:active {
  background: #f0f0f0;
  transform: scale(0.99);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.menu-item .mdi:first-child {
  font-size: 24px;
  color: var(--md-primary);
  margin-right: 16px;
}

.menu-item-text {
  flex-grow: 1;
  font-size: 16px;
  font-weight: 500;
}

.menu-item-arrow {
  font-size: 24px;
  color: var(--md-text-secondary);
  margin-right: -6px;
}

/* ---------------------------------------------------
   8. Balance
--------------------------------------------------- */
.balance-text-wrapper {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 8px 16px 8px;
  margin-bottom: 28px;
  border-bottom: 2px solid #bdbdbd;
}

.balance-text-label {
  font-size: 18px;
  font-weight: 500;
  color: #5c5c5c;
}

.balance-text-amount {
  font-size: 36px;
  font-weight: 700;
  color: #3d4e57;
  letter-spacing: -0.5px;
  line-height: 1;
}

.balance-text-amount span.currency {
  font-size: 18px;
  font-weight: 500;
  margin-left: 4px;
  color: #5c5c5c;
}

/* ---------------------------------------------------
   9. Utilities
--------------------------------------------------- */
.hidden {
  display: none !important;
}

.md-divider {
  border: none;
  border-top: 1px solid var(--md-divider);
  margin: 16px 0;
}

/* ---------------------------------------------------
   10. Auth Layout
--------------------------------------------------- */
.auth-centered-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;   /* 구형 브라우저를 위한 안전장치 */
  min-height: 100dvh;  /* 모바일 브라우저를 위한 동적 높이 대응 */
  box-sizing: border-box;
  padding: 16px;
  padding-bottom: 8vh; /* 시각적 안정감을 위해 정중앙에서 살짝 위로 끌어올림 */
}

.auth-centered-layout .md-card {
  margin-bottom: 0;
}

/* ---------------------------------------------------
   11. Advanced Loading Overlay & Popup
--------------------------------------------------- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease-out;
}

.loading-popup {
  background: var(--md-surface);
  padding: 32px 40px;
  border-radius: var(--border-radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner-container {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 4px solid #f0f0f0;
  border-top-color: var(--md-primary);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  box-sizing: border-box;
}

.spinner-container .mdi {
  font-size: 24px;
  color: var(--md-primary);
}

.loading-text {
  color: var(--md-text-primary);
  font-size: 16px;
  font-weight: 400;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------------------------------------------------
   12. Root Service List Layout
--------------------------------------------------- */
.card-centered-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;   /* 구형 브라우저를 위한 안전장치 */
  min-height: 100dvh;  /* 모바일 브라우저를 위한 동적 높이 대응 */
  box-sizing: border-box;
  padding: 16px;
  padding-bottom: 8vh; /* 시각적 안정감을 위해 정중앙에서 살짝 위로 끌어올림 */
}

.card-centered-layout .md-card {
  margin-bottom: 0;
  width: 100%;
  max-width: 480px;
  box-sizing: border-box;
}

.service-list-card {
  text-align: center;
  padding: 16px 24px 40px !important; 
}

.service-list-icon {
  font-size: 100px;
  color: #6e6e6e; 
  margin-bottom: 12px;
  display: inline-block;
  line-height: 1; 
}

.service-list-title {
  font-size: 24px;
  color: var(--md-text-primary);
  margin: 0 0 16px 0;
  font-weight: 700;
}

.service-list-desc {
  font-size: 15px;
  color: var(--md-text-secondary);
  line-height: 1.6;
  margin-bottom: 36px;
  word-break: keep-all;
}

.service-list-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.service-list-actions a {
  text-decoration: none;
}

/* ---------------------------------------------------
   13. Toast Notification
--------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast-container.show {
  bottom: 40px;
}

.toast-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 8px;
  background: #323232;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  word-break: keep-all;
  line-height: 1.4;
}

.toast-success .toast-icon {
  color: #66bb6a;
}

.toast-error .toast-icon {
  color: #ef5350;
}

.toast-icon {
  font-size: 22px;
  flex-shrink: 0;
}

/* ---------------------------------------------------
   14. Modal & SMS Auth
--------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease-out;
  padding: 16px;
  box-sizing: border-box;
}

.modal-content {
  background: var(--md-surface);
  padding: 32px 24px;
  border-radius: var(--border-radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: var(--md-text-primary);
}

.modal-desc {
  font-size: 14px;
  color: var(--md-text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
  word-break: keep-all;
}

.modal-timer {
  font-size: 24px;
  font-weight: 700;
  color: var(--md-error);
  margin-bottom: 24px;
  font-variant-numeric: tabular-nums;
}

.sms-input-group {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 12px;
  width: 100%;
}

.sms-input {
  flex: 1;
  min-width: 0;
  max-width: 48px;
  height: 52px;
  padding: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  border: 1px solid var(--md-divider);
  border-radius: var(--border-radius);
  outline: none;
  transition: all 0.2s;
  color: var(--md-text-primary);
  background: var(--md-surface);
}

.sms-input:focus {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 2px rgba(117, 117, 117, 0.2);
}

/* ---------------------------------------------------
   15. Refactored Inline Styles
--------------------------------------------------- */
.error-title {
  color: var(--md-error);
  margin-bottom: 16px;
  font-size: 22px;
}

.error-desc {
  font-size: 16px;
  color: var(--md-text-primary);
  margin-bottom: 24px;
  line-height: 1.5;
  word-break: keep-all;
}

.error-timer {
  font-size: 14px;
  color: var(--md-text-secondary);
}

.barcode-card {
  text-align: center;
}

.barcode-title {
  justify-content: center;
}

.barcode-subtitle {
  margin-bottom: 24px;
}

.barcode-box {
  background: #fafafa;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
  border: 1px solid var(--md-divider);
  border-radius: var(--border-radius);
}

.barcode-icon {
  font-size: 96px;
  color: #424242;
}