:root {
  --ink: #163047;
  --muted: #5a6d80;
  --paper: #f3f7fb;
  --panel: #ffffff;
  --line: #d5e3ef;
  --side: #0e3a5c;
  --side-2: #16486e;
  --accent: #1d6cb5;
  --accent-deep: #155892;
  --teal: #1c8a62;
  --shadow: 0 16px 40px rgba(14, 58, 92, 0.08);
  --radius: 16px;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(29, 108, 181, 0.10), transparent 60%),
    radial-gradient(700px 360px at 0% 100%, rgba(28, 138, 98, 0.08), transparent 55%),
    var(--paper);
  font-family: "Microsoft JhengHei UI", "PingFang TC", "Noto Sans TC", sans-serif;
  line-height: 1.7;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.side {
  width: 268px;
  flex: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 28%),
    var(--side);
  color: #e7f2fa;
  padding: 1.4rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
  padding: 0.2rem 0.45rem;
}

.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.brand-kicker {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #9eb6cc;
}

.brand-name {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.side nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-label {
  margin: 0.2rem 0.7rem 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: #8eabc2;
}

.side nav a {
  color: #eef6fb;
  text-decoration: none;
  border-radius: 12px;
  padding: 0.62rem 0.8rem;
}

.side nav a:hover,
.side nav a.is-active {
  background: var(--side-2);
}

.side nav a.is-active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.logout {
  margin-top: auto;
  padding: 0.85rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.who {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  word-break: break-all;
  margin-bottom: 0.7rem;
}

.avatar {
  width: 1.9rem;
  height: 1.9rem;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #d9f3e8;
  color: #146b4c;
  font-weight: 700;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.2rem 3rem;
}

.page {
  max-width: 1080px;
}

.content h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 0.45rem;
}

.content h1 + p,
.lede {
  color: var(--muted);
  max-width: 44rem;
}

.content h2 {
  margin-top: 1.8rem;
  font-size: 1.25rem;
}

.answer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 1.15rem 0 0.75rem;
  padding: 0.42rem 0.85rem;
  border-radius: 10px;
  color: #fff;
}

.answer-head.is-check {
  background: var(--teal);
}

.answer-head.is-brief {
  background: var(--accent);
}

.answer-head.is-detail {
  background: var(--accent-deep);
}

.answer-head span:last-child {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}

.content h3 {
  font-size: 1.05rem;
  margin-top: 1.2rem;
}

.panel,
.content form,
.content .card,
.content table,
.briefing,
.answer-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.content form,
.panel,
.briefing,
.answer-block {
  padding: 1.15rem 1.2rem;
}

.content form {
  margin-top: 1rem;
}

.content .card {
  border: 1px solid var(--line);
}

.form-label {
  font-weight: 650;
  color: #3c4654;
}

.form-control,
.form-select {
  border-color: #c5d6e6;
  border-radius: 12px;
  background: #fff;
  min-height: 2.7rem;
}

.form-control:focus,
.form-select:focus,
.btn:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(29, 108, 181, 0.16);
}

.btn {
  border-radius: 999px;
  font-weight: 650;
  padding: 0.5rem 1.1rem;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-deep);
}

.btn-primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.btn-outline-primary {
  color: var(--accent-deep);
  border-color: #b7d4ea;
  background: #fff;
}

.btn-outline-primary:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-secondary,
.btn-outline-light {
  color: #eef6fb;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-secondary:hover,
.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.content .btn-secondary {
  color: var(--ink);
  background: #fff;
  border-color: #c5d6e6;
}

.content .btn-danger {
  background: #8d2f2f;
  border-color: #8d2f2f;
}

.alert {
  border: 0;
  border-radius: 14px;
}

.alert-warning {
  background: #e7f3fb;
  color: #155892;
}

.alert-danger {
  background: #fdeceb;
  color: #8d2f2f;
}

.content table {
  width: 100%;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
}

.content table th {
  background: #e7f2fa;
  font-weight: 650;
  color: #1e4d73;
}

.content table th,
.content table td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.content table a {
  color: var(--teal);
  font-weight: 650;
  text-decoration: none;
}

.stat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.stat-list div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.stat-list span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-list strong {
  font-size: 1.35rem;
}

.usage,
.briefing {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1.2rem;
}

.usage-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.history-head h1 {
  margin: 0;
}

.history-head form {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.prompt-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prompt-note {
  margin: 0.8rem 0 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--teal);
  border-radius: 12px;
  background: #f3fbf7;
  white-space: pre-wrap;
}

.prompt-note.is-bad {
  border-color: var(--accent);
  background: #f4f8fc;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.prompt-grid label {
  display: grid;
  gap: 0.25rem;
}

.prompt-grid small,
.prompt-card p {
  color: var(--muted);
  margin: 0;
}

.prompt-card {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.prompt-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.prompt-box {
  min-height: 9rem;
  margin-top: 0.55rem;
  font-family: inherit;
}

.prompt-card textarea.form-control {
  height: 124px;
  min-height: 124px;
}

.prompt-save {
  margin-top: 0.4rem;
}

.briefing p {
  margin: 0;
}

.usage span,
.briefing span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.answer-text {
  font-size: 1.05rem;
  line-height: 1.9;
  margin: 0 0 0.9rem;
}

.response-check {
  white-space: pre-wrap;
}

.answer-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.4rem;
}

.source-fold {
  margin-top: 1.4rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 1rem 0.2rem;
}

.source-fold summary {
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.7rem 0.2rem;
}

.source-fold[open] summary {
  margin-bottom: 0.6rem;
}

.source-tip {
  position: relative;
  display: inline-block;
  margin-left: 0.35rem;
  color: #146b4c;
  background: #e5f6ee;
  border-radius: 999px;
  padding: 0 0.45rem;
  font-size: 0.86rem;
  text-decoration: none;
  cursor: help;
}

.source-pop {
  display: none;
  position: absolute;
  left: 0;
  top: 1.7rem;
  z-index: 20;
  width: min(44rem, 80vw);
  max-height: 28rem;
  overflow: auto;
  padding: 0.85rem 0.95rem;
  background: #fff;
  color: var(--ink);
  white-space: normal;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.source-pop-text {
  display: block;
  margin-top: 0.35rem;
  line-height: 1.6;
}

.source-tip:hover .source-pop,
.source-tip:focus .source-pop {
  display: block;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2rem 1.8rem 1.6rem;
}

.auth-card h1 {
  margin-top: 0;
}

.auth-card form {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.batch-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.batch-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.35rem 1rem 0.8rem;
  box-shadow: var(--shadow);
}

.batch-item summary {
  cursor: pointer;
  padding: 0.7rem 0.1rem;
}

.batch-line {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.batch-title {
  flex: 1;
}

.batch-no {
  color: var(--accent);
  font-weight: 700;
}

.batch-flag {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.batch-flag.is-run {
  color: var(--accent);
}

.batch-flag.is-ok {
  color: var(--teal);
}

.batch-flag.is-bad,
.batch-error {
  color: #8d2f2f;
}

.batch-question,
.batch-wait,
.batch-dept {
  margin: 0 0 0.8rem;
}

.batch-dept span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.batch-bundle {
  margin-top: 1rem;
}

.batch-bundle-note {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.batch-one {
  display: none;
}

@media (max-width: 860px) {
  .app-shell {
    flex-direction: column;
  }

  .side {
    width: 100%;
  }

  .side nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .content {
    padding: 1.2rem;
  }

  .stat-list,
  .answer-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
