:root {
  --forest: #12352f;
  --forest-deep: #0a211d;
  --ivory: #f6f1e6;
  --ivory-light: #fffdf8;
  --gold: #765c24;
  --gold-light: #d8c28d;
  --ink: #20312d;
  --muted: #63716c;
  --warning: #8b4b22;
  --shadow: 0 20px 60px rgba(10, 33, 29, 0.12);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 10%, rgba(183, 149, 85, 0.13), transparent 28rem),
    var(--ivory);
  font-family: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
  line-height: 1.7;
  max-width: 100%;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: 0.22;
  background-image: linear-gradient(90deg, transparent 49.8%, rgba(18, 53, 47, 0.09) 50%, transparent 50.2%);
  background-size: 84px 84px;
}

a { color: inherit; }

.site-header,
.staff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0;
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--forest);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  place-items: center;
  color: var(--gold);
  font-size: 0.9rem;
}

.hero {
  width: min(820px, calc(100% - 40px));
  margin: clamp(48px, 10vh, 120px) auto 80px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
}

h1,
h2,
p { margin-top: 0; }

.hero h1 {
  margin-bottom: 24px;
  color: var(--forest);
  font-size: clamp(2.3rem, 7vw, 5.2rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.18;
}

.lead {
  max-width: 640px;
  margin: 0 auto 40px;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.18rem);
}

.status-panel {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  max-width: 650px;
  margin: 0 auto;
  padding: 24px 26px;
  border: 1px solid rgba(183, 149, 85, 0.42);
  background: rgba(255, 253, 248, 0.78);
  box-shadow: var(--shadow);
  text-align: left;
}

.status-panel strong {
  color: var(--forest);
  font-size: 1.08rem;
  letter-spacing: 0.06em;
}

.status-panel p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  margin-top: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 6px rgba(183, 149, 85, 0.14);
  flex: 0 0 auto;
}

footer {
  padding: 30px 20px;
  color: #56645f;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-align: center;
}

.staff-page {
  background: var(--ivory-light);
}

.staff-header {
  width: 100%;
  padding: 22px max(24px, calc((100% - 1120px) / 2));
  background: var(--forest-deep);
}

.brand-light { color: var(--ivory); }

