:root {
  --ink: #15232b;
  --muted: #65747d;
  --line: #d9e2e7;
  --line-strong: #c3d0d7;
  --panel: #ffffff;
  --page: #f5f7f8;
  --soft-blue: #edf4fb;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #dcefeb;
  --blue: #2563eb;
  --amber: #b7791f;
  --green: #15803d;
  --red: #dc2626;
  --shadow: 0 16px 40px rgba(18, 38, 51, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 280px),
    var(--page);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

.shell {
  margin: 24px auto;
  max-width: 1760px;
  padding: 0 20px 44px;
}

.title-bar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 980px;
  min-height: 72px;
  padding: 14px 18px;
}

.home-link {
  align-items: center;
  color: inherit;
  display: inline-flex;
  gap: 14px;
  text-decoration: none;
}

.seal {
  align-items: center;
  background: var(--brand);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-weight: 900;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.title-bar small,
.eyebrow {
  color: var(--muted);
  display: block;
  font-size: 0.84rem;
}

.title-bar strong {
  color: var(--ink);
  display: block;
  font-size: clamp(1.08rem, 2vw, 1.5rem);
}

.user-tools {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  gap: 10px;
  justify-content: flex-end;
}

.user-tools a,
.user-tools button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand-dark);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 7px 11px;
  text-decoration: none;
}

.home {
  margin: 0 auto;
  max-width: 980px;
}

.home h1 {
  font-size: 1.35rem;
  margin: 0 0 14px;
}

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

.area-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(18, 38, 51, 0.06);
  color: var(--ink);
  min-height: 144px;
  padding: 18px;
  position: relative;
  text-align: left;
  transition: 150ms ease;
}

.area-card::before {
  background: var(--brand);
  border-radius: 8px 8px 0 0;
  content: "";
  height: 5px;
  inset: 0 0 auto;
  position: absolute;
}

.area-card.student::before {
  background: var(--blue);
}

.area-card.staff::before {
  background: #64748b;
}

.area-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.area-card span {
  color: var(--muted);
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.area-card strong {
  display: block;
  font-size: 1.35rem;
}

.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #26363e;
  font-size: 0.95rem;
  margin-top: 18px;
  padding: 16px 18px;
}

.notice p {
  margin: 0 0 8px;
}

.notice p:last-child {
  margin-bottom: 0;
}

.section-nav {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(18, 38, 51, 0.06);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin: 0 0 14px;
  padding: 8px;
}

.section-nav button,
.section-nav a {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #33464f;
  display: inline-flex;
  font-size: 0.98rem;
  font-weight: 800;
  min-height: 38px;
  padding: 8px 12px;
  text-decoration: none;
}

.section-nav button:hover,
.section-nav button.active,
.section-nav a:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.content-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

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

.heading-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.table-heading h2,
.table-heading p {
  margin: 0;
}

.table-heading h2 {
  font-size: 1.35rem;
}

.primary-button,
.secondary-button {
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 14px;
}

.primary-button {
  background: var(--brand);
  border: 1px solid var(--brand-dark);
  color: #fff;
  font-weight: 800;
}

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

.secondary-button {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: #26363e;
}

.secondary-button:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.admin-list-tools {
  align-items: center;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #344750;
  display: grid;
  gap: 10px;
  grid-template-columns: auto auto 1fr auto;
  margin: 8px 0 12px;
  padding: 10px;
}

.admin-list-tools label,
.search-form {
  align-items: center;
  display: flex;
  gap: 7px;
}

.admin-list-tools select,
.admin-list-tools input {
  min-height: 34px;
  padding: 6px 9px;
  width: auto;
}

.search-form {
  justify-content: center;
}

.search-form input {
  min-width: 180px;
}

.record-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.record-actions button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #33464f;
  font-weight: 700;
  min-height: 34px;
  padding: 6px 10px;
}

.record-actions button:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

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

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

th {
  background: #f1f5f7;
  color: #33464f;
  font-size: 0.95rem;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

td {
  background: #fff;
  color: #172832;
  font-size: 0.96rem;
}

tbody tr:nth-child(even) td {
  background: #fbfcfd;
}

tbody tr.open-row td {
  background: #fff7ed;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover td,
tbody tr.selected td {
  background: var(--soft-blue);
}

.empty-row {
  color: var(--muted);
  padding: 34px 16px;
  text-align: center;
}

.status {
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  padding: 6px 9px;
  white-space: nowrap;
}

button.status:hover {
  filter: brightness(0.97);
}

.status.open {
  background: #fee2e2;
  color: var(--red);
}

.status.progress {
  background: #fef3c7;
  color: var(--amber);
}

.status.done {
  background: #dcfce7;
  color: var(--green);
}

.response-link {
  align-items: center;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1d4ed8;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 30px;
  padding: 5px 8px;
  text-decoration: none;
}

.response-link:hover {
  background: #dbeafe;
}

.problem-preview {
  cursor: help;
}

.muted-action {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.row-check {
  min-height: auto;
  width: auto;
}

.pager {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

.pager button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand-dark);
  padding: 5px 9px;
}

.pager .current-page {
  color: var(--ink);
  font-weight: 900;
}

.repair-dialog,
.response-dialog,
.detail-dialog,
.response-detail-dialog,
.settings-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(8, 28, 62, 0.28);
  color: var(--ink);
  padding: 18px;
}

.repair-dialog {
  max-width: min(900px, calc(100vw - 32px));
  width: 900px;
}

.response-dialog {
  max-width: min(640px, calc(100vw - 32px));
  width: 640px;
}

.detail-dialog {
  max-width: min(820px, calc(100vw - 32px));
  width: 820px;
}

.response-detail-dialog {
  max-width: min(680px, calc(100vw - 32px));
  width: 680px;
}

.settings-dialog {
  max-width: min(980px, calc(100vw - 32px));
  width: 980px;
}

.repair-dialog::backdrop,
.response-dialog::backdrop,
.detail-dialog::backdrop,
.response-detail-dialog::backdrop,
.settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}

