:root {
  --ink: #192e37;
  --muted: #667b84;
  --accent: #16736a;
  --line: #dce5e8;
  --bg: #f4f7f8;
  --warm: #fff5dd;
  --red: #a33c36;
  font:
    14px/1.55 -apple-system,
    BlinkMacSystemFont,
    "Noto Sans TC",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  outline-offset: 3px;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 9px 14px;
  color: var(--ink);
}
button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.primary:hover {
  background: #115d56;
  color: white;
}
.quiet {
  background: transparent;
}
.shell {
  display: grid;
  grid-template-columns: 218px 1fr;
  min-height: 100vh;
}
.sidebar {
  padding: 30px 18px;
  border-right: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.brand {
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.5px;
  padding: 0 12px 26px;
}
.brand small {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
  margin-top: 4px;
}
.nav {
  border: 0;
  text-align: left;
  padding: 12px 16px;
  color: var(--muted);
}
.nav.active {
  background: #e5f2ee;
  color: #13685f;
  font-weight: 650;
}
.sidebar footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
  padding: 12px;
}
.main {
  min-width: 0;
  padding: 28px 36px 60px;
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
}
.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 1.8px;
  color: var(--accent);
  font-weight: 700;
}
h1 {
  font-size: 28px;
  line-height: 1.25;
  margin: 6px 0;
}
h2 {
  font-size: 19px;
  margin: 0 0 14px;
}
h3 {
  font-size: 15px;
  margin: 4px 0 12px;
}
p {
  margin: 8px 0;
}
.muted,
small {
  color: var(--muted);
}
.notice {
  padding: 11px 15px;
  border-radius: 8px;
  background: var(--warm);
  color: #805c1e;
  font-size: 12px;
  margin-bottom: 20px;
}
.context {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  background: #eaf0f2;
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.context label {
  min-width: 135px;
  flex: 1;
}
.context .badge {
  align-self: center;
}
.badge {
  display: inline-flex;
  border-radius: 30px;
  background: #e7f3ef;
  color: #15695f;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.badge.pending {
  background: #fff0d2;
  color: #8b621d;
}
.badge.neutral {
  background: #edf0f3;
  color: #526471;
}
.card {
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #cdd9de;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
input[type="checkbox"] {
  width: auto;
}
textarea {
  min-height: 75px;
}
.check {
  flex-direction: row;
  align-items: center;
  font-size: 13px;
  color: var(--ink);
}
.field-group {
  border: 0;
  padding: 0;
  margin: 22px 0;
}
.field-group legend {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 12px;
}
.workspace {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 20px;
}
.product-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.product-menu button {
  text-align: left;
}
.product-menu .selected {
  border-color: var(--accent);
  background: #edf7f3;
}
.product-menu strong,
.product-menu small {
  display: block;
}
.tabs {
  display: flex;
  gap: 6px;
  overflow: auto;
  margin: 20px 0;
  padding-bottom: 5px;
}
.tabs button {
  white-space: nowrap;
}
.tabs .active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
  margin: 14px 0;
}
.kpi {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.kpi strong {
  display: block;
  font-size: 27px;
  letter-spacing: -0.7px;
  margin: 8px 0 0;
}
.kpi small {
  font-size: 12px;
}
.kpi.good {
  border-color: #9fcbbf;
  background: #f0f9f5;
}
.scope {
  font-size: 12px;
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin: 12px 0;
}
.scroll {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 9px;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  min-width: 95px;
}
thead th {
  background: #eff4f4;
  color: #4b646d;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
}
tbody tr:last-child td {
  border-bottom: 0;
}
.spreadsheet th:first-child,
.spreadsheet td:first-child {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 3;
  min-width: 145px;
}
.spreadsheet thead th:first-child {
  z-index: 4;
  background: #eff4f4;
}
.spreadsheet tbody tr:hover td {
  background: #f2f8f6;
}
.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.money {
  font-variant-numeric: tabular-nums;
}
.empty {
  text-align: center;
  padding: 52px 24px;
}
.empty h2 {
  margin-top: 15px;
}
.link {
  border: 0;
  padding: 0;
  color: var(--accent);
  background: none;
  text-align: left;
}
.error {
  color: var(--red);
  background: #fff0ef;
  border: 1px solid #eec2bf;
  padding: 14px;
  border-radius: 9px;
  white-space: pre-wrap;
}
.pending-list {
  font-size: 12px;
  background: var(--warm);
  padding: 12px 16px;
  border-radius: 8px;
}
.pending-list li {
  margin: 3px 0;
}
.meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0;
}
.market-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.market-card.selected {
  border-color: var(--accent);
}
.market-card strong {
  display: block;
}
.market-card button {
  margin-top: 10px;
}
.market-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0;
}
.hts-results {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 10px 0;
}
.hts-results button {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.hts-results small {
  display: block;
}
.limit {
  color: var(--muted);
  font-size: 12px;
}
.bar {
  height: 10px;
  background: #e8eff0;
  border-radius: 20px;
  overflow: hidden;
  margin: 9px 0;
}
.bar span {
  display: block;
  background: var(--accent);
  height: 100%;
  max-width: 100%;
}
.bar.over span {
  background: var(--red);
}
details {
  margin: 14px 0;
}
summary {
  cursor: pointer;
  font-weight: 600;
}
.profile-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 20px;
}
.loading {
  padding: 40px;
  color: var(--muted);
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--ink);
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 4px 24px #0002;
  display: none;
  max-width: 90vw;
}
.duties td input,
.duties td select {
  min-width: 100px;
}
.chart-note {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}
.role {
  max-width: 150px;
}
.mobile-nav {
  display: none;
}
.skeleton {
  color: var(--muted);
  padding: 20px;
}
.small {
  font-size: 12px;
}
@media (max-width: 1100px) {
  .main {
    padding: 22px;
  }
  .shell {
    grid-template-columns: 180px 1fr;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .product-menu {
    flex-direction: row;
    overflow: auto;
  }
  .product-menu button {
    min-width: 150px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 4px;
  }
  .brand {
    font-size: 18px;
    padding: 0 6px 6px;
    width: 100%;
  }
  .brand small {
    display: inline;
    margin-left: 10px;
    font-size: 9px;
  }
  .nav {
    font-size: 12px;
    padding: 8px;
  }
  .sidebar footer {
    display: none;
  }
  .main {
    padding: 18px 12px 60px;
  }
  .topline {
    align-items: flex-start;
    gap: 10px;
  }
  h1 {
    font-size: 23px;
  }
  .topline .actions {
    justify-content: end;
  }
  .role {
    max-width: 125px;
    font-size: 12px;
  }
  .card {
    padding: 16px;
  }
  .grid,
  .grid.three,
  .grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .kpis {
    gap: 8px;
  }
  .kpi {
    padding: 12px 9px;
  }
  .kpi strong {
    font-size: 22px;
  }
  .context {
    padding: 12px;
    gap: 8px;
  }
  .context label {
    min-width: 120px;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .market-cards {
    grid-template-columns: 1fr;
  }
  .scroll {
    max-height: 65vh;
  }
  button {
    padding: 8px 10px;
  }
  .notice {
    font-size: 11px;
  }
  .row {
    flex-wrap: wrap;
  }
  .duties th,
  .duties td {
    padding: 8px;
  }
  .product-menu small {
    font-size: 10px;
  }
  .empty {
    padding: 30px 12px;
  }
  .tabs {
    margin-top: 12px;
  }
}
.workspace > * {
  min-width: 0;
}
fieldset {
  min-width: 0;
}
.spreadsheet th {
  white-space: nowrap;
}
progress {
  display: block;
  width: 100%;
  margin-top: 8px;
  accent-color: var(--accent);
}

.auth-page{min-height:100vh;display:grid;place-items:center;padding:20px}.auth-card{width:min(100%,440px)}.auth-card label,#account-form label{display:block;margin:18px 0}.auth-card input,#account-form input{display:block;width:100%;box-sizing:border-box;margin-top:8px}.auth-card button{margin-top:12px}.account-row{padding:16px 0;border-bottom:1px solid #ddd;display:flex;gap:12px;flex-wrap:wrap;align-items:center}

#auth-error:empty{display:none}