.staff-badge,
.coming-soon {
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.staff-badge {
  padding: 7px 12px;
  color: var(--gold-light);
  border: 1px solid rgba(216, 194, 141, 0.44);
}

.staff-main {
  width: min(1000px, calc(100% - 40px));
  margin: 0 auto;
  padding: 68px 0 90px;
}

.staff-intro { max-width: 700px; }

.staff-intro h1 {
  margin-bottom: 14px;
  color: var(--forest);
  font-size: clamp(2rem, 5vw, 3.3rem);
  font-weight: 500;
  line-height: 1.25;
}

.staff-intro > p:last-child { color: var(--muted); }

.security-notice {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin: 38px 0;
  padding: 22px;
  border-left: 4px solid var(--warning);
  background: #fff5ec;
}

.notice-icon {
  display: grid;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: white;
  background: var(--warning);
  font-family: sans-serif;
  font-weight: 700;
  place-items: center;
  flex: 0 0 auto;
}

.security-notice h2 {
  margin-bottom: 4px;
  color: #6f3918;
  font-size: 1rem;
}

.security-notice p {
  margin-bottom: 0;
  color: #765642;
  font-size: 0.92rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.feature-card {
  position: relative;
  min-height: 260px;
  padding: 32px;
  overflow: hidden;
  border: 1px solid #ded7c8;
  background: var(--ivory-light);
  box-shadow: 0 12px 32px rgba(18, 53, 47, 0.08);
}

.card-number {
  display: block;
  margin-bottom: 35px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.76rem;
  letter-spacing: 0.18em;
}

.feature-card h2 {
  margin-bottom: 10px;
  color: var(--forest);
  font-size: 1.45rem;
  font-weight: 500;
}

.feature-card p {
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 0.94rem;
}

.coming-soon {
  display: inline-block;
  padding: 6px 11px;
  color: #52645e;
  background: #edf0eb;
}

.staff-footer {
  color: #a9b5b0;
  background: var(--forest-deep);
}

/* Authentication and shared form layout */
.login-page {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}
.login-page .site-header { flex: 0 0 auto; }
.login-main {
  display: grid;
  width: min(100%, 520px);
  margin: auto;
  padding: 36px 20px 72px;
  place-items: center;
}
.login-card {
  width: 100%;
  padding: clamp(28px, 6vw, 46px);
  border: 1px solid rgba(118, 92, 36, 0.28);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin-bottom: 12px;
  color: var(--forest);
  font-size: clamp(1.75rem, 7vw, 2.65rem);
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.login-lead {
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 0.98rem;
}
.login-form,
.admin-form { display: grid; gap: 18px; }
.field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--forest-deep);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.field input,
.field select,
.field textarea,
.inline-form input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid #b8b1a4;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 400;
  letter-spacing: normal;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-form input:focus {
  border-color: var(--gold);
  outline: 3px solid rgba(118, 92, 36, 0.16);
}
.primary-action,
.secondary-action {
  min-height: 46px;
  padding: 11px 18px;
  border: 1px solid var(--forest);
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.primary-action { color: #fff; background: var(--forest); }
.primary-action:hover,
.primary-action:focus-visible { background: var(--forest-deep); }
.secondary-action { color: var(--forest); background: transparent; }
.login-error {
  padding: 12px 14px;
  border-left: 4px solid #a33a2b;
  border-radius: 6px;
  color: #74281e;
  background: #fff0ed;
}
.logout-form { margin-top: 18px; }
.admin-section {
  margin-top: 38px;
  padding: 28px;
  border: 1px solid #ded7c8;
  border-radius: 16px;
  background: #fff;
}
.inline-form { display: inline-grid; gap: 8px; margin: 4px; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th,
.users-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #e7e0d4;
  text-align: left;
  vertical-align: top;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.danger { color: #842f23; border-color: #a33a2b; }

.workspace-card {
  min-width: 0;
  max-width: 100%;
  margin-top: 28px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid #ded7c8;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(18, 53, 47, 0.06);
}
.section-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}
.section-heading h2 { margin: 0; color: var(--forest); font-size: clamp(1.3rem, 3vw, 1.8rem); }
.section-heading .eyebrow { margin-bottom: 5px; }
.status-pill,
.request-meta span {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  color: #52645e;
  background: #edf0eb;
  font-size: 0.74rem;
  white-space: nowrap;
}
.status-pill.active { color: #76540b; background: #fff2c9; }
.status-pill.success { color: #1f5132; background: #d6f0de; }
.status-pill.failed { color: #762d1d; background: #f7d8cc; }
.analyze-form { display: grid; gap: 8px; margin-top: 14px; }
.analyze-form .primary-action { justify-self: start; }
.analyze-form .form-note { margin: 0; }
.failed-note { color: #762d1d; }
.request-form-placeholder { display: grid; gap: 12px; padding: 12px 4px; }
.manual-confirm-form .form-note { margin: 0; }
button[type="submit"][disabled] { opacity: 0.7; cursor: progress; }
.upload-form { display: grid; min-width: 0; max-width: 100%; grid-template-columns: 1fr auto; gap: 14px; align-items: end; }
.upload-drop {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 8px;
  padding: 18px;
  border: 1px dashed #9a8a67;
  border-radius: 12px;
  color: var(--forest);
  background: #faf8f1;
  font-weight: 700;
}
.upload-drop input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  font: inherit;
  font-weight: 400;
}
.form-note { margin: 14px 0 0; color: var(--muted); font-size: 0.85rem; }
.draft-layout { display: grid; grid-template-columns: minmax(230px, .7fr) minmax(0, 1.3fr); gap: 28px; align-items: start; }
.screenshot-panel { position: sticky; top: 20px; padding: 12px; border-radius: 14px; background: #f2eee4; }
.screenshot-panel img { display: block; width: 100%; max-height: 680px; object-fit: contain; border-radius: 9px; background: #fff; }
.screenshot-panel p { margin: 9px 2px 0; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.raw-ai-result { margin-top: 12px; }
.raw-ai-result summary { cursor: pointer; color: var(--muted); font-size: .78rem; }
.raw-ai-result pre { margin: 8px 0 0; padding: 10px; border-radius: 9px; background: #fffdf8; font-size: .72rem; line-height: 1.5; max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.cancel-draft-form { display: grid; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed #b8b1a4; }
.cancel-draft-form h3 { margin: 0; color: var(--forest); font-size: .95rem; }
.cancel-draft-form .secondary-action { justify-self: start; }
.cancel-draft-form .form-note { margin-top: 0; }
.discard-check { display: flex; gap: 8px; align-items: flex-start; color: var(--forest-deep); font-size: .78rem; font-weight: 600; }
.discard-check input { flex: 0 0 auto; width: 16px; height: 16px; min-height: 0; margin-top: 1px; }
.request-form { display: grid; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field.full { grid-column: 1 / -1; }
.field textarea { resize: vertical; }
.search-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 18px; }
.request-list { display: grid; gap: 12px; }
.request-row { display: flex; gap: 16px; justify-content: space-between; padding: 18px; border: 1px solid #e7e0d4; border-radius: 12px; background: #fffdf8; }
.request-row h3 { margin: 2px 0 4px; color: var(--forest); }
.request-row p { margin: 0; color: var(--muted); }
.request-id { color: var(--gold); font-size: .75rem; }
.request-meta { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.empty-state { padding: 34px 18px; border: 1px dashed #c9c0af; border-radius: 12px; text-align: center; color: var(--muted); }
.empty-state p { margin: 6px 0 0; }

@media (max-width: 650px) {
  .site-header,
  .staff-header { width: 100%; padding: 20px; }
  .brand { font-size: 0.9rem; letter-spacing: 0.08em; }
  .staff-badge { font-size: 0.65rem; }
  .hero { margin-top: 58px; }
  .hero h1 { letter-spacing: 0.04em; }
  .status-panel { padding: 20px; }
  .staff-main { padding-top: 48px; }
  .feature-grid { grid-template-columns: 1fr; }
  .feature-card { min-height: 230px; padding: 26px; }
  .login-page .site-header { padding: 22px 20px 4px; }
  .login-main { margin: 0 auto; padding: 28px 16px 54px; }
  .login-card { padding: 26px 20px; border-radius: 16px; }
  .login-card .eyebrow { margin-bottom: 12px; }
  .login-card h1 { font-size: clamp(1.65rem, 9vw, 2.2rem); }
  .users-table,
  .users-table tbody,
  .users-table tr,
  .users-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .users-table thead { display: none; }
  .users-table tr {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid #ded7c8;
    border-radius: 12px;
    background: #fffdf8;
  }
  .users-table td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  .users-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .82rem;
    font-weight: 700;
  }
  .users-table .actions-cell { display: block; padding-top: 12px; }
  .users-table .actions-cell::before { display: block; margin-bottom: 8px; }
  .users-table .inline-form { display: grid; width: 100%; margin: 8px 0 0; }
  .users-table .inline-form input,
  .users-table .inline-form button { width: 100%; }
  .admin-section { padding: 20px 16px; overflow: hidden; }
  .workspace-card { padding: 20px 16px; border-radius: 14px; }
  .section-heading { align-items: flex-start; flex-wrap: wrap; }
  .search-form,
  .upload-form,
  .draft-layout,
  .form-grid { grid-template-columns: 1fr; }
  .upload-form .primary-action { width: 100%; }
  .screenshot-panel { position: static; }
  .field.full { grid-column: auto; }
  .request-row { flex-direction: column; }
  .request-meta { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------------ */
/*  Request list — view tabs (active / cancelled / all)               */
/* ------------------------------------------------------------------ */
.view-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.view-tab {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: var(--forest);
  background: transparent;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
}
.view-tab:hover,
.view-tab:focus-visible {
  background: rgba(118, 92, 36, 0.1);
  outline: none;
}
.view-tab.active {
  color: #fff;
  background: var(--forest);
  border-color: var(--forest);
}

/* ------------------------------------------------------------------ */
/*  Request list — per-row cancel form (soft-cancel confirmed request) */
/* ------------------------------------------------------------------ */
.cancel-request-form {
  display: grid;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed #b8b1a4;
  border-radius: 10px;
  background: #fdf9ef;
}
.cancel-request-form .cancel-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--forest-deep);
  font-size: 0.78rem;
  font-weight: 600;
}
.cancel-request-form .cancel-check input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-height: 0;
  margin-top: 2px;
}
.cancel-request-form .secondary-action {
  justify-self: start;
  min-height: 38px;
  padding: 8px 14px;
  font-size: 0.85rem;
}
.cancel-check { display: flex; gap: 8px; align-items: flex-start; color: var(--forest-deep); font-size: .78rem; font-weight: 600; }
.cancel-check input { flex: 0 0 auto; width: 16px; height: 16px; min-height: 0; margin-top: 1px; }

.request-row {
  flex-wrap: wrap;
  align-items: flex-start;
}
.request-row-main { flex: 1 1 280px; min-width: 0; }
.request-row.cancelled { opacity: 0.85; background: #faf6ec; }
.request-row.cancelled h3 { color: var(--muted); }
.request-row.cancelled .request-id { color: var(--muted); }
.cancelled-note { margin: 12px 0 0; color: var(--muted); font-size: 0.78rem; }

@media (max-width: 720px) {
  .request-row { flex-direction: column; }
  .request-meta { justify-content: flex-start; }
  .cancel-request-form { width: 100%; }
}