.dialog-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin: 0 0 14px;
  padding-bottom: 10px;
}

.dialog-head h2 {
  color: var(--ink);
  font-size: 1.18rem;
  margin: 0;
}

.close-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #344750;
  display: inline-flex;
  font-size: 1.3rem;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.close-button:hover {
  border-color: var(--red);
  color: var(--red);
}

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

label {
  color: #23343c;
  display: grid;
  font-size: 0.92rem;
  font-weight: 800;
  gap: 6px;
}

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

.field-hint {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  margin: 12px 0 0;
  padding: 10px 12px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  min-height: 36px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
  outline: 0;
}

input[readonly] {
  background: #edf3f7;
  color: var(--muted);
  cursor: default;
}

.self-check {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #23343c;
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 12px;
}

.self-check legend {
  font-weight: 900;
  padding: 0 5px;
}

.self-check label {
  align-items: start;
  display: flex;
  gap: 9px;
}

.self-check input {
  min-height: auto;
  width: auto;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.response-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 130px 1fr;
  overflow: hidden;
}

.response-grid label {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  grid-template-columns: 130px 1fr;
  padding: 10px;
}

.response-grid label:last-child {
  border-bottom: 0;
}

.response-grid textarea {
  min-height: 220px;
}

.detail-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 150px 1fr;
  overflow: hidden;
}

.example-content {
  display: grid;
  gap: 16px;
}

.example-content h3 {
  color: var(--ink);
  font-size: 1rem;
  margin: 0 0 8px;
}

.example-fields {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(150px, 0.36fr) 1fr;
  margin: 0;
  overflow: hidden;
}

.example-fields dt,
.example-fields dd {
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 9px 12px;
}

.example-fields dt {
  background: #f8fafb;
  color: #23343c;
  font-weight: 900;
}

.example-fields dd {
  color: var(--ink);
  font-weight: 750;
}

.example-fields dt:nth-last-child(2),
.example-fields dd:last-child {
  border-bottom: 0;
}

.example-content pre {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
  font-weight: 800;
  line-height: 1.7;
  margin: 0;
  overflow-x: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.example-content ul {
  color: #23343c;
  display: grid;
  gap: 8px;
  line-height: 1.6;
  margin: 0;
  padding-left: 22px;
}

.detail-label,
.detail-value {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.detail-label {
  background: #f8fafb;
  color: #23343c;
  font-weight: 900;
}

.detail-value {
  white-space: pre-line;
}

.detail-label:nth-last-child(2),
.detail-value:last-child {
  border-bottom: 0;
}

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

.settings-grid textarea {
  min-height: 128px;
}

.permission-editor {
  display: grid;
  gap: 10px;
}

.permission-editor-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.permission-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

.permission-table {
  min-width: 1120px;
}

.permission-table th,
.permission-table td {
  font-size: 0.88rem;
  padding: 9px;
  vertical-align: top;
}

.permission-table input,
.permission-table select {
  font-size: 0.9rem;
  min-height: 38px;
  width: 100%;
}

.permission-checks {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  min-width: 250px;
}

.permission-checks label {
  align-items: center;
  display: flex;
  font-size: 0.84rem;
  gap: 5px;
}

.permission-checks input {
  min-height: auto;
  width: auto;
}

.danger-button {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  cursor: pointer;
  font-weight: 800;
  padding: 8px 10px;
}

.hover-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 520px;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  white-space: pre-line;
  z-index: 40;
}

.toast {
  background: #172832;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #fff;
  left: 50%;
  max-width: min(560px, calc(100vw - 32px));
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  position: fixed;
  top: 18px;
  transform: translate(-50%, -14px);
  transition: 160ms ease;
  z-index: 2147483647;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 28px 16px;
}

.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 460px;
  padding: 28px;
  width: 100%;
}

.login-brand {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
}

.login-brand small {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
}

.login-brand h1 {
  font-size: 1.55rem;
  line-height: 1.2;
  margin: 0;
}

.login-note {
  color: var(--muted);
  margin: 0 0 18px;
}

.login-demo {
  background: var(--brand-soft);
  border: 1px solid #b9d8d2;
  border-radius: 8px;
  color: var(--brand-dark);
  font-weight: 800;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.login-error {
  background: #fff1f1;
  border: 1px solid #f0b6b6;
  border-radius: 8px;
  color: #9d2525;
  font-weight: 800;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form .primary-button {
  margin-top: 4px;
  width: 100%;
}

.notice.compact {
  background: #f8fafb;
  font-size: 0.9rem;
  margin-top: 18px;
  padding: 12px;
}

@media (max-width: 900px) {
  .shell {
    margin-top: 14px;
    padding-inline: 12px;
  }

  .area-cards,
  .admin-list-tools,
  .settings-grid,
  .response-grid,
  .response-grid label {
    grid-template-columns: 1fr;
  }

  .area-card {
    min-height: 104px;
  }

  .title-bar,
  .table-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-nav {
    justify-content: flex-start;
  }

  .search-form,
  .admin-list-tools label {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form {
    justify-content: stretch;
  }

  .search-form input,
  .admin-list-tools select,
  .admin-list-tools input {
    width: 100%;
  }

  .record-actions {
    justify-content: stretch;
  }

  .record-actions button {
    flex: 1;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
