:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #647067;
  --line: #d8dfd9;
  --soft: #f4f7f3;
  --panel: #ffffff;
  --brand: #2f6f50;
  --brand-2: #b08952;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #257a55;
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px 12px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(244, 247, 243, .86), rgba(244, 247, 243, .94)),
    url("https://images.unsplash.com/photo-1495474472287-4d71bcdd2085?auto=format&fit=crop&w=1800&q=80") center / cover;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 60px rgba(23, 33, 28, .12);
}

.brand-mark {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.login-logo {
  display: block;
  width: min(240px, 78%);
  height: auto;
  margin: 0 auto 18px;
}

.muted {
  color: var(--muted);
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100dvh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.nav-title {
  font-weight: 800;
  line-height: 1.3;
  margin: 0 8px 18px;
}

.sidebar-logo {
  display: block;
  width: 168px;
  max-width: 100%;
  height: auto;
  margin-bottom: 10px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.nav button.active {
  background: #eaf2ed;
  border-color: #cfe1d7;
  color: var(--brand);
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  padding: 12px 22px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.content {
  padding: 22px;
  max-width: 1280px;
}

.page-title {
  font-size: 24px;
  margin: 0 0 16px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.stat {
  display: grid;
  gap: 6px;
}

.stat strong {
  font-size: 26px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

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

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

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

th {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #edf3ef;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.badge.warn {
  background: #fff3e4;
  color: var(--warn);
}

.badge.danger {
  background: #fff0ee;
  color: var(--danger);
}

.audit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
}

.item-card {
  display: grid;
  gap: 12px;
}

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

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented button {
  min-height: 36px;
}

.segmented button.active-pass {
  background: #e8f5ee;
  border-color: #afd6c1;
  color: var(--ok);
}

.segmented button.active-fail {
  background: #fff0ee;
  border-color: #efb1aa;
  color: var(--danger);
}

.segmented button.active-rec {
  background: #fff8e8;
  border-color: #e3c17f;
  color: var(--warn);
}

.hidden {
  display: none !important;
}

.signature-pad {
  width: 100%;
  height: 170px;
  border: 1px dashed #aeb8af;
  border-radius: 6px;
  background: #fff;
  touch-action: none;
}

.photo-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.photo-list img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.photo-preview {
  min-height: 82px;
  align-content: flex-start;
  padding: 10px;
  border: 1px dashed #b7c2ba;
  border-radius: 6px;
  background: #fbfcfb;
}

.clause-preview:empty {
  display: none;
}

.clause-card {
  background: #fbfcfb;
}

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

.finding-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.finding-row p {
  margin: 6px 0 0;
}

.score-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e5d3b8;
  border-radius: 8px;
  background: #fff8e8;
  padding: 12px;
}

.score-preview strong {
  font-size: 24px;
  color: var(--warn);
}

.trend {
  display: flex;
  min-height: 210px;
  gap: 10px;
  align-items: end;
  overflow-x: auto;
  padding-top: 18px;
}

.trend-point {
  flex: 1 0 54px;
  min-width: 54px;
  display: grid;
  grid-template-rows: 140px auto auto;
  gap: 6px;
  align-items: end;
  text-align: center;
}

.trend-bar {
  width: 24px;
  max-height: 140px;
  justify-self: center;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #2f6f50, #86b793);
}

.trend-point strong {
  font-size: 14px;
}

.trend-point span {
  color: var(--muted);
  font-size: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 36%) 42px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.bar-label {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.bar-label strong,
.bar-label span {
  overflow-wrap: anywhere;
}

.bar-label span {
  color: var(--muted);
  font-size: 12px;
}

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

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

.bar-value {
  text-align: right;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  background: #17211c;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
  z-index: 20;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav button {
    flex: 0 0 auto;
  }

  .content {
    padding: 14px;
  }

  .grid.cols-2,
  .grid.cols-3,
  .audit-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    padding: 12px 14px;
  }

  .panel,
  .card {
    padding: 14px;
  }

  .finding-row {
    grid-template-columns: 1fr;
  }

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

  .bar-value {
    text-align: left;
  }
}
