:root {
  color-scheme: light;
  --ink: #17201e;
  --muted: #64716d;
  --line: #d9e2de;
  --panel: #ffffff;
  --soft: #f4f7f5;
  --green: #1f5f56;
  --teal: #2b8378;
  --amber: #b56a13;
  --red: #b93d3d;
  --blue: #3867a6;
  --shadow: 0 16px 42px rgba(31, 48, 45, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef3f0;
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  background: #fbfcfb;
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  border-radius: 6px;
  font-weight: 800;
  font-size: 22px;
}

.brand-block h1,
.brand-block p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand-block h1 {
  font-size: 20px;
}

.brand-block p,
.eyebrow,
.account-line,
.meta,
.empty-note {
  color: var(--muted);
  font-size: 13px;
}

.login-panel {
  display: grid;
  gap: 8px;
}

.login-panel label {
  color: var(--muted);
  font-size: 13px;
}

.login-panel select,
.field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 42px;
  padding: 9px 10px;
}

.account-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

.pill.good {
  border-color: #b8d8c7;
  background: #eaf7ef;
  color: #1f6538;
}

.pill.warn {
  border-color: #efd0a7;
  background: #fff5e8;
  color: #8a4b0c;
}

.pill.danger {
  border-color: #e8b8b8;
  background: #fff0f0;
  color: #922d2d;
}

.role-nav,
.module-list {
  display: grid;
  gap: 8px;
}

.nav-button,
.module-button,
.action-button,
.icon-button,
.segmented button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  min-height: 40px;
}

.nav-button,
.module-button {
  width: 100%;
  text-align: left;
  padding: 10px 11px;
}

.nav-button.active,
.module-button.active,
.segmented button.active {
  border-color: var(--green);
  background: #e9f3ef;
  color: var(--green);
  font-weight: 700;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h2 {
  font-size: 26px;
}

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

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.icon-button.alert {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
  min-height: 88px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.module-layout {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 14px;
}

.module-list {
  align-self: start;
  position: sticky;
  top: 16px;
}

.module-panel {
  min-height: 560px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.panel-header h3 {
  margin: 0 0 5px;
  font-size: 22px;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 12px;
}

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

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

.section-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  min-height: 104px;
}

.section-box h4 {
  margin: 0 0 10px;
  font-size: 16px;
}

.data-list {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.row-title {
  font-weight: 700;
}

.row-actions,
.toolbar,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-button,
.segmented button {
  min-height: 36px;
  padding: 7px 10px;
}

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

.action-button.secondary {
  background: #eef5fb;
  border-color: #bfd0e4;
  color: var(--blue);
}

.action-button.warn {
  background: #fff5e8;
  border-color: #efd0a7;
  color: var(--amber);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.audit-table th {
  color: var(--muted);
  font-weight: 700;
}

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

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

  .role-nav,
  .module-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
  }

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

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .metric-grid,
  .grid-2,
  .grid-3,
  .role-nav,
  .module-list {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }
}
