:root {
  color-scheme: light;
  --bg: #f8f3f7;
  --surface: #ffffff;
  --surface-soft: #f5edf5;
  --text: #2b2230;
  --muted: #786a7d;
  --line: #e4d6e5;
  --primary: #8f5fa8;
  --primary-dark: #673f7a;
  --accent: #c98556;
  --danger: #b44d55;
  --shadow: 0 10px 30px rgba(65, 39, 75, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(16px, 4vw, 48px);
  background: #673f7a;
  color: #ffffff;
}

.app-header h1 {
  margin: 4px 0 0;
  font-size: clamp(26px, 3vw, 40px);
  letter-spacing: 0;
}

.header-subtitle {
  max-width: 720px;
  margin: 8px 0 0;
  color: #f4e6f5;
  font-weight: 700;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.app-header .eyebrow {
  color: #f0d8f3;
}

.header-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-shell {
  display: grid;
  gap: 20px;
  width: min(1480px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.tool-contact-footer {
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-contact-footer h2 {
  margin: 4px 0 10px;
}

.tool-contact-footer h2 a,
.tool-contact-lines a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 800;
}

.tool-contact-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.trial-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, auto);
  gap: 18px;
  align-items: start;
  padding: 20px;
  border: 1px solid #e4d6e5;
  border-radius: 8px;
  background: #fbf4ff;
  box-shadow: var(--shadow);
}

.trial-intro h2 {
  margin: 4px 0 8px;
  font-size: 24px;
}

.trial-intro p:last-child {
  max-width: 860px;
  margin: 0;
  color: #4b3557;
  font-weight: 700;
}

.trial-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.trial-flow {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trial-flow li {
  min-height: 58px;
  padding: 12px;
  border: 1px solid #e4d6e5;
  border-radius: 6px;
  background: #ffffff;
  color: #4b3557;
  font-weight: 800;
}

.trial-status {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #673f7a;
  color: #ffffff;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 104px;
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  color: var(--primary-dark);
  font-size: 32px;
  line-height: 1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(420px, 1.05fr);
  gap: 20px;
  align-items: start;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.75fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  padding: 20px;
}

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

.panel-heading h2 {
  margin: 2px 0 0;
  font-size: 22px;
}

.status-pill,
.review-badge,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.review-badge.needs-review {
  background: #fff5e9;
  color: #8a6122;
}

.review-badge.ready {
  background: #f0e2f2;
  color: #673f7a;
}

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: #fff5e9;
  color: #6f4526;
  font-weight: 700;
}

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

.compact-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: #4b3557;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #e4d6e5;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(143, 95, 168, 0.18);
}

.helper-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.wide-field {
  margin-top: 14px;
}

.leave-section {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf6fb;
}

.attachment-section {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf6fb;
}

.subsection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.subsection-heading h3 {
  margin: 0;
  font-size: 18px;
}

.leave-fields {
  margin-top: 14px;
}

.leave-fields.is-collapsed {
  display: none;
}

.field-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 800;
}

.safe-hours-panel {
  display: grid;
  align-content: center;
}

.safe-hours-panel h2 {
  max-width: 620px;
}

.progress-track {
  width: 100%;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadfed;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8f5fa8, #c985b8);
  transition: width 180ms ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
}

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

.chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbf6fb;
}

.chart-card h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(84px, 120px) minmax(120px, 1fr) minmax(34px, auto);
  gap: 10px;
  align-items: center;
  color: #4b3557;
  font-size: 14px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadfed;
}

.bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.top-case-list {
  display: grid;
  gap: 10px;
}

.top-case-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 6px;
  background: #f5edf5;
}

.top-case-item strong {
  color: var(--primary-dark);
}

.top-case-item span {
  color: var(--muted);
  font-size: 13px;
}

.advice-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.advice-list li {
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  background: #f5edf5;
  color: #4b3557;
  font-weight: 700;
}

.print-report {
  display: grid;
  gap: 18px;
}

.report-cover {
  padding: 16px;
  border-radius: 8px;
  background: #673f7a;
  color: #ffffff;
}

.report-cover p,
.report-cover h2,
.report-cover span {
  margin: 0;
}

.report-cover h2 {
  margin: 4px 0;
  font-size: 26px;
}

.report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.report-kpi-grid article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbf6fb;
}

.report-kpi-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.report-kpi-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--primary-dark);
  font-size: 28px;
}

.report-table {
  width: 100%;
  min-width: 0;
}

.report-note {
  margin: 0;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: #fff5e9;
  color: #6f4526;
  font-weight: 800;
}

.lost-time-tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff5e9;
  color: #8a6122;
  font-weight: 800;
  white-space: nowrap;
}

.lost-time-tag.no {
  background: #f5edf5;
  color: #4b3557;
}

.attachment-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.attachment-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.attachment-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.attachment-item strong {
  color: var(--primary-dark);
}

.attachment-item span,
.attachment-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.attachment-preview {
  max-width: 160px;
  max-height: 110px;
  border-radius: 6px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.attachment-count-tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff5e9;
  color: #8a6122;
  font-weight: 800;
  white-space: nowrap;
}

.attachment-count-tag.has-files {
  background: #f0e2f2;
  color: #673f7a;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

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

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  background: #f0e2f2;
  color: var(--primary-dark);
}

.danger-button {
  background: #ffe5e5;
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1460px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f5edf5;
  color: #4b3557;
  font-weight: 800;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fbf6fb;
}

.empty-state {
  margin: 18px 0 0;
  color: var(--muted);
  text-align: center;
}

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

.demo-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbf6fb;
}

.demo-card h3 {
  margin: 0;
  font-size: 17px;
}

.demo-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.demo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-grid,
  .dashboard-grid,
  .trial-panel {
    grid-template-columns: 1fr;
  }

  .trial-actions {
    justify-content: flex-start;
  }

  .trial-flow,
  .report-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid,
  .form-grid,
  .compact-grid,
  .demo-grid,
  .chart-grid,
  .trial-flow,
  .report-kpi-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .progress-meta {
    flex-direction: column;
  }

  .panel {
    padding: 16px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-header,
  .trial-panel,
  .stats-grid,
  .dashboard-grid,
  .workspace-grid,
  .panel:not(.print-report-panel),
  .demo-grid {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    margin: 0;
  }

  .print-report-panel {
    display: block !important;
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .print-report-panel .panel-heading {
    display: none;
  }

  .report-cover {
    color: #2b2230;
    background: #ffffff;
    border-bottom: 2px solid #673f7a;
    border-radius: 0;
  }

  .report-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
