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

:root {
  --primary:       #4e7d8e;
  --primary-light: #6a9bad;
  --primary-dark:  #3a6070;
  --sidebar:       #3d6a78;
  --bg:            #f7f9fb;
  --bg-card:       #ffffff;
  --bg-soft:       #edf4f7;
  --border:        #d4e0e5;
  --text:          #2c3e44;
  --text-light:    #6b8a94;
  --gold:          #c9a96e;
  --gold-light:    #e0c992;
  --danger:        #e53935;
  --success:       #4caf50;
}

body {
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
}

header {
  margin-bottom: 36px;
}
header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}
header p {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
  letter-spacing: 2px;
}

/* Steps */
.step { display: none; }
.step.active { display: block; }

h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}

/* Section label */
.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* Checkbox field */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.checkbox-field label {
  font-size: 13px;
  color: var(--text);
  font-weight: 400;
  cursor: pointer;
}

/* Type cards */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.type-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.type-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(78, 125, 142, 0.15);
  transform: translateY(-2px);
}
.type-card .icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  border-radius: 14px;
}
.type-card .icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--primary);
}
.type-card:hover .icon {
  background: rgba(78, 125, 142, 0.12);
}
.type-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.type-card p { font-size: 12px; color: var(--text-light); line-height: 1.6; }

/* Form */
.form-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.back-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.2s;
}
.back-btn:hover { background: var(--bg-soft); color: var(--text); }

.form-section {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}
.form-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bg-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.field-row.full { grid-template-columns: 1fr; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
}
.field label .required { color: var(--danger); margin-left: 2px; }

.field input, .field textarea, .field select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border 0.2s;
  background: var(--bg);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input[type="number"] { -moz-appearance: textfield; }

/* Tags input */
.tags-container {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--bg);
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  cursor: text;
}
.tags-container:focus-within { border-color: var(--primary); background: #fff; }
.tag {
  background: var(--bg-soft);
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tag .remove { cursor: pointer; font-size: 15px; line-height: 1; color: var(--text-light); }
.tag .remove:hover { color: var(--danger); }
.tags-input {
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  min-width: 120px;
  flex: 1;
}

.hint { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* Form actions */
.form-actions {
  text-align: center;
  margin-top: 8px;
}
.generate-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 48px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.generate-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(78, 125, 142, 0.35);
}
.generate-btn:active { transform: translateY(0); }

/* Loading */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(247, 249, 251, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 16px;
  color: var(--text-light);
}
.loading.hidden { display: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--bg-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth pages */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.auth-box {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(78, 125, 142, 0.1);
  border: 1px solid var(--border);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 18px; font-weight: 700; color: var(--text); }
.auth-logo p { font-size: 12px; color: var(--text-light); margin-top: 4px; letter-spacing: 2px; }
.auth-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.2s;
}
.auth-btn:hover { background: var(--primary-dark); }
.auth-link { text-align: center; font-size: 13px; color: var(--text-light); margin-top: 16px; }
.auth-link a { color: var(--primary); text-decoration: none; }
.alert {
  background: #fef2f2;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid #fecaca;
}
.alert.success {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
}

/* Admin table */
.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.user-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-light);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.user-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg-soft);
  color: var(--text);
}
.action-btn {
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  margin-right: 6px;
}
.action-btn.approve { background: #f0fdf4; color: var(--success); }
.action-btn.approve:hover { background: var(--success); color: #fff; }
.action-btn.reject { background: #fef2f2; color: var(--danger); }
.action-btn.reject:hover { background: var(--danger); color: #fff; }

/* ── Header bar ──────────────────────────── */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.header-nav a {
  font-size: 13px;
  color: #888;
  text-decoration: none;
}
.header-nav a:first-child { color: var(--primary); }
.header-user {
  font-size: 13px;
  color: #aaa;
}

/* ── Table wrap (horizontal scroll on mobile) */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Mobile ≤ 640px ──────────────────────── */
@media (max-width: 640px) {
  .container {
    padding: 20px 14px;
  }

  /* Header */
  header { margin-bottom: 24px; }
  header > div:first-child img { height: 120px !important; }
  .header-title { font-size: 17px; }
  .header-nav { gap: 10px; }
  .header-nav a, .header-user { font-size: 12px; }

  /* Type cards — 1 column, horizontal layout */
  .type-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .type-card {
    display: flex;
    align-items: center;
    text-align: left;
    padding: 16px;
    gap: 16px;
  }
  .type-card .icon {
    margin: 0;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
  }
  .type-card h3 { margin-bottom: 4px; font-size: 14px; }
  .type-card p { font-size: 11px; }
  .type-card:hover { transform: none; }

  /* Form sections */
  .form-section { padding: 16px 14px; margin-bottom: 14px; }
  .form-section h3 { font-size: 13px; margin-bottom: 14px; }
  .form-header { margin-bottom: 16px; }
  .form-header h2 { font-size: 15px; }

  /* All field rows stack to single column */
  .field-row { grid-template-columns: 1fr; gap: 10px; margin-bottom: 10px; }

  /* Prevent iOS auto-zoom on inputs */
  .field input,
  .field textarea,
  .field select {
    font-size: 16px;
  }

  /* Tags input */
  .tags-input { min-width: 80px; font-size: 16px; }

  /* Generate button full width */
  .generate-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 15px;
  }

  /* h2 */
  h2 { font-size: 15px; }

  /* Auth pages */
  .auth-box { padding: 24px 18px; }
  .auth-logo img { height: 100px !important; }

  /* Admin header */
  .container > header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .container > header > div:last-child {
    align-self: flex-end;
  }
}

/* ── Very small phones ≤ 380px ───────────── */
@media (max-width: 380px) {
  .container { padding: 16px 12px; }
  .header-nav { gap: 8px; }
  .type-card { padding: 14px 12px; gap: 12px; }
  .form-section { padding: 14px 12px; }
}
